YosysHQ / oss-cad-suite-build

Multi-platform nightly builds of open source digital design and verification tools
ISC License
774 stars 70 forks source link

Add cocotb #34

Closed mcejp closed 2 years ago

mcejp commented 2 years ago

cocotb is a COroutine based COsimulation TestBench environment for verifying VHDL and SystemVerilog RTL using Python.

The reason why this needs to be included in the suite when it's "just a Python package" is that it builds a native component that, AFAIU, gets loaded into the simulator (e.g., iverilog) process. It cannot be installed by the user using the suite's pip, since the latter is not able to compile C/C++, and when built with the OS' native pip & GCC, there is a runtime conflict of libc[++] versions between the library and the simulator.

I have been able to build Cocotb with this patch, however testing it out is a bit trickier, since I suppose it requires building a substantial portion of the suite from source, which takes many hours on a slower CPU. (I haven't been able to use the CI in a fork)

mmicko commented 2 years ago

Thanks @mcejp. Was able to build this on linux-* platforms, but it fails on darwin and windows. First checking what I could do about that, later we can check if there are some other parts needed to make it work.

mmicko commented 2 years ago

I have done change in script so it install package from source (since I need to patch it to be able to cross compile for darwin-x64) . Also added pytest package among installed making it usable directly. Have tried running examples from cocotb github repo and now they are passing. Build is already updated (at least for linux-x64 as I write this) so you can download package and test more.

mmicko commented 2 years ago

iverilog works fine, but verilator seem bit more tricky

mmicko commented 2 years ago

Managed to fix a problem, but still it hangs when using make SIM=verilator I have tried to do local verilator and cocotb installation and got same issue. So if you have experience with some working using cocotb and verilator please point it to me.

mmicko commented 2 years ago

Well this explains Currently cocotb only supports Verilator 4.106 (no earlier or later version).

https://docs.cocotb.org/en/stable/simulator_support.html

mcejp commented 2 years ago

Incredible, thank you! I confirm that it works for me on the latest release.

And you make a good point that I should have thought to test at least building for the other platforms... sorry.