Im using cocotb v1.0 and ghdl 0.35-dev (llvm and gcc backend).
The top level contains a simple for generate statement:
gen_pe : for i in 1 to 4 generate
...
end generate gen_pe;
I tried to access the first generated module in my cocotb testbench with: "dut.gen_pe[1]". It produces the error:
10000.00ns WARNING Failed to find a hdl at index 1 via any registered implementation
10000.00ns ERROR Send raised exception: gen_pe contains no object at index 1
When looping through the dut, it discovers the following submodules from the generate statement:
10000.00ns INFO Found something: (1)(GPI_MODULE)
10000.00ns INFO Found something: (2)(GPI_MODULE)
10000.00ns INFO Found something: (3)(GPI_MODULE)
10000.00ns INFO Found something: (4)(GPI_MODULE)
Unfortunately it isnt possible to access them with "dut.(1)", because it isnt valid python syntax.
Next I tried to execute the test array testcase from cocotb/tests/test_cases/test_array with:
make -s SIM=ghdl TOPLEVEL_LANG=vhdl
Almost all the tests are failing:
*************************************************************************************************
** TEST PASS/FAIL SIM TIME(NS) REAL TIME(S) RATIO(NS/S) **
**************************************************************************************************
** test_array.test_direct_constant_indexing FAIL 2001.00 0.00 1640180.24 **
** test_array.test_direct_signal_indexing FAIL 2001.00 0.00 1048707.02 **
** test_array.test_discover_all FAIL 1001.00 0.01 145412.61 **
** test_array.test_extended_identifiers PASS 2001.00 0.00 5155283.97 **
** test_array.test_gen_loop FAIL 1001.00 0.00 1166573.58 **
** test_array.test_read_write FAIL 1000.00 0.00 860546.57 **
**************************************************************************************************
9005.00ns INFO cocotb.regression regression.py:358 in _log_sim_summary
*************************************************************************************
** ERRORS : 5 **
*************************************************************************************
** SIM TIME : 9005.00 NS **
** REAL TIME : 0.05 S **
** SIM / REAL TIME : 173326.30 NS/S **
Output of test_gen_loop is:
7004.00ns INFO cocotb.regression regression.py:287 in execute Running test 5/6: test_gen_loop
7004.00ns INFO ..tine.test_gen_loop.0x7fa35db6d4d0 decorators.py:191 in send Starting test: "test_gen_loop"
Description: Test accessing Generate Loops
8004.00ns WARNING cocotb.gpi GpiCommon.cpp:353 in gpi_get_handle_by_index Failed to find a hdl at index 20 via any registered implementation
8004.00ns ERROR ..tine.test_gen_loop.0x7fa35db6d4d0 result.py:51 in raise_error Send raised exception: asc_gen contains no object at index 20
File "/home/Programme/cocotb/cocotb/decorators.py", line 197, in send
return self._coro.send(value)
File "/home/Programme/cocotb/tests/test_cases/test_array/test_array.py", line 189, in test_gen_loop
asc_gen_20 = dut.asc_gen[20]
File "/home/Programme/cocotb/cocotb/handle.py", line 342, in __getitem__
raise IndexError("%s contains no object at index %d" % (self._name, index))
8005.00ns ERROR cocotb.regression regression.py:263 in handle_result Test Failed: test_gen_loop (result was TestError)
Thats similar to the error at my design. So I guess its an issue with the module naming.
Any idea how to get valid module names or fix the error completely?
edit: Minimal example
Folder: /home/Programme/cocotb/examples/generate
/home/Programme/cocotb/examples/generate/hdl/top.vhd
:
library ieee;
use ieee.std_logic_1164.all;
entity top is
port (
clk : in std_logic;
A : in std_logic_vector(4 downto 1);
B : out std_logic_vector(4 downto 1)
);
end top;
architecture rtl of top is
begin
gen_pe : for i in 1 to 4 generate
test : process (clk) is
begin
if (rising_edge(clk)) then
B(i) <= A(i);
end if;
end process test;
end generate gen_pe;
end rtl;
/home/Programme/cocotb/examples/generate/tests/top_cocotb.py
:
import cocotb
from cocotb.clock import Clock
from cocotb.triggers import Timer
@cocotb.test()
def test_gen(dut):
cocotb.fork(Clock(dut.clk, 1000).start())
yield Timer(1000)
for i in dut:
print i._log.info("Found something: %s" % i._fullname)
/home/Programme/cocotb/examples/generate/tests/Makefile
:
CWD = $(shell pwd)
COCOTB = $(CWD)/../../..
TOPLEVEL_LANG = vhdl
VHDL_SOURCES = $(CWD)/../hdl/top.vhd
SIM = ghdl
CMD_BIN = ghdl
TOPLEVEL=top
MODULE=$(TOPLEVEL)_cocotb
include $(COCOTB)/makefiles/Makefile.inc
include $(COCOTB)/makefiles/Makefile.sim
sim: $(MODULE).py
After executing with make
, the gpi-module names (1) ... (4)
instead of gen_pe(1) ... gen_pe(4)
are printed to the console.
Update:
The gpi-module names are fixed in the newest version of ghdl. However the cocotb test array testcases are still failing.