File: tb_bin_to_7seg.vhdl

package info (click to toggle)
ghdl 5.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,000 kB
  • sloc: ada: 309,826; vhdl: 209,727; ansic: 31,072; python: 19,213; sh: 14,214; cpp: 2,345; makefile: 1,542; pascal: 585; asm: 45; exp: 40; fortran: 33
file content (49 lines) | stat: -rw-r--r-- 1,145 bytes parent folder | download
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;