2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
7 use work.wishbone_types.all;
11 SIM : boolean := false
17 wishbone_insn_in : in wishbone_slave_out;
18 wishbone_insn_out : out wishbone_master_out;
20 wishbone_data_in : in wishbone_slave_out;
21 wishbone_data_out : out wishbone_master_out;
23 dmi_addr : in std_ulogic_vector(3 downto 0);
24 dmi_din : in std_ulogic_vector(63 downto 0);
25 dmi_dout : out std_ulogic_vector(63 downto 0);
26 dmi_req : in std_ulogic;
27 dmi_wr : in std_ulogic;
28 dmi_ack : out std_ulogic;
30 terminated_out : out std_logic
34 architecture behave of core is
36 signal fetch1_to_fetch2: Fetch1ToFetch2Type;
37 signal fetch2_to_decode1: Fetch2ToDecode1Type;
40 signal fetch2_to_icache : Fetch2ToIcacheType;
41 signal icache_to_fetch2 : IcacheToFetch2Type;
44 signal decode1_to_decode2: Decode1ToDecode2Type;
45 signal decode2_to_execute1: Decode2ToExecute1Type;
47 -- register file signals
48 signal register_file_to_decode2: RegisterFileToDecode2Type;
49 signal decode2_to_register_file: Decode2ToRegisterFileType;
50 signal writeback_to_register_file: WritebackToRegisterFileType;
53 signal decode2_to_cr_file: Decode2ToCrFileType;
54 signal cr_file_to_decode2: CrFileToDecode2Type;
55 signal writeback_to_cr_file: WritebackToCrFileType;
58 signal execute1_to_execute2: Execute1ToExecute2Type;
59 signal execute2_to_writeback: Execute2ToWritebackType;
60 signal execute1_to_fetch1: Execute1ToFetch1Type;
63 signal decode2_to_loadstore1: Decode2ToLoadstore1Type;
64 signal loadstore1_to_loadstore2: Loadstore1ToLoadstore2Type;
65 signal loadstore2_to_writeback: Loadstore2ToWritebackType;
68 signal decode2_to_multiply: Decode2ToMultiplyType;
69 signal multiply_to_writeback: MultiplyToWritebackType;
72 signal fetch1_stall_in : std_ulogic;
73 signal fetch2_stall_in : std_ulogic;
74 signal fetch2_stall_out : std_ulogic;
75 signal decode1_stall_in : std_ulogic;
76 signal decode2_stall_out : std_ulogic;
78 signal flush: std_ulogic;
80 signal complete: std_ulogic;
81 signal terminate: std_ulogic;
82 signal core_rst: std_ulogic;
83 signal icache_rst: std_ulogic;
86 signal dbg_core_stop: std_ulogic;
87 signal dbg_core_rst: std_ulogic;
88 signal dbg_icache_rst: std_ulogic;
91 signal dbg_core_is_stopped: std_ulogic;
94 signal registers: regfile;
98 core_rst <= dbg_core_rst or rst;
100 fetch1_0: entity work.fetch1
102 RESET_ADDRESS => (others => '0')
107 stall_in => fetch1_stall_in,
109 e_in => execute1_to_fetch1,
110 f_out => fetch1_to_fetch2
113 fetch1_stall_in <= fetch2_stall_out or decode2_stall_out;
115 fetch2_0: entity work.fetch2
119 stall_in => fetch2_stall_in,
120 stall_out => fetch2_stall_out,
122 i_in => icache_to_fetch2,
123 i_out => fetch2_to_icache,
124 stop_in => dbg_core_stop,
125 f_in => fetch1_to_fetch2,
126 f_out => fetch2_to_decode1
129 fetch2_stall_in <= decode2_stall_out;
131 icache_0: entity work.icache
139 i_in => fetch2_to_icache,
140 i_out => icache_to_fetch2,
141 wishbone_out => wishbone_insn_out,
142 wishbone_in => wishbone_insn_in
145 icache_rst <= rst or dbg_icache_rst;
147 decode1_0: entity work.decode1
151 stall_in => decode1_stall_in,
153 f_in => fetch2_to_decode1,
154 d_out => decode1_to_decode2
157 decode1_stall_in <= decode2_stall_out;
159 decode2_0: entity work.decode2
163 stall_out => decode2_stall_out,
165 complete_in => complete,
166 stopped_out => dbg_core_is_stopped,
167 d_in => decode1_to_decode2,
168 e_out => decode2_to_execute1,
169 l_out => decode2_to_loadstore1,
170 m_out => decode2_to_multiply,
171 r_in => register_file_to_decode2,
172 r_out => decode2_to_register_file,
173 c_in => cr_file_to_decode2,
174 c_out => decode2_to_cr_file
177 register_file_0: entity work.register_file
180 d_in => decode2_to_register_file,
181 d_out => register_file_to_decode2,
182 w_in => writeback_to_register_file,
183 registers_out => registers);
185 cr_file_0: entity work.cr_file
188 d_in => decode2_to_cr_file,
189 d_out => cr_file_to_decode2,
190 w_in => writeback_to_cr_file
193 execute1_0: entity work.execute1
200 e_in => decode2_to_execute1,
201 f_out => execute1_to_fetch1,
202 e_out => execute1_to_execute2,
203 terminate_out => terminate
206 execute2_0: entity work.execute2
209 e_in => execute1_to_execute2,
210 e_out => execute2_to_writeback
213 loadstore1_0: entity work.loadstore1
216 l_in => decode2_to_loadstore1,
217 l_out => loadstore1_to_loadstore2
220 loadstore2_0: entity work.loadstore2
223 l_in => loadstore1_to_loadstore2,
224 w_out => loadstore2_to_writeback,
225 m_in => wishbone_data_in,
226 m_out => wishbone_data_out
229 multiply_0: entity work.multiply
232 m_in => decode2_to_multiply,
233 m_out => multiply_to_writeback
236 writeback_0: entity work.writeback
239 e_in => execute2_to_writeback,
240 l_in => loadstore2_to_writeback,
241 m_in => multiply_to_writeback,
242 w_out => writeback_to_register_file,
243 c_out => writeback_to_cr_file,
244 complete_out => complete
247 debug_0: entity work.core_debug
251 dmi_addr => dmi_addr,
253 dmi_dout => dmi_dout,
257 core_stop => dbg_core_stop,
258 core_rst => dbg_core_rst,
259 icache_rst => dbg_icache_rst,
260 terminate => terminate,
261 core_stopped => dbg_core_is_stopped,
262 nia => fetch1_to_fetch2.nia,
263 terminated_out => terminated_out
266 -- Dump registers if core terminates
267 sim_terminate_test: if SIM generate
268 dump_registers: process(all)
270 if terminate = '1' then
271 loop_0: for i in 0 to 31 loop
272 report "REG " & to_hstring(registers(i));
274 assert false report "end of test" severity failure;