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 : IcacheToDecode1Type;
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
39 wishbone_out => wb_bram_in,
40 wishbone_in => wb_bram_out
44 bram0: entity work.wishbone_bram_wrapper
47 RAM_INIT_FILE => "icache_test.bin"
52 wishbone_in => wb_bram_in,
53 wishbone_out => wb_bram_out
59 wait for clk_period/2;
61 wait for clk_period/2;
67 wait for 2*clk_period;
75 i_out.nia <= (others => '0');
76 i_out.stop_mark <= '0';
77 i_out.priv_mode <= '1';
78 i_out.virt_mode <= '0';
79 i_out.big_endian <= '0';
83 m_out.addr <= (others => '0');
84 m_out.pte <= (others => '0');
86 wait until rising_edge(clk);
87 wait until rising_edge(clk);
88 wait until rising_edge(clk);
89 wait until rising_edge(clk);
92 i_out.nia <= x"0000000000000004";
94 wait for 30*clk_period;
95 wait until rising_edge(clk);
97 assert i_in.valid = '1' severity failure;
98 assert i_in.insn = x"00000001"
99 report "insn @" & to_hstring(i_out.nia) &
100 "=" & to_hstring(i_in.insn) &
106 wait until rising_edge(clk);
110 i_out.nia <= x"0000000000000008";
111 wait until rising_edge(clk);
112 wait until rising_edge(clk);
113 assert i_in.valid = '1' severity failure;
114 assert i_in.insn = x"00000002"
115 report "insn @" & to_hstring(i_out.nia) &
116 "=" & to_hstring(i_in.insn) &
119 wait until rising_edge(clk);
123 i_out.nia <= x"0000000000000040";
125 wait for 30*clk_period;
126 wait until rising_edge(clk);
128 assert i_in.valid = '1' severity failure;
129 assert i_in.insn = x"00000010"
130 report "insn @" & to_hstring(i_out.nia) &
131 "=" & to_hstring(i_in.insn) &
135 -- test something that aliases
137 i_out.nia <= x"0000000000000100";
138 wait until rising_edge(clk);
139 wait until rising_edge(clk);
140 assert i_in.valid = '0' severity failure;
141 wait until rising_edge(clk);
143 wait for 30*clk_period;
144 wait until rising_edge(clk);
146 assert i_in.valid = '1' severity failure;
147 assert i_in.insn = x"00000040"
148 report "insn @" & to_hstring(i_out.nia) &
149 "=" & to_hstring(i_in.insn) &