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';
80 m_out.addr <= (others => '0');
81 m_out.pte <= (others => '0');
83 wait until rising_edge(clk);
84 wait until rising_edge(clk);
85 wait until rising_edge(clk);
86 wait until rising_edge(clk);
89 i_out.nia <= x"0000000000000004";
91 wait for 30*clk_period;
92 wait until rising_edge(clk);
94 assert i_in.valid = '1' severity failure;
95 assert i_in.insn = x"00000001"
96 report "insn @" & to_hstring(i_out.nia) &
97 "=" & to_hstring(i_in.insn) &
103 wait until rising_edge(clk);
107 i_out.nia <= x"0000000000000008";
108 wait until rising_edge(clk);
109 wait until rising_edge(clk);
110 assert i_in.valid = '1' severity failure;
111 assert i_in.insn = x"00000002"
112 report "insn @" & to_hstring(i_out.nia) &
113 "=" & to_hstring(i_in.insn) &
116 wait until rising_edge(clk);
120 i_out.nia <= x"0000000000000040";
122 wait for 30*clk_period;
123 wait until rising_edge(clk);
125 assert i_in.valid = '1' severity failure;
126 assert i_in.insn = x"00000010"
127 report "insn @" & to_hstring(i_out.nia) &
128 "=" & to_hstring(i_in.insn) &
132 -- test something that aliases
134 i_out.nia <= x"0000000000000100";
135 wait until rising_edge(clk);
136 wait until rising_edge(clk);
137 assert i_in.valid = '0' severity failure;
138 wait until rising_edge(clk);
140 wait for 30*clk_period;
141 wait until rising_edge(clk);
143 assert i_in.valid = '1' severity failure;
144 assert i_in.insn = x"00000040"
145 report "insn @" & to_hstring(i_out.nia) &
146 "=" & to_hstring(i_in.insn) &