下面是一个设计用来表示带有8个LED的8位二进制数的计数器,正在使用测试平台对其进行仿真,但是在运行仿真时,输出仅显示led的UU。
这是我要测试的主要实体:
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_unsigned.all;
entity Lab_3_Source_File is
generic(N_BITS : integer := 8);
port(
btnd : in STD_LOGIC ;
clk : in STD_LOGIC;
led : out STD_LOGIC_VECTOR(7 downto 0)
);
end Lab_3_Source_File;
architecture counter of Lab_3_Source_File is
signal count: STD_LOGIC_VECTOR(7 downto 0);
begin
process(clk, btnd)
begin
if btnd = '1' then
count <= (others => '0');
elsif rising_edge(clk) then
count <= count + 1;
end if;
end process;
led <= count;
end counter;
这是我尝试映射到主要实体的测试平台:
use IEEE.STD_LOGIC_1164.ALL;
entity Count_TestBench is
end Count_TestBench;
architecture Behavioral of Count_TestBench is
signal btnd, clk : STD_LOGIC;
signal led : STD_LOGIC_VECTOR(7 downto 0);
begin
UUT : entity work.Lab_3_Source_File port map (btnd => btnd,clk => clk,led => led);
process
begin
btnd<='1';
wait for 1 ns;
btnd<='0';
led<= (others => '0');
for i in 1 to 100 loop
clk<='1';
wait for 10 ns;
clk<='0';
wait for 10 ns;
led<=led;
end loop;
end process;
end Behavioral;
请有人能帮助我了解如何使仿真显示LED输出增量吗?
编辑:
在测试台上等待1ns的等待时间,将btnd设置为1,以初始化led,根据mkrieger1的回答,经过此更改,led输出仍为U。
count
未初始化内部Lab_3_Source_File
直到btnd
被设置为'1'
,它是不是在测试平台。
由于led
输出由来驱动count
,因此它也未初始化。然后将led
输出的未初始化值Lab_3_Source_File
分配给led
测试台中的信号。
因此,要解决这个问题,你需要设置btnd
到'1'
一旦在测试平台非零持续时间,将其设置为前'0'
一次(否则led
在保持"00000000"
不断)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句