我正在使用cocotb v1.0和ghdl 0.35-dev(llvm和gcc后端)。
顶级包含一个简单的生成语句:
gen_pe : for i in 1 to 4 generate
...
end generate gen_pe;
我尝试使用以下命令访问我的cocotb testbench中的第一个生成的模块:“dut.gen_pe [1]”。它产生错误:
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
当循环播放dut时,它会从generate语句中发现以下子模块:
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)
不幸的是,用“dut。(1)”访问它们是不可能的,因为它不是有效的python语法。
接下来,我尝试从cocotb / tests / test_cases / test_array执行测试数组测试用例:
make -s SIM=ghdl TOPLEVEL_LANG=vhdl
几乎所有的测试都失败了:
*************************************************************************************************
** 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 **
test_gen_loop的输出是:
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)
这与我设计中的错误类似。所以我猜这是模块命名的问题。
知道如何获取有效的模块名称或完全修复错误吗?
编辑:最小示例
文件夹:/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
使用make
执行后,gpi模块名称(1) ... (4)
而非gen_pe(1) ... gen_pe(4)
将打印到控制台。
更新
gpi-module名称在最新版本的ghdl中修复。然而,cocotb测试阵列测试用例仍然失败。