This repository is for ECE201/401
Before starting, ensure you have:
- Linux system (If not, follow the instruction in assignment page)
- Internet connection
- Terminal/Command Prompt access
- Update package index:
sudo apt-get update
- Install Docker Engine:
sudo apt-get install docker-ce docker-ce-cli containerd.io
- Verify installation:
sudo docker --version
docker pull qhou3/riscv-micro-sim
docker run -it qhou3/riscv-micro-sim
To mount a local directory (recommended for persistent work):
docker run -it -v /path/to/local/directory:/work qhou3/riscv-micro-sim
Make sure you are under /marss-riscv/src
directory
- In-order processor
./marss-riscv -ctrlc -rw ../configs/riscv64_inorder_soc.cfg
- Out-of-order processor
./marss-riscv -ctrlc -rw ../configs/riscv64_outoforder_soc.cfg
- Once in RISC-V environment, set up: (should be automatically done, manully just in case)
export PYTHONPATH=/usr/lib64/python2.7/site-packages/ env-update
- Create a simple C program (example.c, If you don't know how to create a file via the command line, refer to File Creation Guide):
#include <stdio.h> int main() { asm("csrs 0x800,zero"); // SIM_START printf("Hello RISC-V World\n"); asm("csrs 0x801,zero"); // SIM_STOP return 0; }
- Compile the program:
gcc -o example example.c
- Run the program:
The output should be:
./example
as well as performance information.Hello RISC-V World!
-
Press
ctrl+c
to exit the simulator -
Go to
/marss-riscv/configs
directory -
Edit the following config files as you wish:
Either
configs/riscv64_inorder_soc.cfg
(View In-Order Configuration File)
or
configs/riscv64_outoforder_soc.cfg
- Docker permission denied
sudo usermod -aG docker $USER newgrp docker
- Container not starting
- Ensure Docker service is running:
sudo systemctl start docker
- Image pull failed
- Check internet connection
- Try with sudo if on Linux
If you don't know how to create a file using the command line, you can use one of the following methods:
cat > example.c << 'EOF'
copy and paste code
EOF
vim example.c
Press i
to enter insert mode, paste the code, press Esc
, then type :wq
and press Enter
to save and exit.