【问题标题】:I need modelsim to look at inner variables我需要 modelsim 来查看内部变量
【发布时间】:2019-02-09 04:17:22
【问题描述】:

我有 VHDL 代码,其中包含我想要模拟的 INs、OUTs 和内部 SIGNAL 常量,例如计数器。我看过网上的例子,我只看到 Modelsim 监控 INs 和 OUTs。但是,我还想查看计数器等内部信号。我看到一个人只写模拟代码。我需要以下的一个简单示例:带有一些 IN 和 OUT 以及一些内部信号的代码。一个简单的通用 TB 代码,只有一个 clk 增量或类似的。我看到了一个看起来正确的示例,但是当我将它改编为我的代码时,Modelsim 中未定义内部信号。我可能会遗漏一些东西,但我的理解是 Modelsim 的一个重要特性是编写一个带有时钟的通用测试台,并使用它来查看我的逻辑的直方图。随着代码的进展,您只需根据需要将变量添加到 tb.如果有人在原始和 tb 中都有一些通用代码或代码位置,他们将分享将非常有帮助。谢谢

【问题讨论】:

    标签: vhdl modelsim test-bench


    【解决方案1】:

    我从来没有遇到过让 modelsim 将内部信号绘制到波形上的问题。我只是将信号从“对象”窗口拖放到 Wave 窗口。

    这是一个简单的例子。这是 TestModule.vhd:

    library ieee;
    use ieee.std_logic_1164.all;
    use IEEE.NUMERIC_STD.ALL;
    
    entity TestModule is
    port (
              ip_sl_ClkIn                : in std_logic;
              ip_slv_InputVal            : in std_logic_vector(7 downto 0);
              ip_sl_InputValid           : in std_logic;
    
              op_slv_OutputVal           : out std_logic_vector(7 downto 0);
              op_sl_OutputValid          : out std_logic
    );
    end TestModule;
    
    
    architecture Behavioral of TestModule is
    
      --==========================
      --== INTERNAL SIGNALS
      --==========================
      signal s_slv_InputNibbleSwap_1d : std_logic_vector(7 downto 0) := (others => 'X');
      signal s_slv_Inverted_2d : std_logic_vector(7 downto 0) := (others => 'X');
    
      signal s_sl_InputValid_1d : std_logic := '0';
      signal s_sl_InputValid_2d : std_logic := '0';
    
    begin
    
    
       RegisterProc : process(ip_sl_ClkIn)
        begin
          if(rising_edge(ip_sl_ClkIn)) then
    
          --Clock Cycle 1:
          --=======================
          --Take the input and swap nibble locations
          s_slv_InputNibbleSwap_1d <= ip_slv_InputVal(3 downto 0) & ip_slv_InputVal(7 downto 4);
          s_sl_InputValid_1d       <= ip_sl_InputValid;
    
          --Clock Cycle 2:
          --=======================          
          --Invert the bits
          s_slv_Inverted_2d        <= not(s_slv_InputNibbleSwap_1d);
          s_sl_InputValid_2d       <= s_sl_InputValid_1d;
    
          end if; --rising_edge(ip_sl_ClkIn)
        end process RegisterProc;
    
    
    
        --Route Outputs:
        --=====================
        op_slv_OutputVal  <= s_slv_Inverted_2d;
        op_sl_OutputValid <= s_sl_InputValid_2d;
    
    end Behavioral;
    

    这里是测试台,TestModule_tb.vhd:

     LIBRARY ieee;
      USE ieee.std_logic_1164.ALL;
    USE ieee.numeric_std.ALL;
      use std.textio.all;
    ENTITY TestModule_tb IS
    END TestModule_tb;
    
    architecture behavior of TestModule_tb is
    
    -- Component Declaration
    -------------------------
      component TestModule
      Port ( 
            ip_sl_ClkIn : in std_logic;
            ip_slv_InputVal : in std_logic_vector ( 7 downto 0 );
            ip_sl_InputValid : in std_logic;
            op_slv_OutputVal : out std_logic_vector ( 7 downto 0 );
            op_sl_OutputValid : out std_logic
        );
      end component;
    
    
    
    --Signals Driven by Entity: TestModule
    -------------------------
        signal s_slv_OutputVal : std_logic_vector ( 7 downto 0 );
        signal s_sl_OutputValid : std_logic;
    
    
    --Test Stimulus Signals:
    -------------------------
        signal s_sl_ClkIn : std_logic;
        signal s_slv_InputVal : std_logic_vector ( 7 downto 0 );
        signal s_sl_InputValid : std_logic;
    
    
    BEGIN
    
    --Component Instantiation
        uut : TestModule
        Port Map (
            ip_sl_ClkIn         => s_sl_ClkIn   ,  --in std_logic
            ip_slv_InputVal     => s_slv_InputVal   ,  --in std_logic_vector ( 7 downto 0 )
            ip_sl_InputValid    => s_sl_InputValid   ,  --in std_logic
            op_slv_OutputVal    => s_slv_OutputVal   ,  --out std_logic_vector ( 7 downto 0 )
            op_sl_OutputValid   => s_sl_OutputValid     --out std_logic
        );
    
    
        clkProc : process
        begin
            s_sl_ClkIn <= '1';
            wait for 10 ns;
            s_sl_ClkIn <= '0';
            wait for 10 ns;
        end process;
    
    
    MainTestProcess : Process
    Begin
    
         s_slv_InputVal <= (others => '0');
         s_sl_InputValid <= '0';
         wait for 100 ns; 
    
         wait until rising_edge(s_sl_ClkIn); wait for 1 ps;
         s_slv_InputVal <= X"AB";
         s_sl_InputValid <= '1';
    
         wait until rising_edge(s_sl_ClkIn); wait for 1 ps;
         s_slv_InputVal <= X"FF";
         s_sl_InputValid <= '0';     
    
         wait for 100 ns;
    
        --Not a failure, but stops the simulation
        assert false report "<---- NOT a failure. Testbench Complete" severity failure;
    
        wait; -- Will wait forever
    end process;
    
    END;
    

    这是一个modelsim DO文件,用于编译和模拟,TestModule_tb.do:

    vlib work
    vcom -reportprogress 300 -work work TestModule.vhd
    vcom -reportprogress 300 -work work TestModule_tb.vhd 
    vsim -gui work.testmodule_tb
    do TestModule_tb_wave.do
    run -all
    

    这是modelsim波形DO文件,TestModule_tb_wave.do:

    onerror {resume}
    quietly WaveActivateNextPane {} 0
    add wave -noupdate /testmodule_tb/uut/ip_sl_ClkIn
    add wave -noupdate /testmodule_tb/uut/ip_slv_InputVal
    add wave -noupdate /testmodule_tb/uut/ip_sl_InputValid
    add wave -noupdate /testmodule_tb/uut/op_slv_OutputVal
    add wave -noupdate /testmodule_tb/uut/op_sl_OutputValid
    add wave -noupdate /testmodule_tb/uut/s_slv_InputNibbleSwap_1d
    add wave -noupdate /testmodule_tb/uut/s_slv_Inverted_2d
    add wave -noupdate /testmodule_tb/uut/s_sl_InputValid_1d
    add wave -noupdate /testmodule_tb/uut/s_sl_InputValid_2d
    TreeUpdate [SetDefaultTree]
    WaveRestoreCursors {{Cursor 1} {90738 ps} 0}
    quietly wave cursor active 1
    configure wave -namecolwidth 331
    configure wave -valuecolwidth 100
    configure wave -justifyvalue left
    configure wave -signalnamewidth 0
    configure wave -snapdistance 10
    configure wave -datasetprefix 0
    configure wave -rowmargin 4
    configure wave -childrowmargin 2
    configure wave -gridoffset 0
    configure wave -gridperiod 1
    configure wave -griddelta 40
    configure wave -timeline 0
    configure wave -timelineunits ps
    update
    WaveRestoreZoom {0 ps} {231001 ps}
    

    【讨论】:

    • 我有一个程序,叫它 prog.vhd。我也有 prog_tb.vhd。主要有大约 20 个 IN/OUT 和 10 个信号。当我运行 Modelsim 时,我只得到 IN/OUT。我无法将内部组件带到“模拟”部分。经过一些扰动后,我得到了一个信号转移到模拟。但是,信号未定义。我缺少一些东西。我想通过示例代码来学习。
    • 我已经修改了我的答案,以展示使用 modelsim 查看内部信号的示例。
    • 非常感谢。我现在想我了解带有内部信号的测试台文件的格式。我今晚会做一些工作,但在北卡罗来纳州已经是啤酒:30。
    • 我终于让 Modelsim 查看所有变量。现在,这导致了另一个问题。如果我有一个大变量,比如 200 位,如何只查看一组这些位,比如 (20-28)?
    • 有几种方法可以做到这一点。您可以在 VHDL 代码中创建一个新信号,该信号分配位 20-28 并在 modelsim 中查看该新信号。您也可以直接在modelsim中这样做:在波形窗口中,展开您的200位向量,然后选择您想要自己查看的位(单击第一位然后按住shift并单击第二位),然后您可以右键单击并选择“组合信号”并给它一个新名称,它将显示一个仅包含这些位的新信号。如果我回答了你原来的问题,请“接受”作为答案。
    猜你喜欢
    • 2018-01-10
    • 2020-02-24
    • 1970-01-01
    • 2013-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多