The primary objective of this project is to design and implement a RISC-V Simulator capable of running the given RISC-V assembly instructions using a C++ program with Cache options.
- Overview
- Instructions
- Project Expandability
- Installation
- Project Structure
- File Descriptions
- Features
The project is designed to implement a RISC-V simulator which is capable of running the RISC-V assembly instructions using C++ program with Command line interface.This supports only a subset of instructions i.e only R, I, S, B, U and J type instructions not any pseudo instructions.The simulator is enhanced with the cache simulation which supports 3 types of replacement policies(FIFO,LRU,RANDOM) and two write policies(WB with no allocate and WT with allocate)
- The application is space sencitive. So bad spaces will cause the application to give error.
- If any comment is present after a instrection there shoud be atleast one space between instructon and comment.
- Project can handle upto 4096 lines excluding comments.
- If needed more instructions can be added to the
risc_v.hfile. - New Instruction type can be added by making a function in
instruction.h. - The maximum line of input file can be increased by just changing the 4096 in
data.handdata.cpp. - The application can be made to support for pseudo-instructions by adding a new function in
instruction.h - The project can be made to support for more than one file by making a loop in
main.cpp. - We can improve the application by adding a GUI to it.
Make can be used to install the application into your personal repo or folder:
make allMake all will compile the files and give you a riscv_asm.exe file which can be run using:
./riscv_sim.exeSpecific .o files can be compiled by the following commands:
make data.o
make encorder.o
make instruction.o
make main.o
make lineRunner.o
make parser.o
make utils.o
make cpu.o
make memory.o
make executor.oThen clean can be used to clean all the files:
make cleanThe project is organized as follows:
├─ src
│ ├── cpu.cpp
│ ├── data.cpp
│ ├── encoder.cpp
│ ├── executor.cpp
│ ├── instruction.cpp
│ ├── lineRunner.cpp
│ ├── main.cpp
│ ├── memory.cpp
│ ├── parser.cpp
│ └── utils.cpp
├── include
│ ├── cpu.h
│ ├── data.h
│ ├── encoder.h
│ ├── executor.h
│ ├── instruction.h
│ ├── lineRunner.h
│ ├── memory.h
│ ├── parser.h
│ ├── risc-v.h
│ └── utils.h
├── Makefile
├── README.md
└── report.pdf
-
src/: Contains all the source code files.
encoder.cpp: conatains the implementation of encoding functionalities of the instruction.instruction.cpp: Contains Implementation of instruction functionalities.parser.cpp: Implementation of parsing functionalities.utils.cppImplementation of common utility functions.lineRunner.cppIt contains all the functions for each instructiondata.cpp: Contains the strings and maps to store the data of the instructions.cpu.cpp: Implements the functionalities of register store and register load.memory.cpp: Implements the memory opertions on both the cache memory and main memory.executor.cpp: Contains the implementation details required for execution of the decoded instructions.main.cpp: The entry point of the application.
-
include/: Contains all the Header files for the above source code files used in the project and an additional risc-v.h file.
risc-v.h: Contains the information about registers and instruction ,their corresponding opcode,funct values.
-
Makefile: Configuration file for Make to build the project..
-
Report: Contains the brief description each file and functions in them.Example usage of the project and the output of the project.