【问题标题】:How can I test bench a VHDL 24 hour Clock?如何测试 VHDL 24 小时时钟?
【发布时间】:2016-05-22 01:43:06
【问题描述】:

我在尝试测试我的 VHDL 时遇到了一些问题。 我正在使用 fpga Baysis 2 运行我的代码,它在硬件上运行良好,但是当我使用 Isim 程序来模拟我的代码时,它没有显示我的输出引脚的任何行为,只有字母U.

我正在浏览互联网,但找不到解决方案,有人可以帮我解决这个问题吗?

下面是我的代码的最后一部分(可能是有问题的部分)。在此之前,代码只是有一个过程,将时钟分频为 1 秒,另一个分频为 1/200 秒,以快速打开和关闭 fpga 显示屏上的 LED,并计算秒数以使 24 小时时钟工作,当然。

    contador: process(clk200)

variable flag : std_logic_vector (1 downto 0);
-- ledplex is the mux that controls which display should be on
-- Segm is the 7 segments display 
-- mu md hu hd are the signals with the time information
begin

if(clk200'event and clk200='1') then
     if (flag = "00") then

        ledplex <= "1110";

            case mu is 
                when 0 => segm <= "1000000";
                when 1 => segm <= "1111001";
                when 2 => segm <= "0100100";
                when 3 => segm <= "0110000";
                when 4 => segm <= "0011001";
                when 5 => segm <= "0010010";
                when 6 => segm <= "0000011";
                when 7 => segm <= "1111000";
                when 8 => segm <= "0000000";
                when 9 => segm <= "0011000";
                when others => segm <= "1111111";   
            end case;
        flag := "01";

    elsif (flag = "01") then

        ledplex <= "1101";

            case md is 
                when 0 => segm <= "1000000";
                when 1 => segm <= "1111001";
                when 2 => segm <= "0100100";
                when 3 => segm <= "0110000";
                when 4 => segm <= "0011001";
                when 5 => segm <= "0010010";
                when others => segm <= "1111111";           
            end case;
    flag := "10";

    elsif (flag = "10") then
        ledplex <= "1011";

            case hu is 
                when 0 => segm <= "1000000";
                when 1 => segm <= "1111001";
                when 2 => segm <= "0100100";
                when 3 => segm <= "0110000";
                when 4 => segm <= "0011001";
                when 5 => segm <= "0010010";
                when 6 => segm <= "0000011";
                when 7 => segm <= "1111000";
                when 8 => segm <= "0000000";
                when 9 => segm <= "0011000";
                when others => segm <= "1111111";   
            end case;
        flag := "11";

    elsif (flag = "11") then
        ledplex <= "0111";

            case hd is 
                when 0 => segm <= "1000000";
                when 1 => segm <= "1111001";
                when 2 => segm <= "0100100";
                when others => segm <= "1111111";           
            end case;
    flag := "00";

    end if;
end if;
end process contador;

下面是测试台 图书馆 ieee; 使用 ieee.std_logic_1164.ALL;

 ENTITY t_b IS
 END t_b;

   ARCHITECTURE behavior OF t_b IS 

-- Component Declaration for the Unit Under Test (UUT)

    COMPONENT hora
   PORT(
     clk25m : IN  std_logic;
     segm : OUT  std_logic_vector(6 downto 0);
     ledplex : OUT  std_logic_vector(3 downto 0);
        x : out std_logic
    );
   END COMPONENT;

    signal  clk_tb : std_logic := '0';
    signal  segm_tb : std_logic_vector(6 downto 0);
    signal   ledplex_tb : std_logic_vector(3 downto 0);
    signal x_tb : std_logic;

    BEGIN

    CUT: hora port map(  clk25m => clk_tb,
                                segm => segm_tb,
                                ledplex => ledplex_tb,
                                x => x_tb);


    Test_Vector: process
    begin
    clk_tb <= '1';
    wait for 40 ns;
    clk_tb <= '0';
    wait for 40 ns;
    end process;

    END behavior;

【问题讨论】:

  • 我可以看到你不想用大量代码压倒人们,但不是摆脱阻止它编译的位,如何摆脱与你的问题无关的位?这样,您向我们展示了一些可以编译和运行的代码,这样我们就可以轻松地重现您的问题,而无需提供太多代码。这称为MCVE。创建一个 MCVE 还有另一个优点:在创建一个 MCVE 时,提问者很可能自己发现了问题,因此比仅仅阅读别人的答案学到的更多。

标签: vhdl fpga


【解决方案1】:

您没有初始化变量flag。没有这个你的变量可能是未定义的,因此U。使用以下内容:

variable flag : std_logic_vector (1 downto 0) := "00"; -- initialize variable

【讨论】:

    猜你喜欢
    • 2015-08-05
    • 1970-01-01
    • 2013-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-16
    • 1970-01-01
    • 2015-08-21
    相关资源
    最近更新 更多