下面是一个计数器,旨在表示一个8位二进制数与8发光二极管,它正在模拟使用一个测试平台,但当运行模拟时,输出只是显示UU为led。
以下是我要测试的主要实体:
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输出递增?
编辑:
将btnd设置为1,在测试台上等待1ns以初始化led,在mkrieger1的回答之后,在此更改后led输出仍在U。
发布于 2021-01-03 00:43:13
在count
设置为'1'
之前,不会在Lab_3_Source_File
中初始化btnd
,而它不在测试工作台中。
因为led
输出是由count
驱动的,所以它也没有初始化。然后,将led
输出的Lab_3_Source_File
的未初始化值分配给测试平台中的led
信号。
因此,要解决这一问题,您需要在testbench中将btnd
设置为'1'
一次,持续时间为非零,然后再将其设置为'0'
(否则,led
将一直保存在"00000000"
上)。
https://stackoverflow.com/questions/65545587
复制相似问题