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.

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

See original GitHub issue

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?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
martijnbastiaancommented, Jul 15, 2021

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
0reactions
imphilcommented, Dec 14, 2022

To add a bit more context here for people coming to this bug:

  • User-visible problem: cocotb users with VHDL toplevel designs cannot use RisingEdge() triggers in Xcelium and IUS.
  • Workaround: Use a Verilog toplevel.
  • Summary of the underlying issue: Cadence Xcelium and IUS do not support a VHPI feature cocotb relies on to implement RisingEdge triggers.

Steps to reproduce the issue

$ git clone https://github.com/cocotb/cocotb.git
$ python3 -m venv cocotb-venv
$ cd cocotb-venv
$ . bin/activate
$ pip3 install cocotb==1.7.2 pytest
$ make -C ../cocotb/examples/simple_dff SIM=xcelium TOPLEVEL_LANG=vhdl COCOTB_LOG_LEVEL=DEBUG COCOTB_SCHEDULER_DEBUG=1 all

The output will include the following lines:

     0.00ns ERROR    gpi                                VHPI: Registered callback isn't enabled! Got vhpiStateP=vhpiUndefined(1000)
     0.00ns ERROR    gpi                                Failed to register a value change callback

where Xcelium indicates that it does not support the vhpiStateP property of vhpi_get().

Analysis

The calling code in question is vhpi_get(vhpiStateP, new_hdl); at https://github.com/cocotb/cocotb/blob/ac41bea02b9e09a617fca95421f36dac5029d247/cocotb/share/lib/vhpi/VhpiCbHdl.cpp#L452-L458

vhpi_get() obtains the property of an object, in this case of new_hdl, a callback handle. vhpiStateP indicates which type of property we’d like to get: the state of the callback. vhpi_get() should return one of three options: vhpiEnable, vhpiDisable or vhpiMature. Instead, Xcelium returns vhpiUndefined, indicating that it does not support getting the vhpiStateP property from a callback handle.

It should be noted that using vhpiStateP is not really obscure, as seen in the example code in the VHDL IEEE Std 1076-2019 spec section “23.8 vhpi_enable_cb”:

In the following VHPI program, the function vhpi_enable_cb is used to enable a callback that was registered but is disabled.

static vhpiHandleT mylastcbk = 0;

void activate_cbk(vhpiHandle cbHdl) {
  vhpiStateT cbState;
  cbState = vhpi_get(vhpiStateP, cbHdl);
  if (cbState == vhpiDisable)
    vhpi_enable_cb(cbHdl);
  }
}

void register_cbk() {
  vhpiCbDataT cbData;
  vhpiHandleT cbHdl;
  int flags;
  flags = vhpiDisableCb | vhpiReturnCb;
  cbData.reason = vhpiCbEndOfSimulation;
  cbData.cb_rtn = myf;
  cbHdl = vhpi_register_cb(&cbData, flags);
  mylastcbk = cbHdl;
}

int main (int argc, char *argv[] ){
  register_cbk();
  ...
  activate_cbk(mylastcbk);
  return(0);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Xcelium Errors/Warnings with xmhelp ...
The xmhelp utility gives you detailed information about an error or warning message that you may get during the various phases of your...
Read more >
Logic Simulation | Vivado Design Suite User Guide - Xilinx
Cadence Xcelium Parallel Simulator ... Set up an install location in Vivado IDE (if not using the Vivado ... fs, ps, ns, us,...
Read more >
cocotb/Lobby - Gitter
I see on cocotb/cocotb#1359 that warnings are being added for the combination of VHDL + Cadence. Is the implication that Verilog works as...
Read more >
Incisive Simulator Tcl Command Reference
of design abstraction for Verilog, VHDL, and mixed-language. Using the coverage command, you can: □. Setup coverage variables (coverage ...
Read more >
Cadence AMS Simulator User Guide -- B. Tcl-Based Debugging
Note: The expr command cannot evaluate calls to Verilog functions. ... For VHDL, you can deposit to ports, signals, and variables if no...
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