d-iii-s / msim Goto Github PK
View Code? Open in Web Editor NEWLight-weight MIPS R4000 and RISC-V system simulator
Home Page: https://d3s.mff.cuni.cz/software/msim/
License: GNU General Public License v2.0
Light-weight MIPS R4000 and RISC-V system simulator
Home Page: https://d3s.mff.cuni.cz/software/msim/
License: GNU General Public License v2.0
In interactive mode, msim should first print version and then suggest to use the 'help' command. When the 'help' command is used, it should also somehow give hint about existence of device commands.
If the status register is badly set (cp0_status_ksu == 3
) MSIM may terminate on assertion in either convert_addr_kernel32
or convert_addr_kernel64
because of ASSERT(CPU_KERNEL_MODE(cpu));
(inside cpu.c
, called from convert_addr
).
It should probably be better to throw an exception (perhaps excCpU
for Coprocessor Unusable) to allow the user debug the problem instead of aborting forcefully.
[Reproducible with Kalisto if one of the mfc0 $status
is commented out in the context switch code.]
MSIM is built as a deterministic simulator but for detecting race conditions in student assignments a bit of randomization might help.
This might include tiny changes to the counter registers so that timer interrupts are not coming always at the same time. Perhaps there are other sources (destinations) of randomness?
Tab completion does not work for second parameter.
Example session follows:
<msim> Alert: Configuration file "msim.conf" not found, skipping
<msim> Alert: MSIM 1.4.0
<msim> Alert: Entering interactive mode, type `help' for help.
[msim] add dcpu cpu
[msim] cpu <TAB>
bd br break cp0d goto help id info ...
[msim] cpu b<TAB>
bd br break
[msim] cpu bre<TAB>
Sub-command is not completed when it is the only option.
This is regression from 1.3.8.5 where this worked.
This bit shall signal the current state of the device (operation in progress) and could be used for simple implementations without a need for interrupt handling.
The implementation is actually there (cp0_dump_all()
) but this function is never called.
When running bats system tests with version Bats 1.2.0-dev
all the tests are skipped.
Output:
$ bats tests/system/basic.bats
bats: ~/msim/tests/system/common.bash.bash does not exist
bats: ~/msim/tests/system/common.bash.bash does not exist
bats: ~/msim/tests/system/common.bash.bash does not exist
bats: ~/msim/tests/system/common.bash.bash does not exist
bats: ~/msim/tests/system/common.bash.bash does not exist
5 tests, 0 failures, 5 not run
I think this problem is on line 3 of tests/system/basic.bats
: load "common.bash"
.
It seems bats adds an extra .bash
at the end of the filename.
Removing the .bash
from the load fixes this problem for me.
(changing the line to load "common"
)
In progress as a student project.
When MSIM is killed (e.g. via timeout from scripts), it breaks terminal configuration. input_back()
should be called from signal handlers too.
echo "add ddisk disk" | ./msim
Terminates with
<msim> Alert: Configuration file "msim.conf" not found, skipping
<msim> Alert: MSIM 2.1.0
<msim> Alert: Entering interactive mode, type `help' for help.
[msim] add ddisk disk
<msim> Error: Missing parameter "register block address"
Segmentation fault (core dumped)
dumpdev
prints the following for a rwm
device:
[ name ] [ type ] [ parameters...
mem rwm [Start ] [Size ] [Type]
00000000000 0 none
Rather it should be:
[ name ] [ type ] [ parameters...
mem rwm [Start ] [Size ] [Type]
00000000000 0 none
Copying this as-is from a TODO
file (there is no context whether this refers to emulated memory, some part of some student assignments or MSIM's use of malloc
):
add debug features
- memory allocation
- first and last block check
- show all allocated memory blocks
- check for unallocated memory at the end of the program or at the free function call
- allocation information (function, file and the line number)
Code can use special instruction to enter interactive mode. When run from script, this usually creates issues (simulation may appear to hang when in fact it is just waiting for input). We should have a way to avoid this:
isatty
Header file /usr/include/bits/limits.h
in Alpine (tested in Docker on alpine:latest
(b2aa39c304c2
)) defines PAGESIZE
.
This shadows the variable in device/cpu/riscv_rv32ima/cpu.c
.
Fix is to rename this variable to lower case or something similar.
This option should enable monitoring register changes in the assembler (during trace) but it does not do anything at the moment. As a matter of fact, the boolean variable associated with this flag is never read anywhere in the code.
Calling cpu cp0d cause
is much more user friendly than cpu cp0d 13
.
The csrrd
dump of RISC-V CPU is rather long and for debugging purposes in our courses most of the counters are not really needed (and only clutter the view).
It might make sense to split this into two commands and remove the performance counters from the basic dump.
Following should raise an error and second device should not be added.
echo -e "add dr4kcpu one\nadd rwm one 0x0\ndumpdev" | ./msim
Instead, dumpdev
prints the following:
[ name ] [ type ] [ parameters...
one dr4kcpu R4000
one rwm [Start ] [Size ] [Type]
00000000000 0 none
The current implementation of the printer device (dprinter) flushes output inside printer_step4k, that is, only every 4096 simulator steps. Possibly, this was done to improve simulation speed, but as a result the print output is not visible when single stepping using the gdb interface. This is not a problem in the msim interface, because it uses the same output as the machine and flushes during command prompts.
(I can do the change, the reason for the ticket is I'm not sure there aren't other reasons for the delayed flush.)
Use the defined constants for bit shifts in bit operations (e.g. in cp0_status_ie
).
The documentation regarding RICV-V TLB default size mentions a Kilo-TLB and Mega-TLB size, which is a remnant of previous implementation.
Typing add <Tab><Tab>
should print list of known devices. Currently, nothing happens.
This does not work in 1.3.8.5 either but according to the old tutorial this used to work at some time in the past. Certainly a nice feature.
There seems to be a difference in handling translations between virtual and physical addresses in MSIM 1.3.8.5 and current HEAD when ERL bit is set.
Not yet sure which version behaves correctly, perhaps the old MSIM treats the condition for Cache error and ERL=1 for any exception.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.