2 use ieee.std_logic_1164.all;
6 use work.wishbone_types.all;
11 architecture behave of icache_tb is
12 signal clk : std_ulogic;
13 signal rst : std_ulogic;
15 signal i_out : Fetch1ToIcacheType;
16 signal i_in : IcacheToFetch2Type;
18 signal m_out : MmuToIcacheType;
20 signal wb_bram_in : wishbone_master_out;
21 signal wb_bram_out : wishbone_slave_out;
23 constant clk_period : time := 10 ns;
25 icache0: entity work.icache
37 wishbone_out => wb_bram_in,
38 wishbone_in => wb_bram_out
42 bram0: entity work.wishbone_bram_wrapper
45 RAM_INIT_FILE => "icache_test.bin"
50 wishbone_in => wb_bram_in,
51 wishbone_out => wb_bram_out
57 wait for clk_period/2;
59 wait for clk_period/2;
65 wait for 2*clk_period;
73 i_out.nia <= (others => '0');
74 i_out.stop_mark <= '0';
78 m_out.addr <= (others => '0');
79 m_out.pte <= (others => '0');
81 wait until rising_edge(clk);
82 wait until rising_edge(clk);
83 wait until rising_edge(clk);
84 wait until rising_edge(clk);
87 i_out.nia <= x"0000000000000004";
89 wait for 30*clk_period;
90 wait until rising_edge(clk);
92 assert i_in.valid = '1' severity failure;
93 assert i_in.insn = x"00000001"
94 report "insn @" & to_hstring(i_out.nia) &
95 "=" & to_hstring(i_in.insn) &
101 wait until rising_edge(clk);
105 i_out.nia <= x"0000000000000008";
106 wait until rising_edge(clk);
107 wait until rising_edge(clk);
108 assert i_in.valid = '1' severity failure;
109 assert i_in.insn = x"00000002"
110 report "insn @" & to_hstring(i_out.nia) &
111 "=" & to_hstring(i_in.insn) &
114 wait until rising_edge(clk);
118 i_out.nia <= x"0000000000000040";
120 wait for 30*clk_period;
121 wait until rising_edge(clk);
123 assert i_in.valid = '1' severity failure;
124 assert i_in.insn = x"00000010"
125 report "insn @" & to_hstring(i_out.nia) &
126 "=" & to_hstring(i_in.insn) &
130 -- test something that aliases
132 i_out.nia <= x"0000000000000100";
133 wait until rising_edge(clk);
134 wait until rising_edge(clk);
135 assert i_in.valid = '0' severity failure;
136 wait until rising_edge(clk);
138 wait for 30*clk_period;
139 wait until rising_edge(clk);
141 assert i_in.valid = '1' severity failure;
142 assert i_in.insn = x"00000040"
143 report "insn @" & to_hstring(i_out.nia) &
144 "=" & to_hstring(i_in.insn) &
150 assert false report "end of test" severity failure;