msys2 / MINGW-packages

Package scripts for MinGW-w64 targets to build under MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
2.24k stars 1.2k forks source link

verilator generated code is unix based not for windows #21385

Closed Kreijstal closed 1 month ago

Kreijstal commented 1 month ago

Description / Steps to reproduce the issue

There is a problem with the code generated by verilator that it can not use certain unix constructs,

  1. install verilator:p, rust:p, python-pip:p
  2. 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.

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


### Expected behavior

You get hello world

### Actual behavior

you get 

verilator -f servant_1.3.0.vc



### 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_
Kreijstal commented 1 month ago

I made a mistake, the testbench itself is the one that makes such assumptions, not verilator