question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error accessing top level port of VHDL DUT trying adder example using GHDL

See original GitHub issue

When trying the VHDL adder example with GHDL, each tests fails when the first access to a top level port occurs.

TMs-Air:tests torsten$ make SIM=ghdl TOPLEVEL_LANG=vhdl 
/Applications/Xcode.app/Contents/Developer/usr/bin/make results.xml
cd sim_build && /usr/local/bin/ghdl -a /Users/torsten/Projects/Git/cocotb/examples/adder/tests/../hdl/adder.vhdl && /usr/local/bin/ghdl -e adder
cd sim_build; \
    PYTHONPATH=/Users/torsten/Projects/Git/cocotb/build/libs/x86_64:/Users/torsten/Projects/Git/cocotb:/Users/torsten/Projects/Git/cocotb/examples/adder/tests:/Users/torsten/Projects/Git/cocotb/examples/adder/tests/../model: LD_LIBRARY_PATH=/Users/torsten/Projects/Git/cocotb/build/libs/x86_64::/System/Library/Frameworks/Python.framework/Versions/2.7/lib:/System/Library/Frameworks/Python.framework/Versions/2.7/lib:/System/Library/Frameworks/Python.framework/Versions/2.7/lib:/System/Library/Frameworks/Python.framework/Versions/2.7/lib MODULE=test_adder \
        TESTCASE= TOPLEVEL=adder TOPLEVEL_LANG=vhdl \
    /usr/local/bin/ghdl -r adder --vpi=/Users/torsten/Projects/Git/cocotb/build/libs/x86_64/libvpi.so
loading VPI module '/Users/torsten/Projects/Git/cocotb/build/libs/x86_64/libvpi.so'
     -.--ns INFO     cocotb.gpi                                GpiCommon.cpp:91   in gpi_print_registered_impl       VPI registered
VPI module loaded!
  0.00ns INFO     cocotb.gpi                                  gpi_embed.c:248  in embed_sim_init                  Running on GHDL version 0.1
  0.00ns INFO     cocotb.gpi                                  gpi_embed.c:249  in embed_sim_init                  Python interpreter initialised and cocotb loaded!
  0.00ns INFO     cocotb                                      __init__.py:115  in _initialise_testbench           Running tests with Cocotb v1.0 from /Users/torsten/Projects/Git/cocotb
  0.00ns INFO     cocotb                                      __init__.py:131  in _initialise_testbench           Seeding Python random module with 1466546523
  0.00ns INFO     cocotb.regression                         regression.py:161  in initialise                      Found test test_adder.adder_basic_test
  0.00ns INFO     cocotb.regression                         regression.py:161  in initialise                      Found test test_adder.adder_randomised_test
  0.00ns INFO     cocotb.regression                         regression.py:262  in execute                         Running test 1/2: adder_basic_test
  0.00ns INFO     ..tine.adder_basic_test.0x101bc7a90       decorators.py:189  in send                            Starting test: "adder_basic_test"
                                                                                                                            Description: Test for 5 + 10
  2.00ns ERROR    ..tine.adder_basic_test.0x101bc7a90           result.py:51   in raise_error                     Send raised exception: adder contains no object named A
                                                                                                                              File "/Users/torsten/Projects/Git/cocotb/cocotb/decorators.py", line 194, in send
                                                                                                                                return self._coro.send(value)
                                                                                                                              File "/Users/torsten/Projects/Git/cocotb/examples/adder/tests/test_adder.py", line 16, in adder_basic_test
                                                                                                                                dut.A = A
                                                                                                                              File "/Users/torsten/Projects/Git/cocotb/cocotb/handle.py", line 239, in __setattr__
                                                                                                                                return getattr(self, name)._setcachedvalue(value)
                                                                                                                              File "/Users/torsten/Projects/Git/cocotb/cocotb/handle.py", line 261, in __getattr__
                                                                                                                                raise AttributeError("%s contains no object named %s" % (self._name, name))

  3.00ns ERROR    cocotb.regression                         regression.py:246  in handle_result                   Test Failed: adder_basic_test (result was TestError)
  3.00ns INFO     cocotb.regression                         regression.py:262  in execute                         Running test 2/2: adder_randomised_test
  3.00ns INFO     ..adder_randomised_test.0x101bc7e90       decorators.py:189  in send                            Starting test: "adder_randomised_test"
                                                                                                                            Description: Test for adding 2 random numbers multiple times
  5.00ns ERROR    ..adder_randomised_test.0x101bc7e90           result.py:51   in raise_error                     Send raised exception: Attempt to access A which isn't present in adder
                                                                                                                              File "/Users/torsten/Projects/Git/cocotb/cocotb/decorators.py", line 194, in send
                                                                                                                                return self._coro.send(value)
                                                                                                                              File "/Users/torsten/Projects/Git/cocotb/examples/adder/tests/test_adder.py", line 37, in adder_randomised_test
                                                                                                                                dut.A = A
                                                                                                                              File "/Users/torsten/Projects/Git/cocotb/cocotb/handle.py", line 243, in __setattr__
                                                                                                                                name, self._name))

  6.00ns ERROR    cocotb.regression                         regression.py:246  in handle_result                   Test Failed: adder_randomised_test (result was TestError)
  6.00ns ERROR    cocotb.regression                         regression.py:167  in tear_down                       Failed 2 out of 2 tests (0 skipped)
  6.00ns INFO     cocotb.regression                         regression.py:176  in tear_down                       Shutting down...

Running the example with icarus verilog works as expected. Maybe this is an GHDL specific error? The endian_swapper example works with both, icarus and GHDL.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tgingoldcommented, Jun 22, 2016

Yes, using a case insensitive string compare fixes the issue.

0reactions
tmeissnercommented, Jun 25, 2016

I think we can close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cocotb/Lobby - Gitter
Hello, I was able to run the simple examples of adder and dff; The endian_swapper looks like a good test harness that has...
Read more >
cocotb Documentation - Read the Docs
When cocotb initialises it finds the top-level instantiation in the simulator and creates a handle called dut. Top-level signals can be accessed ......
Read more >
A full adder - GHDL guide
This example starts with a full adder described in the adder.vhdl file: ... port (i0, i1 : in bit; ci : in bit;...
Read more >
v1.3.1 PDF - cocotb's documentation!
toplevel in the simulator without any wrapper code. cocotb drives ... """Try accessing the design.""" dut._log.info("Running test!").
Read more >
VHDL Testbench Design
entity adder_bench is -- no top-level I/O ports ... component adder is -- declare the adder component port (. X,Y: in ... Simple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found