1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity tb_bin_to_7seg is
end;
architecture tb of tb_bin_to_7seg is
signal clk: std_logic;
signal bin: unsigned(3 downto 0);
subtype seg_vec is std_logic_vector(6 downto 0);
signal segs: seg_vec;
begin
clk_pr: process
begin
for i in 1 to 16 loop
clk <= '0';
wait for 5 ns;
clk <= '1';
wait for 5 ns;
end loop;
wait;
end process;
bin <= to_unsigned(1, bin);
dut: entity work.bin_to_7seg
port map(
clk_in => clk,
bin_in => bin,
segs_out => segs);
process (clk)
type res_arr is array (natural range <>) of seg_vec;
constant res : res_arr (0 to 15) :=
("UUUUUUU", 7x"00", 7x"00", 7x"00", 7x"00", 7x"00", 7x"10", 7x"20",
7x"00", 7x"00", 7x"00", 7x"00", 7x"00", 7x"10", 7x"20", 7x"00");
variable idx : natural := 0;
begin
if rising_edge(clk) then
assert segs = res (idx) report "segs=" & to_bstring(segs)
severity failure;
idx := idx + 1;
end if;
end process;
end;
|