This is work done as part of the B.Tech project at IIT Madras. The aim of the project is to explore resource-performance tradeoffs in existing hardware compilers. This repo contains Scala source code for a 5-stage RISC-V processor which comes in two variants: single-cycle and pipelined. Simulation code has also been added for Verilator.
If you are new to this (like we were), here's a lightning-quick primer on all you need to know to use this:
-
Chisel3
Chisel3 is a hardware construction language embedded within the Scala programming language. It is being developed by UCB-BAR and is used mainly to design hardware generators.- Basic knowledge of Scala syntax can be found on the Scala website, specifically the Tour of Scala (it will be needed since Chisel3 is essentially a Scala library specialized for hardware construction - no need to go too much into detail, you can learn as you go)
- Install and learn SBT - the Scala build tool, used to compile, run and test your Scala/Chisel3 project - by going through the sbt by example tutorial on the SBT website
- You can learn how to use Chisel3 by:
- going through the bootcamp
- dissecting the template project
- referring to the Chisel3 cheatsheet (open
main.tex
and download the PDF) and the Chisel3 API
- Once you are comfortable with the basics, you can clone the Chisel3 repo to start working on your projects locally
- Simple install - clone above repo,
cd
into directory and entersbt 'publishLocal'
in terminal - In order to use Chisel3 locally, you will have to add it as a dependency in the
build.sbt
script of your project. Refer to thebuild.sbt
of the template project (mentioned above) to see how they do it
-
Instruction Set Architecture of CPU
- RV32I ISA is used in this project
- Refer to the riscv-spec.pdf document found here in the ISA Specification section
- Here's a convenient reference for dataflow of the instructions
-
Using this project
- All modules used can be found at
src/main/scala
- To generate HDL for single-cycle and pipelined processors, first compile the project using
sbt 'compile'
, and then runsbt 'runMain mycpu.SCCPU_Driver'
andsbt 'runMain mycpu.PCPU_Driver'
respectively
- All modules used can be found at
-
Verifying functionaliy using simulation
- Simulation can be carried out using tools in the
sim
directory - As of now, Verilator is used to perform simulation
- The
README
file in the respective directories explain more about the tools and their usage
- Simulation can be carried out using tools in the
More details will be added as we will continue our work on building the testing apparatus. We also plan to look into the RocketChip in-order core and see what changes we can make to the current design.