cocotb中带有generate语句的模块名不可用

2024-06-02 04:47:57 发布

您现在位置:Python中文网/ 问答频道 /正文

Im使用cocotbv1.0和ghdl0.35-dev(llvm和gcc后端)。在

顶层包含一个简单的for generate语句:

gen_pe : for i in 1 to 4 generate
    ...
end generate gen_pe;

我试图访问我的cocotb测试台中的第一个生成的模块:杜特根佩[1] “。”。它会产生错误:

^{pr2}$

当dut通过循环子模块发现以下语句时:

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执行test array testcase:

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                         **

测试回路的输出为:

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)而不是{}被打印到控制台。在

更新:

gpi模块名称在最新版本的ghdl中是固定的。但是cocotb测试阵列测试用例仍然失败。在


Tags: 模块inpytestinfohometoparray