tpoikela / uvm-python

UVM 1.2 port to Python
Apache License 2.0
235 stars 45 forks source link

Using uvm-python for with custom build infrastructure #46

Closed sbhutada closed 9 months ago

sbhutada commented 9 months ago

I am trying to integrate cocotb inside larger build infrastructure. What is the best way to do this? I thought venv might work. Any suggestions? Thanks.

Creating a venv and install UVM-Python package:

python3.10 -m venv …/uvmpy/venv
cd …/uvmpy
git clone https://github.com/tpoikela/uvm-python.git
cd uvm-python
python -m pip install .

I see cocotb-config under ../venv/bin

I run this command in a new terminal and different directory:

source .../uvmpy/venv/bin/activate.csh

which cocotb-config
…/uvmpy/venv/bin/cocotb-config

Then run an example and I get this error:

cp -rf …/uvmpy/uvm-python/test/examples .
cd examples/minimal

(Update Makefile: ../../.. in PYTHONPATH changed to the location of …/uvmpy/uvm-python)

make sim
Traceback (most recent call last):
  File “…/uvmpy/venv/bin/cocotb-config", line 5, in <module>
    from cocotb.config import main
  File "…/uvmpy/venv/lib/python3.10/site-packages/cocotb/__init__.py", line 43, in <module>
    import cocotb.handle
  File "…/uvmpy/venv/lib/python3.10/site-packages/cocotb/handle.py", line 39, in <module>
    from cocotb import simulator
ImportError: cannot import name 'simulator' from partially initialized module 'cocotb' (most likely due to a circular import) (…/uvmpy/venv/lib/python3.10/site-packages/cocotb/__init__.py)

I also sometimes see cocotb-config not found. Is there a way to use cocotb Makefiles without coco-tb-config?

sbhutada commented 9 months ago

I used 3.12 and it seems to work.

I just need to know how to avoid using cocotb-config - or how to integrate this in larger build infrastructure.

Thanks.

tpoikela commented 9 months ago

You should be able to run cocotb-config --makefiles from command line or shell. If it does not work, there's something wrong with your setup. So the Makefiles from uvm-python should work as they are, unmodified.

At the end of Makefile in test/examples/minimal, you can find:

include $(shell cocotb-config --makefiles)/Makefile.sim

You can replace the $(...) part with the actual path to Makefile.sim. You can find this path either by running cocotb-config --makefiles or find -name Makefile.sim from the shell.

Let me know if you still have questions or problems.

tpoikela commented 9 months ago

Please also check https://docs.cocotb.org/en/stable/install.html for instructions. They also mention there:

After installation, you should be able to execute cocotb-config. If it is not found, you need to append its location to the PATH environment variable. This may happen when you use the --user option to pip, in which case the location is documented here.

uvm-python has cocotb as a dependency, so cocotb should be installed properly after installing uvm-python. Please check the output from python -m pip install . to see that cocotb was installed correctly.

sbhutada commented 9 months ago

Thanks. Fixed the issue with miniconda.