Closed marcorogo13 closed 1 month ago
In theory this should just work by setting tool : verilator
instead of tool : icarus
in the core description file, or by providing --tool=verilator
on the command-line. I just tried this myself however, and I'm getting some errors like undefined reference to
Py_IsInitialized'` so I suspect that either my environment isn't set up correctly to test this or that we need to do something more when we call Verilator.
As for me an exception was popping out from edalize not recognizing verilator as possible tool in this case, as soon as I get back to work on it I can you some details more
Here is the problem:
INFO: Preparing cocotb:tb:cve2_core:1.0.0
Traceback (most recent call last):
File "//.local/bin/fusesoc", line 33, in <module>
sys.exit(load_entry_point('fusesoc==2.3', 'console_scripts', 'fusesoc')())
File "//.local/lib/python3.9/site-packages/fusesoc/main.py", line 672, in main
fusesoc(args)
File "//.local/lib/python3.9/site-packages/fusesoc/main.py", line 662, in fusesoc
args.func(fs, args)
File "//.local/lib/python3.9/site-packages/fusesoc/main.py", line 316, in run
edam_file, backend = fs.get_backend(core, flags, args.backendargs)
File "//.local/lib/python3.9/site-packages/fusesoc/fusesoc.py", line 170, in get_backend
return edam_file, backend_class(
File "//.local/lib/python3.9/site-packages/edalize/flows/edaflow.py", line 291, in __init__
self.configure_tools(self.flow)
File "//.local/lib/python3.9/site-packages/edalize/flows/sim.py", line 41, in configure_tools
(opt, val) = cocotb_options[tool]
KeyError: 'verilator'
As I was saying in the sim.py there is no entry for verilator, should I look into the edalize part of it or is there a quicker way to somehow make it work? Thanks again
and the core file used, nothing changed other than the tool ` CAPI=2:
name: cocotb:tb:cve2_core:1.0.0
filesets: rtl: files:
../test.sv file_type: systemVerilogSource
cocotb: files:
targets: default: &default filesets:
Aha! I noticed now that the verilator cocotb support isn't in the released version. It was added just after the last release. You could try switching to the development version if you like. The easiest way (that I know) is to clone Edalize and install it from the repo by running:
git clone https://github.com/olofk/edalize
cd edalize
pip install --user -e .
ahh now is running at least, then is giving a ' undefined reference to `Py_IsInitialized' ' but that could very well be a issue of mine in setting up the environment. Thanks again!
I have been looking at this a bit more but not getting any wiser unfortunately. If I force -lpython3.11
into LDFLAGS, I can make it compile but that is clearly a hack. Also, even if it compiles it gets stuck at time zero when I'm waiting for a clock edge. Trying to see if the cocotb devs have some more ideas here https://app.gitter.im/#/room/#cocotb_Lobby:gitter.im
Yes, I got to the same point adding manually to the g++ flags -lpython3.11 when compiling in the build folder, doing that for a simple dummy test I was trying to run it seemed to work. Now I was trying to figure out where to actually add the flag to have it added automatically
Ok, good to know that you could run the test. I failed to do that on my side. Could you try if the example in this repo works too? (I had to change toplevel to toplevel : axis_send_packet
and change to reg [31:0] cnt;
to make it stop complaining).
I have a preliminary solution now. The cocotb libraries are supposed to be loaded at runtime, but the linker checks the symbols at compile-time. Adding -Wl,--unresolved-symbols=ignore-all
to the end of LDFLAGS here seems to do the trick. Would be great if you could test that.
Ok, good to know that you could run the test. I failed to do that on my side. Could you try if the example in this repo works too? (I had to change toplevel to
toplevel : axis_send_packet
and change toreg [31:0] cnt;
to make it stop complaining).
Ok so after doing the same changes you did and trying with verilator i got to the same point (having to add the missing LDFLAG) after that the simulation started resulting in time advancing , only problem is that for some reason fusesoc did not find the tb_utils so then i got this
expected = cocotb.top.MSG_STR.value.decode('ascii')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'decode'
510.00ns INFO cocotb.regression *********************************************************************************************
** TEST STATUS SIM TIME (ns) REAL TIME (s) RATIO (ns/s) **
*********************************************************************************************
** test_axis_send_packet.test_busy_cfg FAIL 510.00 0.00 107795.77 **
*********************************************************************************************
** TESTS=1 PASS=0 FAIL=1 SKIP=0 510.00 0.01 64730.96 **
*********************************************************************************************
I guess this is because i removed the tb_utils from the required filesets.
I have a preliminary solution now. The cocotb libraries are supposed to be loaded at runtime, but the linker checks the symbols at compile-time. Adding
-Wl,--unresolved-symbols=ignore-all
to the end of LDFLAGS here seems to do the trick. Would be great if you could test that.
Ok I tried this with my testbench and looks like it is working! Thanks again for the support
Thanks for checking. I filed this bug for cocotb. If I don't get any comments I will add the LDFLAGS addition permanently.
The other problem of time not advancing is likely something about Verilator on my side since you could confirm time advances when you run it on your side.
Keeping this issue open for now until the LDFLAGS addition has gone into the code base.
This works with Verilator now, so closing.
Is there any way to generalize this flow including verilator as a simulator? thanks in advance!