2 use ieee.std_logic_1164.all;
6 use work.wishbone_types.all;
11 architecture behave of dcache_tb is
12 signal clk : std_ulogic;
13 signal rst : std_ulogic;
15 signal d_in : Loadstore1ToDcacheType;
16 signal d_out : DcacheToWritebackType;
18 signal wb_bram_in : wishbone_master_out;
19 signal wb_bram_out : wishbone_slave_out;
21 constant clk_period : time := 10 ns;
23 dcache0: entity work.dcache
33 wishbone_out => wb_bram_in,
34 wishbone_in => wb_bram_out
38 bram0: entity work.mw_soc_memory
41 RAM_INIT_FILE => "icache_test.bin"
46 wishbone_in => wb_bram_in,
47 wishbone_out => wb_bram_out
53 wait for clk_period/2;
55 wait for clk_period/2;
61 wait for 2*clk_period;
72 d_in.addr <= (others => '0');
73 d_in.data <= (others => '0');
74 d_in.write_reg <= (others => '0');
75 d_in.length <= (others => '0');
76 d_in.byte_reverse <= '0';
77 d_in.sign_extend <= '0';
79 d_in.update_reg <= (others => '0');
81 wait for 4*clk_period;
82 wait until rising_edge(clk);
84 -- Cacheable read of address 4
87 d_in.addr <= x"0000000000000004";
89 wait until rising_edge(clk);
92 wait until rising_edge(clk) and d_out.write_enable = '1';
93 assert d_out.valid = '1';
94 assert d_out.write_data = x"0000000100000000"
95 report "data @" & to_hstring(d_in.addr) &
96 "=" & to_hstring(d_out.write_data) &
97 " expected 0000000100000000"
99 -- wait for clk_period;
101 -- Cacheable read of address 30
104 d_in.addr <= x"0000000000000030";
106 wait until rising_edge(clk);
109 wait until rising_edge(clk) and d_out.write_enable = '1';
110 assert d_out.valid = '1';
111 assert d_out.write_data = x"0000000D0000000C"
112 report "data @" & to_hstring(d_in.addr) &
113 "=" & to_hstring(d_out.write_data) &
114 " expected 0000000D0000000C"
117 -- Non-cacheable read of address 100
120 d_in.addr <= x"0000000000000100";
122 wait until rising_edge(clk);
125 wait until rising_edge(clk) and d_out.write_enable = '1';
126 assert d_out.valid = '1';
127 assert d_out.write_data = x"0000004100000040"
128 report "data @" & to_hstring(d_in.addr) &
129 "=" & to_hstring(d_out.write_data) &
130 " expected 0000004100000040"
133 wait for clk_period*4;
135 assert false report "end of test" severity failure;