raysalemi / Python4RTLVerification

MIT License
117 stars 27 forks source link

Got error upon running the example 22_Simulating_with_cocotb with modelsim #13

Open mu-aslam opened 1 year ago

mu-aslam commented 1 year ago

I tried to compile the example 22_Simulating_with_cocotb using "make SIM=modelsim". However it gives following error `Loading sv_std.std

# Loading sim_build/work.counter
# Loading ~/Desktop/miniconda3/envs/py3_32/lib/python3.7/site-packages/cocotb/libs/libcocotbvpi_modelsim.so
#      -.--ns INFO     gpi                                ..mbed/gpi_embed.cpp:76   in set_program_name_in_venv        Did not detect Python virtual environment. Using system-wide Python interpreter
#      -.--ns INFO     gpi                                ../gpi/GpiCommon.cpp:101  in gpi_print_registered_impl       VPI registered
#      0.00ns INFO     cocotb                             Running on ModelSim - Intel FPGA Edition version 2020.1 2020.02
#      0.00ns INFO     cocotb                             Running tests with cocotb v1.8.0 from ~/Desktop/miniconda3/envs/py3_32/lib/python3.7/site-packages/cocotb
#      0.00ns INFO     cocotb                             Seeding Python random module with 1691150502
#      0.00ns INFO     cocotb.regression                  pytest not found, install it to enable better AssertionError messages
#      0.00ns INFO     cocotb.regression                  Found test testbench.no_count
#      0.00ns INFO     cocotb.regression                  Found test testbench.three_count
#      0.00ns INFO     cocotb.regression                  Found test testbench.oops
#      0.00ns INFO     cocotb.regression                  running no_count (1/3)
#                                                           Test no count if reset is 0
#      8.00ns WARNING  gpi                                VPI: Not able to map type vpiByteVar(614) to object.
#      9.00ns INFO     cocotb.regression                  no_count failed
#                                                         Traceback (most recent call last):
#                                                           File "~Desktop/st_engineering/learning/cocotb/Python4RTLVerification-master/22_Simulating_with_cocotb/testbench.py", line 23, in no_count
#                                                             count = get_int(dut.count.value)
#                                                           File "~/Desktop/miniconda3/envs/py3_32/lib/python3.7/site-packages/cocotb/handle.py", line 370, in __getattr__
#                                                             raise AttributeError(f"{self._name} contains no object named {name}")
#                                                         AttributeError: counter contains no object named count
#      9.00ns INFO     cocotb.regression                  running three_count (2/3)
#                                                           Test that we count up as expected
#     17.00ns INFO     cocotb.regression                  three_count failed
#                                                         Traceback (most recent call last):
#                                                           File "~/Desktop/st_engineering/learning/cocotb/Python4RTLVerification-master/22_Simulating_with_cocotb/testbench.py", line 38, in three_count
#                                                             count = get_int(dut.count)
#                                                           File "~/Desktop/miniconda3/envs/py3_32/lib/python3.7/site-packages/cocotb/handle.py", line 370, in __getattr__
#                                                             raise AttributeError(f"{self._name} contains no object named {name}")
#                                                         AttributeError: counter contains no object named count
#     17.00ns INFO     cocotb.regression                  running oops (3/3)
#                                                           Demonstrate a coroutine mistake
#     17.00ns INFO     root                               Did not await
#     18.00ns INFO     cocotb.regression                  oops passed
#     18.00ns INFO     cocotb.regression                  **************************************************************************************
#                                                         ** TEST                          STATUS  SIM TIME (ns)  REAL TIME (s)  RATIO (ns/s) **
#                                                         **************************************************************************************
#                                                         ** testbench.no_count             FAIL           9.00           0.01        602.87  **
#                                                         ** testbench.three_count          FAIL           8.00           0.00       8154.18  **
#                                                         ** testbench.oops                 PASS           1.00           0.00       4419.71  **
#                                                         **************************************************************************************
#                                                         ** TESTS=3 PASS=1 FAIL=2 SKIP=0                 18.00           0.03        553.00  **
#                                                         **************************************************************************************
#                                                         
# ** Note: $finish
#    Time: 18 ns  Iteration: 0  Instance: /counter
# End time: 14:01:42 on Aug 04,2023, Elapsed time: 0:00:01
# Errors: 0, Warnings: 0
make[1]: Leaving directory ~/Desktop/st_engineering/learning/cocotb/Python4RTLVerification-master/22_Simulating_with_cocotb'

-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! `

However when I changed the output logic [3:0] count) the data type. The example passed without any error

#     18.00ns INFO     cocotb.regression                  **************************************************************************************
#                                                         ** TEST                          STATUS  SIM TIME (ns)  REAL TIME (s)  RATIO (ns/s) **
#                                                         **************************************************************************************
#                                                         ** testbench.no_count             PASS           9.00           0.01        607.93  **
#                                                         ** testbench.three_count          PASS           8.00           0.00      12576.62  **
#                                                         ** testbench.oops                 PASS           1.00           0.00       7913.78  **
#                                                         **************************************************************************************
#                                                         ** TESTS=3 PASS=3 FAIL=0 SKIP=0                 18.00           0.03        646.87  **

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Is this cocotb limitation that it does not support specific data type? Do we need to have a specific requirement to run these example with modelsim? Or is it compiler limiaton as I dont see error with default simulator?

raysalemi commented 1 year ago

I wonder if modelsim needs the -sv option to process SystemVerilog two-value variables.

mu-aslam commented 1 year ago

Sorry I did not get you, do I need to change the Makefle as everything including sv files are there?

raysalemi commented 1 year ago

Sorry I did not get you, do I need to change the Makefle as everything including sv files are there?

I would change the options to ModelSim to include -sv on the command line.