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_scale is
9 --------------------------------------------------------------------------------
11 architecture testbench of tb_vector_scale is
13 constant period : time := 500 ns;
14 constant offset : time := 0 us;
16 constant IRF_ADR_W : integer := 5;
19 signal ACK_O : std_logic;
20 signal CLK_I : std_logic;
21 signal RST_I : std_logic;
22 signal STB_I : std_logic;
24 signal IRF_ACK_I : std_logic;
25 signal IRF_ADR_O : std_logic_vector (IRF_ADR_W-1 downto 0);
26 signal IRF_CYC_O : std_logic;
27 signal IRF_DAT_I : std_logic_vector (15 downto 0);
28 signal IRF_DAT_O : std_logic_vector (15 downto 0);
29 signal IRF_STB_O : std_logic;
30 signal IRF_WE_O : std_logic;
32 signal MUL_A : std_logic_vector (15 downto 0);
33 signal MUL_B : std_logic_vector (15 downto 0);
34 signal MUL_PROD : std_logic_vector (31 downto 0);
37 subtype word_t is std_logic_vector (15 downto 0);
39 signal dbg_mem0x05 : word_t := (others => '0');
40 signal dbg_mem0x10 : word_t := (others => '0');
41 signal dbg_mem0x11 : word_t := (others => '0');
42 signal dbg_ack : std_logic := '0';
44 --------------------------------------------------------------------------------
48 uut : entity work.vector_scale
50 IRF_ADR_W => IRF_ADR_W,
65 IRF_ACK_I => IRF_ACK_I,
66 IRF_ADR_O => IRF_ADR_O,
67 IRF_DAT_I => IRF_DAT_I,
68 IRF_DAT_O => IRF_DAT_O,
69 IRF_STB_O => IRF_STB_O,
70 IRF_WE_O => IRF_WE_O);
72 multiplier_1 : entity work.multiplier
79 SYSCON_CLK : process is
91 SYSCON_RST : process is
103 DBG_MEM : process (IRF_STB_O, CLK_I) is
105 IRF_ACK_I <= IRF_STB_O and (IRF_WE_O or dbg_ack);
107 if rising_edge(CLK_I) then
108 dbg_ack <= IRF_STB_O;
111 if rising_edge(CLK_I) and IRF_STB_O = '1' then
112 if IRF_WE_O = '0' then
113 case conv_integer(IRF_ADR_O) is
114 when 16#05# => IRF_DAT_I <= dbg_mem0x05;
115 when 16#10# => IRF_DAT_I <= dbg_mem0x10;
116 when 16#11# => IRF_DAT_I <= dbg_mem0x11;
118 IRF_DAT_I <= (others => '0');
119 report "Reading from non-existing register" severity warning;
122 case conv_integer(IRF_ADR_O) is
123 --when 16#05# => dbg_mem0x05 <= IRF_DAT_O;
124 --when 16#10# => dbg_mem0x10 <= IRF_DAT_O;
125 when 16#11# => dbg_mem0x11 <= IRF_DAT_O;
127 report "Writing to read-only registers" severity error;
133 --------------------------------------------------------------------------------
135 UUT_FEED : process is
142 for i in 0 to 10 loop
143 dbg_mem0x10 <= "0000000111111111";
145 dbg_mem0x05 <= conv_std_logic_vector(i*(2**10), 16);
147 wait for 0.75*period;
149 wait for 0.25*period;
150 wait until rising_edge(CLK_I) and ACK_O = '1';
151 wait for 0.25*period;
153 wait for 0.75*period;