]> rtime.felk.cvut.cz Git - fpga/pwm.git/blob - tb/tb_priority_encoder.vhd
Added priority encoder.
[fpga/pwm.git] / tb / tb_priority_encoder.vhd
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_arith.all;
4 use ieee.std_logic_unsigned.all;
5
6 entity tb_priority_encoder is
7 end tb_priority_encoder;
8
9 --------------------------------------------------------------------------------
10
11 architecture testbench of tb_priority_encoder is
12
13   constant period : time := 1 us;
14   constant offset : time := 0 us;
15
16   signal CLK_I : std_logic;
17   signal RST_I : std_logic;
18   
19   signal SEL  : std_logic_vector (3 downto 0);
20   signal CODE : std_logic_vector (1 downto 0);
21
22 --------------------------------------------------------------------------------
23   
24 begin
25   
26   uut: entity work.priority_encoder
27     generic map (
28       SEL_W  => 4,
29       CODE_W => 2)
30     port map (
31       sel  => SEL,
32       code => CODE);
33
34   
35   SYSCON_CLK : process is
36   begin
37     CLK_I <= '0';
38     wait for offset;
39     loop
40       CLK_I <= '1';
41       wait for period/2;
42       CLK_I <= '0';
43       wait for period/2;
44     end loop;
45   end process;
46
47   SYSCON_RST : process is
48   begin
49     RST_I <= '0';
50     wait for offset;
51     wait for 0.75*period;
52     RST_I <= '1';
53     wait for 2*period;
54     RST_I <= '0';
55     wait;
56   end process;
57
58 --------------------------------------------------------------------------------
59
60   UUT_FEED : process is
61   begin
62     SEL <= "0000";
63         
64     wait for offset;
65     wait for 3*period;
66
67     for i in 1 to 15 loop
68       SEL <= conv_std_logic_vector(i, 4);
69       wait for 3*period;
70     end loop;
71     
72     wait;
73   end process;
74   
75 end testbench;
76