TDT4255/introduction.org
2022-09-13 08:37:27 +02:00

8.7 KiB

About RISCV-FiveStage

The task in this project is to implement a 5-stage pipelined processor for the RISCV32I instruction set.

This project framework is used for the all of the milestones in the processor design course TDT4255, however you are more than welcome to use this project yourself, or to teach a class. Please reach out if you do!

In this project you will build a 5-stage RISCV32I processor that is able to run real RISC-V programs as long as they only use the 32I instruction subset. Since this is your first time building a processor, starting with a 5-stage design presents a very difficult challenge, which is why this project is split into four parts. In the first two parts the instructions will be interspersed with NOP instructions, four NOPs for every real. This means that you do not need to take into account dependencies and so forth, making things a lot easier for you.

For the last two parts the only difference is that NOP instructions will not be inserted. You can read about this in the ex2 guide, and will not be discussed further here.

In the project skeleton files (Found here) you can see that a lot of code has already been provided, which can make it difficult to get started. Hopefully this document can help clear up at least some of the confusion. The rest of this document gives an overview of the exercise framework and testing. If you want to jump straight to something practical you can start following the exercise guide, however at some point you should read through the rest of this document.

A tour of FiveStage

In order to orient yourself you first need a map, thus a high level overview of the processor you're going to design is showed underneath: Keep in mind that this is just a high level sketch, omitting many details as well entire features (for instance branch logic)

/kaholaz/TDT4255/media/commit/b51417739d81649e695a334b972e2b78344456ac/Images/FiveStage.png

Now that you have an idea of what you're building it is time to take inventory of the files included in the skeleton, and what, if anything should be added.

Tests

In addition to the skeleton files it's useful to take a look at how the tests work. You will not need to alter anything here other than the test manifest, but some of these settings can be quite useful to alter. The main attraction is the test options. By altering the verbosity settings you may change what is output. The settings are:

  • printIfSuccessful Enables logging on tests that succeed. You typically want this turned off, at least for the full test runner.
  • printErrors Enables logging of errors. You obviously want this one on, at least on the single test.
  • printParsedProgram Prints the desugared program. Useful when the test asm contains instructions that needs to be expanded or altered. Unsure what "bnez" means? Turn this setting on and see!
  • printVMtrace Enables printing of the VM trace, showing how the ideal machine executes a test
  • printVMfinal Enables printing of the final VM state, showing how the registers look after completion. Useful if you want to see what a program returns.
  • printMergedTrace Enables printing of a merged trace. With this option enabled you get to see how the VM and your processor executed the program side by side. This setting is extremely helpful to track down where your program goes wrong! This option attempts to synchronize the execution traces as best as it can, however once your processor design derails this becomes impossible, leading to rather nonsensical output. The output should look like this (picture is from exercise 2, without NOP padding)

    /kaholaz/TDT4255/media/commit/b51417739d81649e695a334b972e2b78344456ac/Images/merged.png

    Instructions that were only executed by either VM or Your design is colored red or blue.

    IF YOU ARE COLOR BLIND YOU SHOULD ALTER THE DISPLAY COLORS!

    On some windows terminal emulators there exists a bug that causes colors to not display correctly, giving your terminal a very.. rastafarian look as shown below:

    /kaholaz/TDT4255/media/commit/b51417739d81649e695a334b972e2b78344456ac/Images/rasta.png

  • nopPadded Set this to false when you're ready to enter the big-boy league
  • breakPoints Not implemented. It's there as a teaser, urging you to implement it so I don't have to.