There is a problem with the code generated by verilator that it can not use certain unix constructs,
install verilator:p, rust:p, python-pip:p
do
# Create a root directory to keep all the different parts of the project together. We will refer to this directory as $WORKSPACE from now on.
mdkir test
cd test
export WORKSPACE=$(pwd)
All the following commands will be run from this directory unless otherwise stated.
The FuseSoC standard library already contains a version of SERV, but if we want to make changes to SERV, run the bundled example or use the Zephyr support, it is better to add SERV as a separate library into the workspace
MDU will be available in $WORKSPACE/fusesoc_libraries/mdu
We are now ready to do our first exercises with SERV.
If everything worked, the output should look like
INFO: Preparing ::serv:1.3.0
INFO: Setting up project
INFO: Building simulation model
INFO: Running
After performing all the steps that are mentioned above, the directory structure from the $WORKSPACE should look like this:
.
$WORKSPACE
|
├── build
│ └── ...
├── fusesoc.conf
└── fusesoc_libraries
├── fusesoc_cores
│ └── ...
├── mdu
│ └── ...
└── serv
└── ...
Running pre-built test software
Build and run the single threaded zephyr hello world example with verilator (should be stopped with Ctrl-C):
fusesoc run --target=verilator_tb servant --uart_baudrate=57600 --firmware=$SERV/sw/zephyr_hello.hex
### Expected behavior
You get hello world
### Actual behavior
you get
verilator -f servant_1.3.0.vc
V e r i l a t i o n R e p o r t: Verilator 5.026 2024-06-15 rev UNKNOWN.REV
Verilator: Built from 1.836 MB sources in 28 modules, into 0.437 MB in 21 C++ files needing 0.000 MB
Verilator: Walltime 0.073 s (elab=0.000, cvt=0.016, bld=0.000); cpu 0.000 s on 1 threads; alloced 17.508 MB
make -f Vservant_sim.mk
make[1]: Entering directory '/home/SYSTEM/to/build/servant_1.3.0/verilator_tb'
g++ -I. -MMD -IC:/rtools43/mingw64/share/verilator/include -IC:/rtools43/mingw64/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_TRACE=1 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -faligned-new -fcf-protection=none -Wno-bool-operation -Wno-shadow -Wno-sign-compare
-Wno-tautological-compare -Wno-uninitialized -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable -Os -c -o servant_tb.o src/servant_1.3.0/bench/servant_tb.cpp
In file included from ./Vservant_sim.h:12,
from src/servant_1.3.0/bench/servant_tb.cpp:6:
C:/rtools43/mingw64/share/verilator/include/vltstd/svdpi.h:143:22: warning: 'dllimport' attribute ignored [-Wattributes]
143 | XXTERN typedef void svScope;
| ^~~
C:/rtools43/mingw64/share/verilator/include/vltstd/svdpi.h:146:22: warning: 'dllimport' attribute ignored [-Wattributes]
146 | XXTERN typedef void svOpenArrayHandle;
| ^~~~~
src/servant_1.3.0/bench/servant_tb.cpp: In function 'int main(int, char, char)':
src/servant_1.3.0/bench/servant_tb.cpp:119:58: error: 'S_IRWXU' was not declared in this scope
119 | tf = open("trace.bin", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
| ^~~
src/servant_1.3.0/bench/servant_tb.cpp:137:58: error: 'S_IRWXU' was not declared in this scope
137 | cps_file = open("cps", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
| ^~~
src/servant_1.3.0/bench/servant_tb.cpp:169:9: error: 'dprintf' was not declared in this scope; did you mean 'wprintf'?
169 | dprintf(cps_file,"%d\n", (cur_cycle-last_cycle)/2);
| ^~~
| wprintf
make[1]: [Vservant_sim.mk:61: servant_tb.o] Error 1
make[1]: Leaving directory '/home/SYSTEM/to/build/servant_1.3.0/verilator_tb'
make: [Makefile:11: Vservant_sim] Error 2
ERROR: Failed to build ::servant:1.3.0 : '['make']' exited with an error: 2
### Verification
- [X] I have verified that my MSYS2 is up-to-date before submitting the report (see https://www.msys2.org/docs/updating/)
### Windows Version
MINGW64_NT-10.0-19045
### MINGW environments affected
- [X] MINGW64
- [ ] MINGW32
- [ ] UCRT64
- [ ] CLANG64
- [ ] CLANG32
- [ ] CLANGARM64
### Are you willing to submit a PR?
_No response_
Description / Steps to reproduce the issue
There is a problem with the code generated by verilator that it can not use certain unix constructs,
All the following commands will be run from this directory unless otherwise stated.
Install FuseSoC
pip install fusesoc
Add the FuseSoC standard library
fusesoc library add fusesoc_cores https://github.com/fusesoc/fusesoc-cores
The FuseSoC standard library already contains a version of SERV, but if we want to make changes to SERV, run the bundled example or use the Zephyr support, it is better to add SERV as a separate library into the workspace
fusesoc library add serv https://github.com/olofk/serv
The SERV repo will now be available in $WORKSPACE/fusesoc_libraries/serv. We will refer to that directory as $SERV.
export SERV=$WORKSPACE/fusesoc_libraries/serv
Install the latest version of Verilator
(Optional) To support RISC-V M-extension extension, Multiplication and Division unit (MDU) can be added included into the SERV as a separate library.
fusesoc library add mdu https://github.com/zeeshanrafique23/mdu
MDU will be available in $WORKSPACE/fusesoc_libraries/mdu
We are now ready to do our first exercises with SERV.
If everything worked, the output should look like
INFO: Preparing ::serv:1.3.0
INFO: Setting up project
INFO: Building simulation model
INFO: Running
After performing all the steps that are mentioned above, the directory structure from the $WORKSPACE should look like this:
.
$WORKSPACE
|
├── build
│ └── ...
├── fusesoc.conf
└── fusesoc_libraries
├── fusesoc_cores
│ └── ...
├── mdu
│ └── ...
└── serv
└── ...
Running pre-built test software
Build and run the single threaded zephyr hello world example with verilator (should be stopped with Ctrl-C):
fusesoc run --target=verilator_tb servant --uart_baudrate=57600 --firmware=$SERV/sw/zephyr_hello.hex
verilator -f servant_1.3.0.vc
~~ C:/rtools43/mingw64/share/verilator/include/vltstd/svdpi.h:146:22: warning: 'dllimport' attribute ignored [-Wattributes] 146 | XXTERN typedef void svOpenArrayHandle; | ^~~~~ src/servant_1.3.0/bench/servant_tb.cpp: In function 'int main(int, char, char)': src/servant_1.3.0/bench/servant_tb.cpp:119:58: error: 'S_IRWXU' was not declared in this scope 119 | tf = open("trace.bin", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU); | ^~~ src/servant_1.3.0/bench/servant_tb.cpp:137:58: error: 'S_IRWXU' was not declared in this scope 137 | cps_file = open("cps", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU); | ^~~ src/servant_1.3.0/bench/servant_tb.cpp:169:9: error: 'dprintf' was not declared in this scope; did you mean 'wprintf'? 169 | dprintf(cps_file,"%d\n", (cur_cycle-last_cycle)/2); | ^~~ | wprintf make[1]: [Vservant_sim.mk:61: servant_tb.o] Error 1 make[1]: Leaving directory '/home/SYSTEM/to/build/servant_1.3.0/verilator_tb' make: [Makefile:11: Vservant_sim] Error 2 ERROR: Failed to build ::servant:1.3.0 : '['make']' exited with an error: 2