1

我正在为 2 位寄存器编写代码和测试台,但是在我的测试台中,当我运行测试台的模拟时,我的断言报告语句没有显示在控制台中。我正在使用 Modelsim PE 学生版 10.4a,并且我正在运行 100 ns 的模拟。这是测试台和控制台图像请帮助。提前致谢。modelsim 仿真的快照

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_textio.all;
use std.textio.all;


entity reg_TB is            -- entity declaration
end reg_TB;

------------------------------------------------------------------

architecture TB of reg_TB is

    component reg
    port(   I:      in std_logic_vector(1 downto 0);
            clock:  in std_logic;
        load:   in std_logic;
        clear:  in std_logic;
        Q:      out std_logic_vector(1 downto 0)
    );
    end component;

    signal T_I:     std_logic_vector(1 downto 0);
    signal T_clock: std_logic;
    signal T_load:  std_logic;
    signal T_clear: std_logic;
    signal T_Q:     std_logic_vector(1 downto 0);

begin

    U_reg: reg port map (T_I, T_clock, T_load, T_clear, T_Q);

    -- concurrent process to offer the clock signal
    process
    begin
    T_clock <= '0';
    wait for 5 ns;
    T_clock <= '1';
    wait for 5 ns;
    end process;

    process                         

    variable err_cnt: integer :=0;

    begin                               

    T_I <= "10";
    T_load <= '0';
    T_clear <= '1';

    -- case 1
    wait for 20 ns;
    T_load <= '1';
    wait for 10 ns;
    assert (T_Q="10") report "Test1 Failed!" severity error;
    if (T_Q/=T_I) then
        err_cnt := err_cnt+1;
    end if;

    -- case 2               
    wait for 10 ns;
    T_load <= '0';
    wait for 10 ns;
    assert (T_Q="10") report "Test2 Failed!" severity error;
    if (T_Q/=T_I) then
        err_cnt := err_cnt+1;
    end if;     

    -- case 3
    wait for 10 ns;
    T_clear <= '0';                                        
    wait for 10 ns;
    assert (T_Q="00") report "Test3 Failed!" severity error;
    if (T_Q/=T_I) then
        err_cnt := err_cnt+1;
    end if;

    -- case 4
    wait for 10 ns;
    T_clear <= '1';
    wait for 10 ns;
    assert (T_Q="00") report "Test4 Failed!" severity error;
    if (T_Q/=T_I) then
        err_cnt := err_cnt+1;
    end if;

    -- summary of all the tests
    if (err_cnt=0) then 
        assert false
        report "Testbench of register completely successfully!"
        severity note;
    else
        assert true
        report "Something wrong, check again pls!"
        severity error;
    end if;

        wait;

    end process;

end TB;

------------------------------------------------------------------
configuration CFG_TB of reg_TB is
    for TB
    end for;
end CFG_TB;
------------------------------------------------------------------
4

2 回答 2

2

您的所有报告都基于断言,如果断言没有失败,则不会打印报告。另外,请注意,每个测试中的断言与 increment 的条件不同err_cnt,因此您可能会在没有打印的情况下多次失败(因为断言没有失败)但仍然在最后输入“失败”部分,其中你不会得到任何打印,因为assert true永远不会失败。

尝试将“report”和“severity”子句添加到测试本身的相关检查中,看看是否打印了任何内容。此外,如果测试失败与否,请在最终检查中删除断言,如您所知(!)。

例如:

...
-- case 3
wait for 10 ns;
T_clear <= '0';                                        
wait for 10 ns;
if (T_Q/=T_I) then
    err_cnt := err_cnt+1;
    report "Test3 Failed!" severity error;
end if;

...

if (err_cnt=0) then 
    report "Testbench of register completely successfully!"
    severity note;
else
    report "Something wrong, check again pls!"
    severity error;
end if;
于 2015-12-09T20:28:40.297 回答
0

如果在每个测试用例中的 if 语句之后立即添加 err_cnt 的报告语句:

    if (T_Q/=T_I) then
        err_cnt := err_cnt+1;
    end if;
    report "err_cont = " &integer'image(err_cnt);

您会发现测试用例 3 和测试用例 4 递增 err_cnt 而不会失败:

reg_tb.vhdl:93:5:@30ns:(report note): err_cont = 0
reg_tb.vhdl:102:5:@50ns:(report note): err_cont = 0
reg_tb.vhdl:111:5:@70ns:(报告注释):err_cont = 1
reg_tb.vhdl:120:5:@90ns:(报告注释):err_cont = 2

时间戳将这些显示为测试用例 1 - 4,err_cnt 是一个变量,因此它在最后两个中递增。

这阻止了这里的第一次报告:

    -- summary of all the tests
    if (err_cnt=0) then 
        assert false
        report "Testbench of register completely successfully!"
        severity note;
    else
        assert true
        report "Something wrong, check again pls!"
        severity error;
    end if;

正如 Brian 评论的那样,断言 true 永远不会是错误的,并且您不会执行摘要中的第二个报告语句。

正如 MbyD 指出的那样,您断言的内容与您认为出于 err_cnt 目的的错误之间存在差异,并且 if 语句条件对于案例 3 和 4 无效:

reg_tb_testcases1_4.png

于 2015-12-09T21:29:37.837 回答