2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_arith.all;
4 use ieee.std_logic_unsigned.all;
6 entity tb_vector_gen is
9 --------------------------------------------------------------------------------
11 architecture testbench of tb_vector_gen is
13 constant period : time := 5 ns;
14 constant offset : time := 0 us;
16 constant LUT_DAT_W : integer := 10;
17 constant LUT_ADR_W : integer := 9;
18 constant LUT_INIT_FILE : string := "../sin.lut";
19 constant IRF_ADR_W : integer := 5;
21 constant WAVE_SIZE : integer := 2**LUT_ADR_W;
24 signal ACK_O : std_logic;
25 signal CLK_I : std_logic;
26 signal RST_I : std_logic;
27 signal STB_I : std_logic;
29 signal IRF_ACK_I : std_logic;
30 signal IRF_ADR_O : std_logic_vector (IRF_ADR_W-1 downto 0);
31 signal IRF_CYC_O : std_logic;
32 signal IRF_DAT_I : std_logic_vector (15 downto 0);
33 signal IRF_DAT_O : std_logic_vector (15 downto 0);
34 signal IRF_STB_O : std_logic;
35 signal IRF_WE_O : std_logic;
36 signal LUT_ADR_O : std_logic_vector (LUT_ADR_W-1 downto 0);
37 signal LUT_DAT_I : std_logic_vector (LUT_DAT_W-1 downto 0);
38 signal LUT_STB_O : std_logic;
41 subtype word_t is std_logic_vector (15 downto 0);
43 signal dbg_mem0 : word_t := conv_std_logic_vector(1,16); -- read only by UUT
44 signal dbg_mem1 : word_t := (others => '0');
45 signal dbg_mem2 : word_t := (others => '0');
46 signal dbg_mem3 : word_t := (others => '0');
47 signal dbg_ack : std_logic := '0';
49 --------------------------------------------------------------------------------
53 uut : entity work.vector_gen
59 IRF_ACK_I => IRF_ACK_I,
60 IRF_ADR_O => IRF_ADR_O,
62 IRF_DAT_I => IRF_DAT_I,
63 IRF_DAT_O => IRF_DAT_O,
64 IRF_STB_O => IRF_STB_O,
66 LUT_ADR_O => LUT_ADR_O,
67 LUT_DAT_I => LUT_DAT_I,
68 LUT_STB_O => LUT_STB_O);
70 wave_table_1 : entity work.wave_table
74 INIT_FILE => LUT_INIT_FILE)
79 DAT_I => (others => '0'),
85 SYSCON_CLK : process is
97 SYSCON_RST : process is
101 wait for 0.75*period;
109 DBG_MEM : process (IRF_STB_O, CLK_I) is
111 IRF_ACK_I <= IRF_STB_O and (IRF_WE_O or dbg_ack);
113 if rising_edge(CLK_I) then
114 dbg_ack <= IRF_STB_O;
117 if rising_edge(CLK_I) and IRF_STB_O = '1' then
118 if IRF_WE_O = '0' then
119 case conv_integer(IRF_ADR_O) is
120 when 0 => IRF_DAT_I <= dbg_mem0;
121 when 1 => IRF_DAT_I <= dbg_mem1;
122 when 2 => IRF_DAT_I <= dbg_mem2;
123 when 3 => IRF_DAT_I <= dbg_mem3;
124 when others => IRF_DAT_I <= (others => '0');
127 case conv_integer(IRF_ADR_O) is
128 when 1 => dbg_mem1 <= IRF_DAT_O;
129 when 2 => dbg_mem2 <= IRF_DAT_O;
130 when 3 => dbg_mem3 <= IRF_DAT_O;
137 --------------------------------------------------------------------------------
139 UUT_FEED : process is
146 for i in 0 to WAVE_SIZE loop
147 dbg_mem0 <= (others => '0');
148 dbg_mem0(LUT_ADR_O'RANGE) <= conv_std_logic_vector(i, LUT_ADR_W);
151 wait until rising_edge(CLK_I) and ACK_O = '1';