cocotb: "Unable set up RisingEdge(c) Trigger" with Cadence IUS/Xcelium and VHDL

Current status: See https://github.com/cocotb/cocotb/issues/1076#issuecomment-1351266296 for a summary of the problem.

Cadence tracks the implementation of the missing functionality as Jira ticket AVSREQ-183427.


When I run examples/dff/tests with

make SIM=ius TOPLEVEL_LANG=vhdl COCOTB_LOG_LEVEL=DEBUG COCOTB_SCHEDULER_DEBUG=1 all

I am getting the following output:

     0.00ns DEBUG    cocotb.regression                         regression.py:555  in generate_tests                  Adding generated test "run_test_001" to module "dff_cocotb"
     0.00ns INFO     cocotb.regression                         regression.py:187  in initialise                      Found test dff_cocotb.run_test_001
     0.00ns INFO     cocotb.regression                         regression.py:321  in execute                         Running test 1/1: run_test_001
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:618  in add                             Adding new coroutine run_test_001
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:695  in schedule                        Scheduling coroutine run_test_001 with outcome Value(None)
     0.00ns INFO     ...test.run_test_001.0x7f4ae5046780       decorators.py:253  in _advance                        Starting test: "run_test_001"
                                                                                                                     Description: Automatically generated test
                                                                                                                     
                                                                                                                     
     0.00ns DEBUG    ...test.run_test_001.0x7f4ae5046780       decorators.py:258  in _advance                        Sending Value(None)
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:701  in schedule                        Coroutine run_test_001 yielded run_test (mode 1)
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:645  in _trigger_from_unstarted_coro    Scheduling nested coroutine: run_test
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:618  in add                             Adding new coroutine run_test
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:695  in schedule                        Scheduling coroutine run_test with outcome Value(None)
     0.00ns DEBUG    cocotb.c                                      handle.py:84   in __init__                        Created
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:618  in add                             Adding new coroutine start
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:695  in schedule                        Scheduling coroutine start with outcome Value(None)
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:695  in schedule                        Scheduling coroutine _do_writes with outcome Value(None)
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:701  in schedule                        Coroutine _do_writes yielded _Event (mode 1)
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:372  in _event_loop                     Trigger fired: _Event
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:434  in _event_loop                     1 pending coroutines for event _Event
                                                                                                                     	_do_writes
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:441  in _event_loop                     Scheduling coroutine _do_writes
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:695  in schedule                        Scheduling coroutine _do_writes with outcome Value(<cocotb.triggers._Event object at 0x7f4ae491f548>)
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:701  in schedule                        Coroutine _do_writes yielded ReadWrite(readwritesync) (mode 1)
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:444  in _event_loop                     Scheduled coroutine _do_writes
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:463  in _event_loop                     All coroutines scheduled, handing control back to simulator
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:701  in schedule                        Coroutine start yielded Timer(2500000.00ps) (mode 1)
     0.00ns DEBUG    cocotb.d                                      handle.py:84   in __init__                        Created
     0.00ns DEBUG    cocotb.q                                      handle.py:84   in __init__                        Created
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:618  in add                             Adding new coroutine _monitor_recv
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:695  in schedule                        Scheduling coroutine _monitor_recv with outcome Value(None)
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:701  in schedule                        Coroutine _monitor_recv yielded RisingEdge(c) (mode 1)
     0.00ns ERROR    cocotb.RisingEdge.0x7f4ae4925c28              result.py:52   in raise_error                     Unable set up RisingEdge(c) Trigger
                                                                                                                     NoneType: None
                                                                                                                     
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:372  in _event_loop                     Trigger fired: NullTrigger()
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:434  in _event_loop                     1 pending coroutines for event NullTrigger()
                                                                                                                     	_monitor_recv
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:441  in _event_loop                     Scheduling coroutine _monitor_recv
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:695  in schedule                        Scheduling coroutine _monitor_recv with outcome Error(TestError('Unable set up RisingEdge(c) Trigger'))
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:714  in schedule                        Coroutine completed: _monitor_recv
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:491  in unschedule                      TestComplete received: TestError
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:754  in finish_test                     finish_test called with TestError('Unable set up RisingEdge(c) Trigger')
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:780  in cleanup                         Killing start
     0.00ns DEBUG    ..tb.coroutine.start.0x7f4ae4924198       decorators.py:182  in kill                            kill() called on coroutine
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:780  in cleanup                         Killing _do_writes
     0.00ns DEBUG    ..routine._do_writes.0x7f4ae4924278       decorators.py:182  in kill                            kill() called on coroutine
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:780  in cleanup                         Killing run_test_001
     0.00ns DEBUG    ...test.run_test_001.0x7f4ae5046780       decorators.py:182  in kill                            kill() called on coroutine
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:444  in _event_loop                     Scheduled coroutine _monitor_recv
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:276  in _check_termination              Test terminating, scheduling Timer
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:463  in _event_loop                     All coroutines scheduled, handing control back to simulator
     0.00ns INFO     cocotb.scoreboard.dff                     scoreboard.py:216  in add_interface                   Created with reorder_depth 0
     0.00ns DEBUG    cocotb.monitor.BitMonitor                   __init__.py:112  in add_callback                    Adding callback of function check_received_transaction to monitor
     0.00ns DEBUG    cocotb.monitor.BitMonitor                   __init__.py:112  in add_callback                    Adding callback of function model to monitor
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:618  in add                             Adding new coroutine _monitor_recv
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:695  in schedule                        Scheduling coroutine _monitor_recv with outcome Value(None)
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:701  in schedule                        Coroutine _monitor_recv yielded RisingEdge(c) (mode 4)
     0.00ns ERROR    cocotb.RisingEdge.0x7f4ae4925c28              result.py:52   in raise_error                     Unable set up RisingEdge(c) Trigger
                                                                                                                     NoneType: None
                                                                                                                     
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:372  in _event_loop                     Trigger fired: NullTrigger()
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:378  in _event_loop                     Ignoring trigger NullTrigger() since we're terminating
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:618  in add                             Adding new coroutine _cr_twiddler
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:695  in schedule                        Scheduling coroutine _cr_twiddler with outcome Value(None)
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:695  in schedule                        Scheduling coroutine _do_writes with outcome Value(None)
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:701  in schedule                        Coroutine _do_writes yielded _Event (mode 4)
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:372  in _event_loop                     Trigger fired: _Event
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:378  in _event_loop                     Ignoring trigger _Event since we're terminating
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:701  in schedule                        Coroutine _cr_twiddler yielded RisingEdge(c) (mode 4)
     0.00ns ERROR    cocotb.RisingEdge.0x7f4ae4925c28              result.py:52   in raise_error                     Unable set up RisingEdge(c) Trigger
                                                                                                                     NoneType: None
                                                                                                                     
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:372  in _event_loop                     Trigger fired: NullTrigger()
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:378  in _event_loop                     Ignoring trigger NullTrigger() since we're terminating
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:701  in schedule                        Coroutine run_test yielded RisingEdge(c) (mode 4)
     0.00ns ERROR    cocotb.RisingEdge.0x7f4ae4925c28              result.py:52   in raise_error                     Unable set up RisingEdge(c) Trigger
                                                                                                                     NoneType: None
                                                                                                                     
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:372  in _event_loop                     Trigger fired: NullTrigger()
     0.00ns DEBUG    cocotb.scheduler                           scheduler.py:378  in _event_loop                     Ignoring trigger NullTrigger() since we're terminating
     1.00ns DEBUG    cocotb.scheduler                           scheduler.py:303  in begin_test                      begin_test called with trigger: Timer(1000.00ps)
     1.00ns DEBUG    cocotb.scheduler                           scheduler.py:319  in begin_test                      Issue test result to regression object
     1.00ns ERROR    cocotb.regression                         regression.py:300  in handle_result                   Test Failed: run_test_001 (result was TestError)
     1.00ns ERROR    cocotb.regression                         regression.py:207  in tear_down                       Failed 1 out of 1 tests (0 skipped)

(I have modified line 695 of scheduler.py to read self.log.debug("Scheduling coroutine {} with outcome {}".format(coroutine.__name__, send_outcome)) here.)

Any hints as to how to approach debugging this?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 32 (19 by maintainers)

Commits related to this issue

Most upvoted comments

We’re encountering this issue when using Xcelium too. Because it supports cross-language compilation, you can write a Verilog shim. This makes cocotb talk to the simulator over VPI which doesn’t encounter similar issues as the VHPI codepath.

Workaround example

Click to expand

The following cocotb test case + hdl files work fine in GHDL but fail with Xcelium:

adder.vhdl:

port
  ( clk : in std_logic
  ; a : in signed(31 downto 0)
  ; b : in signed(31 downto 0)
  ; c : out signed(31 downto 0)
  );
end adder;

architecture Behavioral of adder is
begin
  p_add : process(clk)
  begin
    if rising_edge(clk) then
      c <= a + b;
    end if;
  end process p_add;
end Behavioral;

test.py:

import cocotb

from cocotb.clock import Clock
from cocotb.triggers import RisingEdge

@cocotb.test()
async def simple_test(dut):
    clock = Clock(dut.clk, 50, units='ns')
    cocotb.fork(clock.start())

    dut.a.value = 5
    dut.b.value = 7

    # Wait for simulator to start
    await RisingEdge(dut.clk)

    # Latch a+b
    await RisingEdge(dut.clk)

    # a+b on output
    await RisingEdge(dut.clk)

    assert dut.c.value.integer == 12

Makefile:

SIM ?= ghdl
TOPLEVEL_LANG ?= vhdl
MODULE := test

VHDL_SOURCES = adder.vhdl

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

To work around this, add a Verilog shim:

adder_shim.v:

module adder_shim
  ( input         clk
  , input  [31:0] a
  , input  [31:0] b
  , output [31:0] c
  );

  adder d0 (clk, a, b, c);
endmodule

and change your Makefile such that it uses the shim when compiling with Xcelium:

SIM ?= ghdl
TOPLEVEL_LANG ?= vhdl
MODULE := test

VHDL_SOURCES = adder.vhdl

ifneq ($(filter $(SIM),xcelium),)
    VERILOG_SOURCES = adder_shim.v
    TOPLEVEL_LANG := verilog
    TOPLEVEL := adder_shim
else
    TOPLEVEL_LANG := vhdl
    TOPLEVEL := adder
endif

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