Coder Social home page Coder Social logo

mipt-ilab / mipt-mips Goto Github PK

View Code? Open in Web Editor NEW
330.0 23.0 142.0 115.88 MB

Cycle-accurate pre-silicon simulator of RISC-V and MIPS CPUs

Home Page: http://mipt-ilab.github.io/mipt-mips/

License: MIT License

C++ 97.46% CMake 1.27% C 0.14% GDB 0.02% Makefile 0.14% Assembly 0.97%
mips cpu cpu-cache clock-precise branch-prediction branch-predictor computer-architecture-lesson computer-architecture pre-silicon mips-binutils

mipt-mips's People

Contributors

agrachiv avatar alex19999 avatar alexander-titov avatar alexseppar avatar andreizoltan avatar beanefit avatar bova-ev avatar dandyforever avatar davtyan-arsen avatar denislos avatar dependabot[bot] avatar exucutional avatar gkorepanov avatar graudtv avatar igorsmir-ilab avatar inedostoev avatar ivan23kor avatar kiraproger avatar kkorolev avatar kkorolev-intel avatar kurapov-peter avatar olegladin avatar pavelkryukov avatar pooh64 avatar soshink avatar timofeevalex avatar trexxet avatar viktor-prutyanov avatar vodogrey2012 avatar yanlogovskiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mipt-mips's Issues

Implement data bypassing

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.

Move all unit tests to single file

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.

Support Windows-Ubuntu build

AMB: Make MIPT-MIPS fully buildable with Windows-Ubuntu. Manual to install required dependencies is published on Wiki.

Introduce new types for cycles and latencies

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.

Create option to select dumping units

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.

Fix factorial trace (Funcsim)

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.

Build fails for some files

In func_instr:

$ 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]))
                                               ^

In perf_sim:

 $ 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;
              ^~~~

Generate and test MS Visual Studio solution & project files with CMake

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

  1. I have to use patched LibELF build as original source contains a small bug
  2. MIPS binutils are built only by MinGW โ€” it is OK as we use only binaries

Besides, everything is OK to create *.sln and *.vcxproj files (NMake is very, very bad)

Merge ElfParser and Disassembler

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.

Create option to select dumping units

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.

Add deadlock detector

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.

Enable very strict C++ warning rules

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.

Enhance register file with LO and HI registers

MIPS ISA defines LO and HI registers with implicit access by following instructions:

  • mult
  • multu
  • div
  • divu
  • mfhi
  • mthi
  • mflo
  • mtlo

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]

Compare PerfSim and FuncSim internally

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.

Create a trace to test BP (not a bubble sort)

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.

Factorial trace (func_sim and perf_sim mismatch)

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]

Add wrong code detector in functional simulator

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.

Fix factorial.out

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!

Add self-modifying code stress test trace

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.