]> rtime.felk.cvut.cz Git - fpga/pwm.git/blob - tb/tb_wave_table.vhd
Unused signal removed and minor change.
[fpga/pwm.git] / tb / tb_wave_table.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_wave_table is
7 end tb_wave_table;
8
9 --------------------------------------------------------------------------------
10
11 architecture testbench of tb_wave_table is
12
13   constant period : time := 37.5 ns;
14   constant offset : time := 0 us;
15
16   constant DAT_W     : integer := 10;
17   constant ADR_W     : integer := 9;
18   constant INIT_FILE : string  := "../sin.lut";
19
20   constant WAVE_SIZE : integer := 2**ADR_W;
21
22
23   signal ACK_O : std_logic;
24   signal ADR_I : std_logic_vector (ADR_W-1 downto 0);
25   signal CLK_I : std_logic;
26   signal DAT_I : std_logic_vector (DAT_W-1 downto 0);
27   signal DAT_O : std_logic_vector (DAT_W-1 downto 0);
28   signal STB_I : std_logic;
29   signal WE_I  : std_logic;
30   signal RST_I : std_logic;
31
32 --------------------------------------------------------------------------------
33   
34 begin
35   
36   uut : entity work.wave_table
37     generic map (
38       DAT_W     => DAT_W,
39       ADR_W     => ADR_W,
40       INIT_FILE => INIT_FILE)
41     port map (
42       ACK_O => ACK_O,
43       ADR_I => ADR_I,
44       CLK_I => CLK_I,
45       DAT_I => DAT_I,
46       DAT_O => DAT_O,
47       STB_I => STB_I,
48       WE_I  => WE_I);
49   
50   SYSCON_CLK : process
51   begin
52     CLK_I <= '0';
53     wait for offset;
54     loop
55       CLK_I <= '1';
56       wait for period/2;
57       CLK_I <= '0';
58       wait for period/2;
59     end loop;
60   end process;
61
62   SYSCON_RST : process
63   begin
64     RST_I <= '0';
65     wait for offset;
66     wait for 0.75*period;
67     RST_I <= '1';
68     wait for 2*period;
69     RST_I <= '0';
70     wait;
71   end process;
72     
73 --------------------------------------------------------------------------------
74
75   UUT_FEED : process
76   begin
77     DAT_I <= (others => '0');
78     ADR_I <= (others => '0');
79     STB_I <= '0';
80     WE_I  <= '0';
81     
82     wait for offset;
83     wait for 4*period;
84     
85     for i in 0 to 2*(WAVE_SIZE-1) loop
86       ADR_I <= conv_std_logic_vector(i, ADR_W);
87       STB_I <= '1';
88       wait until ACK_O = '1';
89       wait for period;
90       STB_I <= '0';
91       wait for period;
92     end loop;
93     
94     wait;
95   end process;
96   
97 end testbench;
98