mipt-ilab / mipt-mips Goto Github PK
View Code? Open in Web Editor NEWCycle-accurate pre-silicon simulator of RISC-V and MIPS CPUs
Home Page: http://mipt-ilab.github.io/mipt-mips/
License: MIT License
Cycle-accurate pre-silicon simulator of RISC-V and MIPS CPUs
Home Page: http://mipt-ilab.github.io/mipt-mips/
License: MIT License
AMB: all common infrastructure is moved to the base class with zero impact on MIPT-MIPS accuracy.
$ make
g++-6 -std=c++14 -Wall -Wextra -Werror -O3 -c ../../func_sim/func_memory/func_memory.cpp -I ../../
g++-6 -std=c++14 -Wall -Wextra -Werror -O3 -MM -o func_memory.d ../../func_sim/func_memory/func_memory.cpp -I ../../
g++-6 -std=c++14 -Wall -Wextra -Werror -O3 -c ../../func_sim/elf_parser/elf_parser.cpp -I ../../
g++-6 -std=c++14 -Wall -Wextra -Werror -O3 -MM -o elf_parser.d ../../func_sim/elf_parser/elf_parser.cpp -I ../../
g++-6 -std=c++14 -Wall -Wextra -Werror -O3 -c disasm.cpp -I ../../
disasm.cpp: In function 'int main(int, char**)':
disasm.cpp:30:47: error: cannot convert 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'const char*' for argument '1' to 'int strcmp(const char*, const char*)'
if ( !strcmp( section[i].name, argv[2]))
^
$ make
[g++-6] elf_parser.o
[g++-6] func_memory.o
[g++-6] func_instr.o
[g++-6] perf_sim.o
perf_sim.cpp:15:14: error: 'uint' does not name a type
static const uint PORT_BW = 1;
^~~~
Currently factorial fails on instruction 62:
./perf_sim -b ../tests/samples/factorial.out -n 100 -d -f
jr $ra
perf_sim: ../func_sim/func_memory/func_memory.cpp:79: uint64 FuncMemory::read(uint64, short unsigned int) const: Assertion `check( addr)' failed.
The problem is that jal
istruction does not perform writeback to $ra register.
AMB: C++11 is enabled as default standard in MIPT-MIPS. C++03 types are removed from types.h
Currently we use uint64 for accounting cycles. We may add better types with operator overloading, so some operations would be prohibited (like adding cycles to cycles).
Valid operations:
Cycle + Latency => Cycle
Cycle - Latency => Cycle
Cycle - Cycle => Latency
Cycle (compare) Cycle => bool
Latency + Latency => Latency
Latency - Latency => Latency
Latency / int => latency
Latency * int => Latency
int * Latency => Latency
Cycle % int => int
Examples of invalid operations:
Cycle * (anything)
Cycle / (anything)
Latency - Cycle
Both types should support literals.
AMB: make MIPT-MIPS fully buildable with MSVS. Add a wiki manual if there are some tricks.
I've added MSVC command line build to AppVeyor with two noted
Besides, everything is OK to create *.sln and *.vcxproj files (NMake is very, very bad)
AMB: GZipped traces can opened just as common ones
AMB: mem_trace.s size is reduced, so we have "C++" as main language in GitHub
MIPT-MIPS cannot model self-modifying code at the moment. However, at least we have to add some tests for that.
AMB: trace is added and demonstrates different behavior on Functional and Performance simulation
Currently we run PerfSim and FuncSim independently and then compare logs. However, if FuncSim was started inside PerfSim, we may get results a little bit simpler and faster.
Historically assignments were about creation a tool and a unit test for it. However, now we can put all unit tests to the single unit, so they can be by single command.
The trace goes to deadlock.
How to reproduce:
./perf_sim ../tests/samples/memtrace_based.out 100 -d
Currently if a header file is changes, no rebuild is performed by Make. There is a way how to trace dependencies from headers automatically: http://stackoverflow.com/questions/2394609/makefile-header-dependencies
AMB: every Makefile contains correct dependencies
AMB: Boost is added to build system. Parsing of arguments is performed with boost.
There are two options at the moment: either all units do dump or none of them. The idea is to provide string name to each unit ("bp", "datacache" etc.) and enable their dump from command line. It should be implemented by combination of Log and Config classes.
Currently MIPS ISA is stored in C-style static array. With C++11 we may initialize something like std::list or std::unordered_map during compile-time.
After fixing #73 I get
$ ./perf_sim -b ../tests/samples/factorial.out -n 1300 -d
wb cycle 147:bubble
decode cycle 147:bubble
fetch cycle 147:bubble
execute cycle 147:bubble
memory cycle 147:mflo $t3, $zero, $zero [ $t3 = 0x0]
Executed instructions: 69
wb cycle 148:mflo $t3, $zero, $zero [ $t3 = 0x0]
****************************
Mismatch:
Checker output: mflo $t3, $zero, $zero [ $t3 = 0x1]
PerfSim output: mflo $t3, $zero, $zero [ $t3 = 0x0]
A command line option should select what simulator has to be run
Problem with Factorial program.
To reproduce:
mipt-mips/tests/samples$ make build_all
mipt-mips/perf_sim$./perf_sim ../tests/samples/factorial.out 100 -d
Error message:
Executed instructions: 5
fetch cycle 15: 0x23bdfff4
decode cycle 15: bubble
execute cycle 15: or $t0, $v0, $zero [ $t0 = 0x4]
memory cycle 15: syscall
ERROR: Writing to valid register!
AMB: GoogleTest library is deleted from MIPT-MIPS repository. Manual how to install GoogleTest is uploaded to Wiki.
Currently no testing for Branch Prediction is made. We have to add the trace with huge amount of random branches.
The candidate was a bubble sort, but unfortunately, it is has low sensitivity to branch prediction.
AMB: Trace is implemented and shows sensitivity to BP mode.
You have to introduce DataBypass class which will allow to perform bypassing between different pipe stages. The implementation should be close to scoreboard (producers mark registers as bypassible, consumers check if their registers are bypassible).
AMB: DataBypass class is fully connected to MIPT-MIPS and enabled in testing.
We have testing only for addu, addi, j. All the instructions must be covered.
AMB: Make MIPT-MIPS fully buildable with Windows-Ubuntu. Manual to install required dependencies is published on Wiki.
We have a cache model implemented, but it is not connected to PerfSim.
AMB: Data Cache Unit is implemented and performance studies are made on memory stress trace.
Currently we define CXXFLAGS in each Makefile. The object is to add one Makefile in $TRUNK to keep all the options.
AMB: root Makefile is added, all other Makefiles include it,
Currently deadlocks are not handled, simulator gets into an infinite loop. There should be a very simple handler โ if there are no writebacks in previous 1000 cycles, error message is printed.
There are two options at the moment: either all units do dump or none of them. The idea is to provide string name to each unit ("bp", "datacache" etc.) and enable their dump from command line:
./mipt-mips -units_log bp,datacache,fetch
.
To implement this, Module class (#357) should be coupled with existing Log class, and Valuestd::string object.
The goal is to integrate testing to GitHub, so some unit tests will be run for every pull request.
In MDSP, we used to have Log class which allows to quickly enable or disable logging. We want to port it from MDSP to MIPT-MIPS and remove all std::cout usage.
For the most of cases, execution of several (>10) sll $0, $0, 0x0
instructions means that program is executed incorrectly. We need to have an automized detector of such instructions in FuncSim to stop simulation if such sequence is detected.
Recently PVS-Studio developers provided a free service to use their static analyzer tool. We would like to use in our project.
Information: http://www.viva64.com/ru/b/0457/
AMB: PVS Studio support enabled in MIPT-MIPS. Something is found :-)
AMB: GoogleTest library in MIPT-MIPS is bumped to new version, testing works fine.
MIPS ISA defines LO and HI registers with implicit access by following instructions:
MIPS restricts LO and HI usage to simplify dependency tracking (thus you have to track them as single register)
A computed result written to the HI/LO pair by DIV, DIVU,MULT, or MULTU must be read by MFHI or MFLO before a new result can be written into either HI or LO. If an MTHI instruction is executed following one of these arithmetic instructions, but before an MFLO or MFHI instruction, the contents of LO are UNPREDICTABLE. The following example shows this illegal situation:
MUL r2,r4 # start operation that will eventually write to HI,LO
... # code not containing mfhi or mflo
MTHI r6
... # code not containing mflo
# this mflo would get an UNPREDICTABLE value
MFLO r3
Example to reproduce:
$ ./perf_sim -b ../tests/samples/factorial.out -n 1300 -d
wb cycle 147:bubble
decode cycle 147:bubble
fetch cycle 147:bubble
execute cycle 147:bubble
memory cycle 147:mflo $t3, $zero, $zero [ $t3 = 0x0]
Executed instructions: 69
wb cycle 148:mflo $t3, $zero, $zero [ $t3 = 0x0]
****************************
Mismatch:
Checker output: mflo $t3, $zero, $zero [ $t3 = 0x1]
PerfSim output: mflo $t3, $zero, $zero [ $t3 = 0x0]
I personally prefer to enable as much C++ warnings as it is possible with -Wall -Wextra -Werror
flags. Can someone please enable these flag and fix warnings appeared?
AMB: These flags are enabled in all Makefiles, all builds pass.
We do not test correctness of instruction execution, this functionality has to be implemented.
With BPU enabled, we may re-arrange clocking of stages in natural FDEMW order. After completion, you should provide IPC drift numbers.
The object is to re-write that code using reverse_iterators:
Currently mem_trans.s is designed to test Data Cache Unit, but we might want to test Instruction Cache Unit. So, the new trace should contain non-memory instructions.
We have a cache model implemented, but it is not connected to PerfSim.
AMB: Instruction Cache Unit is implemented and performance studies are made on instruction stress trace.
Checklist
Currently to add a new option one needs to add it to config.h
and config.cpp
. The goal is to initialize any value with single code line.
Currently ElfParser and Disassembler do the same job of printin contents of MIPS binary file. The tools should be merged to one tool which prints both data and disassembled instructions.
Currently uint64
is used to represent address. However, we have to use Addr type instead.
AMB: build manuals for FuncSim and PerfSim are available on Wiki.
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.