2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
6 use work.wishbone_types.all;
8 entity simple_ram_behavioural_tb is
9 end simple_ram_behavioural_tb;
11 architecture behave of simple_ram_behavioural_tb is
12 signal clk : std_ulogic;
13 signal rst : std_ulogic := '1';
15 constant clk_period : time := 10 ns;
17 signal w_in : wishbone_slave_out;
18 signal w_out : wishbone_master_out;
20 simple_ram_0: entity work.mw_soc_memory
22 RAM_INIT_FILE => "simple_ram_behavioural_tb.bin",
35 wait for clk_period / 2;
37 wait for clk_period / 2;
42 w_out.adr <= (others => '0');
43 w_out.dat <= (others => '0');
46 w_out.sel <= (others => '0');
56 -- test various read lengths and alignments
58 w_out.sel <= "00000001";
59 w_out.adr <= x"0000000000000000";
60 assert w_in.ack = '0';
62 assert w_in.ack = '1';
63 assert w_in.dat(7 downto 0) = x"00" report to_hstring(w_in.dat);
66 assert w_in.ack = '0';
69 w_out.sel <= "00000001";
70 w_out.adr <= x"0000000000000001";
71 assert w_in.ack = '0';
73 assert w_in.ack = '1';
74 assert w_in.dat(7 downto 0) = x"01" report to_hstring(w_in.dat);
77 assert w_in.ack = '0';
80 w_out.sel <= "00000001";
81 w_out.adr <= x"0000000000000007";
82 assert w_in.ack = '0';
84 assert w_in.ack = '1';
85 assert w_in.dat(7 downto 0) = x"07" report to_hstring(w_in.dat);
88 assert w_in.ack = '0';
91 w_out.sel <= "00000011";
92 w_out.adr <= x"0000000000000000";
93 assert w_in.ack = '0';
95 assert w_in.ack = '1';
96 assert w_in.dat(15 downto 0) = x"0100" report to_hstring(w_in.dat);
99 assert w_in.ack = '0';
102 w_out.sel <= "00000011";
103 w_out.adr <= x"0000000000000001";
104 assert w_in.ack = '0';
106 assert w_in.ack = '1';
107 assert w_in.dat(15 downto 0) = x"0201" report to_hstring(w_in.dat);
110 assert w_in.ack = '0';
113 w_out.sel <= "00000011";
114 w_out.adr <= x"0000000000000007";
115 assert w_in.ack = '0';
117 assert w_in.ack = '1';
118 assert w_in.dat(15 downto 0) = x"0807" report to_hstring(w_in.dat);
121 assert w_in.ack = '0';
124 w_out.sel <= "00001111";
125 w_out.adr <= x"0000000000000000";
126 assert w_in.ack = '0';
128 assert w_in.ack = '1';
129 assert w_in.dat(31 downto 0) = x"03020100" report to_hstring(w_in.dat);
132 assert w_in.ack = '0';
135 w_out.sel <= "00001111";
136 w_out.adr <= x"0000000000000001";
137 assert w_in.ack = '0';
139 assert w_in.ack = '1';
140 assert w_in.dat(31 downto 0) = x"04030201" report to_hstring(w_in.dat);
143 assert w_in.ack = '0';
146 w_out.sel <= "00001111";
147 w_out.adr <= x"0000000000000007";
148 assert w_in.ack = '0';
150 assert w_in.ack = '1';
151 assert w_in.dat(31 downto 0) = x"0A090807" report to_hstring(w_in.dat);
154 assert w_in.ack = '0';
157 w_out.sel <= "11111111";
158 w_out.adr <= x"0000000000000000";
159 assert w_in.ack = '0';
161 assert w_in.ack = '1';
162 assert w_in.dat(63 downto 0) = x"0706050403020100" report to_hstring(w_in.dat);
165 assert w_in.ack = '0';
168 w_out.sel <= "11111111";
169 w_out.adr <= x"0000000000000001";
170 assert w_in.ack = '0';
172 assert w_in.ack = '1';
173 assert w_in.dat(63 downto 0) = x"0807060504030201" report to_hstring(w_in.dat);
176 assert w_in.ack = '0';
179 w_out.sel <= "11111111";
180 w_out.adr <= x"0000000000000007";
181 assert w_in.ack = '0';
183 assert w_in.ack = '1';
184 assert w_in.dat(63 downto 0) = x"0E0D0C0B0A090807" report to_hstring(w_in.dat);
187 assert w_in.ack = '0';
189 -- test various write lengths and alignments
191 w_out.sel <= "00000001";
192 w_out.adr <= x"0000000000000000";
194 w_out.dat(7 downto 0) <= x"0F";
195 assert w_in.ack = '0';
197 assert w_in.ack = '1';
200 assert w_in.ack = '0';
203 w_out.sel <= "00000001";
204 w_out.adr <= x"0000000000000000";
206 assert w_in.ack = '0';
208 assert w_in.ack = '1';
209 assert w_in.dat(7 downto 0) = x"0F" report to_hstring(w_in.dat);
212 assert w_in.ack = '0';
215 w_out.sel <= "11111111";
216 w_out.adr <= x"0000000000000007";
218 w_out.dat <= x"BADC0FFEBADC0FFE";
219 assert w_in.ack = '0';
221 assert w_in.ack = '1';
224 assert w_in.ack = '0';
227 w_out.sel <= "11111111";
228 w_out.adr <= x"0000000000000007";
230 assert w_in.ack = '0';
232 assert w_in.ack = '1';
233 assert w_in.dat = x"BADC0FFEBADC0FFE" report to_hstring(w_in.dat);
236 assert w_in.ack = '0';
238 assert false report "end of test" severity failure;