Skip to content

Commit b6969ef

Browse files
committed
doc: Add Windows WSL simulation setup guide
Document the steps required to run the Ibex Verilator simulation on Windows via WSL, including all dependency fixes needed for Ubuntu 24 and GCC 13. Fixes encountered and documented: - Python venv required due to externally-managed env - edalize and packaging must be installed separately - riscv32 symlinks needed for riscv64 toolchain - zicsr extension required for GCC 13 compatibility - srecord needed for vmem file generation - SRAMInitFile requires absolute path Relates to #741
1 parent eede2fb commit b6969ef

1 file changed

Lines changed: 173 additions & 0 deletions

File tree

doc/windows_wsl_simulation.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
Documentation for issue #741:
2+
3+
---
4+
5+
## Running Ibex Simple System Simulation on Windows (via WSL)
6+
7+
This guide documents the steps and fixes required to run the Ibex Verilator simulation on a Windows machine using WSL (Windows Subsystem for Linux).
8+
9+
---
10+
11+
### Prerequisites
12+
13+
- Windows 10/11 with WSL installed
14+
- Ubuntu 24.04 (Noble) inside WSL
15+
16+
---
17+
18+
### Step 1 — Install WSL
19+
20+
Open PowerShell as administrator:
21+
22+
```bash
23+
wsl --install
24+
```
25+
26+
Restart your machine. All following commands run inside WSL.
27+
28+
---
29+
30+
### Step 2 — Install system dependencies
31+
32+
```bash
33+
sudo apt update
34+
sudo apt install python3-venv python3-full verilator srecord \
35+
gcc-riscv64-unknown-elf git make
36+
```
37+
38+
**Why `srecord`?** The build process uses `srec_cat` to convert the compiled binary into a `.vmem` memory file. Without it, the make step silently produces `.elf` and `.bin` but fails at the final conversion step.
39+
40+
**Why `riscv64` not `riscv32`?** Ubuntu 24 only ships `riscv64-unknown-elf-gcc`. It compiles 32-bit RISC-V code fine with the right flags. Create symlinks so the Makefile can find it:
41+
42+
```bash
43+
sudo ln -s /usr/bin/riscv64-unknown-elf-gcc /usr/bin/riscv32-unknown-elf-gcc
44+
sudo ln -s /usr/bin/riscv64-unknown-elf-objcopy /usr/bin/riscv32-unknown-elf-objcopy
45+
sudo ln -s /usr/bin/riscv64-unknown-elf-objdump /usr/bin/riscv32-unknown-elf-objdump
46+
```
47+
48+
---
49+
50+
### Step 3 — Set up Python virtual environment
51+
52+
Ubuntu 24 blocks system-wide pip installs. Use a venv instead:
53+
54+
```bash
55+
python3 -m venv ~/vlsi-env
56+
source ~/vlsi-env/bin/activate
57+
58+
pip install fusesoc edalize packaging
59+
```
60+
61+
To activate automatically on every WSL startup:
62+
63+
```bash
64+
echo "source ~/vlsi-env/bin/activate" >> ~/.bashrc
65+
```
66+
67+
**Packages needed and why:**
68+
- `fusesoc` — build system that orchestrates the simulation flow
69+
- `edalize` — backend EDA tool abstraction layer (not pulled in automatically by fusesoc)
70+
- `packaging` — version checking utility used by `check_tool_requirements.py` (not included by default)
71+
72+
---
73+
74+
### Step 4 — Clone the repo and set up remotes
75+
76+
```bash
77+
# Fork lowRISC/ibex on GitHub first, then:
78+
git clone https://github.com/YOUR_USERNAME/ibex.git
79+
cd ibex
80+
81+
# Keep upstream as a remote to pull future updates
82+
git remote rename origin upstream
83+
git remote add origin https://github.com/YOUR_USERNAME/ibex.git
84+
```
85+
86+
---
87+
88+
### Step 5 — Fix the GCC architecture flag
89+
90+
GCC 13.x (shipped with Ubuntu 24) requires CSR instructions to be explicitly declared via the `zicsr` extension. Without this fix you get errors like:
91+
92+
```
93+
Error: unrecognized opcode `csrw mhpmcounter3h,x0', extension `zicsr' required
94+
```
95+
96+
Edit `examples/sw/simple_system/common/common.mk`:
97+
98+
```bash
99+
nano examples/sw/simple_system/common/common.mk
100+
```
101+
102+
Find this line:
103+
104+
```makefile
105+
ARCH ?= rv32imc
106+
```
107+
108+
Change it to:
109+
110+
```makefile
111+
ARCH ?= rv32imc_zicsr
112+
```
113+
114+
Save with `Ctrl+O` → Enter → `Ctrl+X`.
115+
116+
---
117+
118+
### Step 6 — Build the test program
119+
120+
```bash
121+
make -C examples/sw/simple_system/hello_test
122+
```
123+
124+
Expected output files in `examples/sw/simple_system/hello_test/`:
125+
126+
```
127+
hello_test.bin hello_test.c hello_test.d
128+
hello_test.elf hello_test.o hello_test.vmem Makefile
129+
```
130+
131+
If `hello_test.vmem` is missing, `srecord` was not installed (see Step 2).
132+
133+
---
134+
135+
### Step 7 — Run the simulation
136+
137+
```bash
138+
fusesoc --cores-root=. run --target=sim --tool=verilator \
139+
lowrisc:ibex:ibex_simple_system \
140+
--SRAMInitFile=$(pwd)/examples/sw/simple_system/hello_test/hello_test.vmem
141+
```
142+
143+
**Note:** Use `$(pwd)` for an absolute path — relative paths are silently ignored and the CPU will loop on empty memory printing `Illegal instruction` indefinitely.
144+
145+
**Note:** The flag is `--SRAMInitFile`, not `--ram_init_file`.
146+
147+
---
148+
149+
### Expected successful output
150+
151+
```
152+
Simulation of Ibex
153+
==================
154+
Initializing memory from file 'hello_test.vmem'
155+
Terminating simulation by software request.
156+
Received $finish() from Verilog, shutting down simulation.
157+
158+
Simulation statistics
159+
=====================
160+
Executed cycles: 13274
161+
Wallclock time: 0.125 s
162+
Instructions Retired: 261
163+
```
164+
165+
---
166+
167+
### Known warnings (safe to ignore)
168+
169+
- **`WARNING: This backend is deprecated`** — edalize backend deprecation notice. The simulation still works. Migration to the Flow API is tracked separately.
170+
- **`launch-ros requires setuptools`** — unrelated ROS package conflict, does not affect ibex.
171+
172+
---
173+

0 commit comments

Comments
 (0)