1 |
2 |
csantifort |
//////////////////////////////////////////////////////////////////
|
2 |
|
|
// //
|
3 |
|
|
// Amber 2 Core top-Level module //
|
4 |
|
|
// //
|
5 |
|
|
// This file is part of the Amber project //
|
6 |
|
|
// http://www.opencores.org/project,amber //
|
7 |
|
|
// //
|
8 |
|
|
// Description //
|
9 |
|
|
// Instantiates the core consisting of fetch, instruction //
|
10 |
|
|
// decode, execute, and co-processor. //
|
11 |
|
|
// //
|
12 |
|
|
// Author(s): //
|
13 |
|
|
// - Conor Santifort, csantifort.amber@gmail.com //
|
14 |
|
|
// //
|
15 |
|
|
//////////////////////////////////////////////////////////////////
|
16 |
|
|
// //
|
17 |
|
|
// Copyright (C) 2010 Authors and OPENCORES.ORG //
|
18 |
|
|
// //
|
19 |
|
|
// This source file may be used and distributed without //
|
20 |
|
|
// restriction provided that this copyright statement is not //
|
21 |
|
|
// removed from the file and that any derivative work contains //
|
22 |
|
|
// the original copyright notice and the associated disclaimer. //
|
23 |
|
|
// //
|
24 |
|
|
// This source file is free software; you can redistribute it //
|
25 |
|
|
// and/or modify it under the terms of the GNU Lesser General //
|
26 |
|
|
// Public License as published by the Free Software Foundation; //
|
27 |
|
|
// either version 2.1 of the License, or (at your option) any //
|
28 |
|
|
// later version. //
|
29 |
|
|
// //
|
30 |
|
|
// This source is distributed in the hope that it will be //
|
31 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied //
|
32 |
|
|
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
|
33 |
|
|
// PURPOSE. See the GNU Lesser General Public License for more //
|
34 |
|
|
// details. //
|
35 |
|
|
// //
|
36 |
|
|
// You should have received a copy of the GNU Lesser General //
|
37 |
|
|
// Public License along with this source; if not, download it //
|
38 |
|
|
// from http://www.opencores.org/lgpl.shtml //
|
39 |
|
|
// //
|
40 |
|
|
//////////////////////////////////////////////////////////////////
|
41 |
|
|
|
42 |
|
|
|
43 |
15 |
csantifort |
module a23_core
|
44 |
2 |
csantifort |
(
|
45 |
|
|
input i_clk,
|
46 |
|
|
|
47 |
|
|
input i_irq, // Interrupt request, active high
|
48 |
|
|
input i_firq, // Fast Interrupt request, active high
|
49 |
|
|
|
50 |
|
|
input i_system_rdy, // Amber is stalled when this is low
|
51 |
|
|
|
52 |
|
|
// Wishbone Master I/F
|
53 |
|
|
output [31:0] o_wb_adr,
|
54 |
|
|
output [3:0] o_wb_sel,
|
55 |
|
|
output o_wb_we,
|
56 |
|
|
input [31:0] i_wb_dat,
|
57 |
|
|
output [31:0] o_wb_dat,
|
58 |
|
|
output o_wb_cyc,
|
59 |
|
|
output o_wb_stb,
|
60 |
|
|
input i_wb_ack,
|
61 |
|
|
input i_wb_err
|
62 |
|
|
|
63 |
|
|
);
|
64 |
|
|
|
65 |
|
|
wire [31:0] execute_address;
|
66 |
|
|
wire execute_address_valid;
|
67 |
|
|
wire [31:0] execute_address_nxt; // un-registered version of execute_address to the cache rams
|
68 |
|
|
wire [31:0] write_data;
|
69 |
|
|
wire write_enable;
|
70 |
|
|
wire [31:0] read_data;
|
71 |
|
|
wire priviledged;
|
72 |
|
|
wire exclusive_exec;
|
73 |
|
|
wire data_access_exec;
|
74 |
|
|
wire [3:0] byte_enable;
|
75 |
|
|
wire data_access; // high for data petch, low for instruction fetch
|
76 |
|
|
wire exclusive; // swap access
|
77 |
|
|
wire cache_enable; // Enabel the cache
|
78 |
|
|
wire cache_flush; // Flush the cache
|
79 |
|
|
wire [31:0] cacheable_area;
|
80 |
|
|
|
81 |
|
|
wire fetch_stall; // when this is asserted all registers in all 3 pipeline
|
82 |
|
|
// stages are held
|
83 |
|
|
// at their current values
|
84 |
|
|
wire [1:0] status_bits_mode;
|
85 |
|
|
wire status_bits_irq_mask;
|
86 |
|
|
wire status_bits_firq_mask;
|
87 |
|
|
wire status_bits_flags_wen;
|
88 |
|
|
wire status_bits_mode_wen;
|
89 |
|
|
wire status_bits_irq_mask_wen;
|
90 |
|
|
wire status_bits_firq_mask_wen;
|
91 |
|
|
wire [31:0] execute_status_bits;
|
92 |
|
|
|
93 |
|
|
wire [31:0] imm32;
|
94 |
|
|
wire [4:0] imm_shift_amount;
|
95 |
|
|
wire shift_imm_zero;
|
96 |
|
|
wire [3:0] condition;
|
97 |
|
|
wire [31:0] read_data_s2;
|
98 |
|
|
wire [4:0] read_data_alignment;
|
99 |
|
|
|
100 |
|
|
wire [3:0] rm_sel;
|
101 |
|
|
wire [3:0] rds_sel;
|
102 |
|
|
wire [3:0] rn_sel;
|
103 |
|
|
wire [1:0] barrel_shift_amount_sel;
|
104 |
|
|
wire [1:0] barrel_shift_data_sel;
|
105 |
|
|
wire [1:0] barrel_shift_function;
|
106 |
|
|
wire [8:0] alu_function;
|
107 |
|
|
wire [1:0] multiply_function;
|
108 |
|
|
wire [2:0] interrupt_vector_sel;
|
109 |
|
|
wire [3:0] address_sel;
|
110 |
|
|
wire [1:0] pc_sel;
|
111 |
|
|
wire [1:0] byte_enable_sel;
|
112 |
|
|
wire [2:0] status_bits_sel;
|
113 |
|
|
wire [2:0] reg_write_sel;
|
114 |
|
|
wire user_mode_regs_load;
|
115 |
|
|
wire user_mode_regs_store_nxt;
|
116 |
|
|
wire firq_not_user_mode;
|
117 |
|
|
|
118 |
|
|
wire write_data_wen;
|
119 |
|
|
wire copro_write_data_wen;
|
120 |
|
|
wire base_address_wen;
|
121 |
|
|
wire pc_wen;
|
122 |
|
|
wire [14:0] reg_bank_wen;
|
123 |
|
|
|
124 |
|
|
wire [2:0] copro_opcode1;
|
125 |
|
|
wire [2:0] copro_opcode2;
|
126 |
|
|
wire [3:0] copro_crn;
|
127 |
|
|
wire [3:0] copro_crm;
|
128 |
|
|
wire [3:0] copro_num;
|
129 |
|
|
wire [1:0] copro_operation;
|
130 |
|
|
wire [31:0] copro_read_data;
|
131 |
|
|
wire [31:0] copro_write_data;
|
132 |
|
|
wire multiply_done;
|
133 |
|
|
|
134 |
|
|
wire decode_fault;
|
135 |
|
|
wire iabt_trigger;
|
136 |
|
|
wire dabt_trigger;
|
137 |
|
|
|
138 |
|
|
wire [7:0] decode_fault_status;
|
139 |
|
|
wire [7:0] iabt_fault_status;
|
140 |
|
|
wire [7:0] dabt_fault_status;
|
141 |
|
|
|
142 |
|
|
wire [31:0] decode_fault_address;
|
143 |
|
|
wire [31:0] iabt_fault_address;
|
144 |
|
|
wire [31:0] dabt_fault_address;
|
145 |
|
|
|
146 |
|
|
wire adex;
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
// data abort has priority
|
150 |
|
|
assign decode_fault_status = dabt_trigger ? dabt_fault_status : iabt_fault_status;
|
151 |
|
|
assign decode_fault_address = dabt_trigger ? dabt_fault_address : iabt_fault_address;
|
152 |
|
|
assign decode_fault = dabt_trigger | iabt_trigger;
|
153 |
|
|
|
154 |
|
|
|
155 |
15 |
csantifort |
a23_fetch u_fetch (
|
156 |
2 |
csantifort |
.i_clk ( i_clk ),
|
157 |
|
|
|
158 |
|
|
.i_address ( {execute_address[31:2], 2'd0} ),
|
159 |
|
|
.i_address_valid ( execute_address_valid ),
|
160 |
|
|
.i_address_nxt ( execute_address_nxt ),
|
161 |
|
|
.i_write_data ( write_data ),
|
162 |
|
|
.i_write_enable ( write_enable ),
|
163 |
|
|
.o_read_data ( read_data ),
|
164 |
|
|
.i_priviledged ( priviledged ),
|
165 |
|
|
.i_byte_enable ( byte_enable ),
|
166 |
|
|
.i_data_access ( data_access ),
|
167 |
|
|
.i_exclusive ( exclusive ),
|
168 |
|
|
.i_cache_enable ( cache_enable ),
|
169 |
|
|
.i_cache_flush ( cache_flush ),
|
170 |
|
|
.i_cacheable_area ( cacheable_area ),
|
171 |
|
|
|
172 |
|
|
.i_system_rdy ( i_system_rdy ),
|
173 |
|
|
.o_fetch_stall ( fetch_stall ),
|
174 |
|
|
|
175 |
|
|
.o_wb_adr ( o_wb_adr ),
|
176 |
|
|
.o_wb_sel ( o_wb_sel ),
|
177 |
|
|
.o_wb_we ( o_wb_we ),
|
178 |
|
|
.i_wb_dat ( i_wb_dat ),
|
179 |
|
|
.o_wb_dat ( o_wb_dat ),
|
180 |
|
|
.o_wb_cyc ( o_wb_cyc ),
|
181 |
|
|
.o_wb_stb ( o_wb_stb ),
|
182 |
|
|
.i_wb_ack ( i_wb_ack ),
|
183 |
|
|
.i_wb_err ( i_wb_err )
|
184 |
|
|
);
|
185 |
|
|
|
186 |
|
|
|
187 |
15 |
csantifort |
a23_decode u_decode (
|
188 |
2 |
csantifort |
.i_clk ( i_clk ),
|
189 |
|
|
|
190 |
|
|
// Instruction fetch or data read signals
|
191 |
|
|
.i_read_data ( read_data ),
|
192 |
|
|
.i_execute_address ( execute_address ),
|
193 |
|
|
.i_adex ( adex ),
|
194 |
|
|
.i_iabt ( 1'd0 ),
|
195 |
|
|
.i_dabt ( 1'd0 ),
|
196 |
|
|
.i_abt_status ( 8'd0 ),
|
197 |
|
|
|
198 |
|
|
.o_read_data ( read_data_s2 ),
|
199 |
|
|
.o_read_data_alignment ( read_data_alignment ),
|
200 |
|
|
|
201 |
|
|
.i_irq ( i_irq ),
|
202 |
|
|
.i_firq ( i_firq ),
|
203 |
|
|
.i_fetch_stall ( fetch_stall ),
|
204 |
|
|
.i_execute_status_bits ( execute_status_bits ),
|
205 |
|
|
.i_multiply_done ( multiply_done ),
|
206 |
|
|
|
207 |
|
|
.o_status_bits_mode ( status_bits_mode ),
|
208 |
|
|
.o_status_bits_irq_mask ( status_bits_irq_mask ),
|
209 |
|
|
.o_status_bits_firq_mask ( status_bits_firq_mask ),
|
210 |
|
|
.o_imm32 ( imm32 ),
|
211 |
|
|
.o_imm_shift_amount ( imm_shift_amount ),
|
212 |
|
|
.o_shift_imm_zero ( shift_imm_zero ),
|
213 |
|
|
.o_condition ( condition ),
|
214 |
|
|
.o_exclusive_exec ( exclusive_exec ),
|
215 |
|
|
.o_data_access_exec ( data_access_exec ),
|
216 |
|
|
.o_rm_sel ( rm_sel ),
|
217 |
|
|
.o_rds_sel ( rds_sel ),
|
218 |
|
|
.o_rn_sel ( rn_sel ),
|
219 |
|
|
.o_barrel_shift_amount_sel ( barrel_shift_amount_sel ),
|
220 |
|
|
.o_barrel_shift_data_sel ( barrel_shift_data_sel ),
|
221 |
|
|
.o_barrel_shift_function ( barrel_shift_function ),
|
222 |
|
|
.o_alu_function ( alu_function ),
|
223 |
|
|
.o_multiply_function ( multiply_function ),
|
224 |
|
|
.o_interrupt_vector_sel ( interrupt_vector_sel ),
|
225 |
|
|
.o_address_sel ( address_sel ),
|
226 |
|
|
.o_pc_sel ( pc_sel ),
|
227 |
|
|
.o_byte_enable_sel ( byte_enable_sel ),
|
228 |
|
|
.o_status_bits_sel ( status_bits_sel ),
|
229 |
|
|
.o_reg_write_sel ( reg_write_sel ),
|
230 |
|
|
.o_user_mode_regs_load ( user_mode_regs_load ),
|
231 |
|
|
.o_user_mode_regs_store_nxt ( user_mode_regs_store_nxt ),
|
232 |
|
|
.o_firq_not_user_mode ( firq_not_user_mode ),
|
233 |
|
|
.o_write_data_wen ( write_data_wen ),
|
234 |
|
|
.o_base_address_wen ( base_address_wen ),
|
235 |
|
|
.o_pc_wen ( pc_wen ),
|
236 |
|
|
.o_reg_bank_wen ( reg_bank_wen ),
|
237 |
|
|
.o_status_bits_flags_wen ( status_bits_flags_wen ),
|
238 |
|
|
.o_status_bits_mode_wen ( status_bits_mode_wen ),
|
239 |
|
|
.o_status_bits_irq_mask_wen ( status_bits_irq_mask_wen ),
|
240 |
|
|
.o_status_bits_firq_mask_wen ( status_bits_firq_mask_wen ),
|
241 |
|
|
|
242 |
|
|
.o_copro_opcode1 ( copro_opcode1 ),
|
243 |
|
|
.o_copro_opcode2 ( copro_opcode2 ),
|
244 |
|
|
.o_copro_crn ( copro_crn ),
|
245 |
|
|
.o_copro_crm ( copro_crm ),
|
246 |
|
|
.o_copro_num ( copro_num ),
|
247 |
|
|
.o_copro_operation ( copro_operation ),
|
248 |
|
|
.o_copro_write_data_wen ( copro_write_data_wen ),
|
249 |
|
|
|
250 |
|
|
.o_iabt_trigger ( iabt_trigger ),
|
251 |
|
|
.o_iabt_address ( iabt_fault_address ),
|
252 |
|
|
.o_iabt_status ( iabt_fault_status ),
|
253 |
|
|
.o_dabt_trigger ( dabt_trigger ),
|
254 |
|
|
.o_dabt_address ( dabt_fault_address ),
|
255 |
|
|
.o_dabt_status ( dabt_fault_status )
|
256 |
|
|
);
|
257 |
|
|
|
258 |
|
|
|
259 |
15 |
csantifort |
a23_execute u_execute (
|
260 |
2 |
csantifort |
.i_clk ( i_clk ),
|
261 |
|
|
|
262 |
|
|
.i_read_data ( read_data_s2 ),
|
263 |
|
|
.i_read_data_alignment ( read_data_alignment ),
|
264 |
|
|
.i_copro_read_data ( copro_read_data ),
|
265 |
|
|
|
266 |
|
|
.o_write_data ( write_data ),
|
267 |
|
|
.o_copro_write_data ( copro_write_data ),
|
268 |
|
|
.o_address ( execute_address ),
|
269 |
|
|
.o_address_valid ( execute_address_valid ),
|
270 |
|
|
.o_address_nxt ( execute_address_nxt ),
|
271 |
|
|
.o_adex ( adex ),
|
272 |
|
|
|
273 |
|
|
.o_byte_enable ( byte_enable ),
|
274 |
|
|
.o_data_access ( data_access ),
|
275 |
|
|
.o_write_enable ( write_enable ),
|
276 |
|
|
.o_exclusive ( exclusive ),
|
277 |
|
|
.o_priviledged ( priviledged ),
|
278 |
|
|
.o_status_bits ( execute_status_bits ),
|
279 |
|
|
.o_multiply_done ( multiply_done ),
|
280 |
|
|
|
281 |
|
|
.i_fetch_stall ( fetch_stall ),
|
282 |
|
|
.i_status_bits_mode ( status_bits_mode ),
|
283 |
|
|
.i_status_bits_irq_mask ( status_bits_irq_mask ),
|
284 |
|
|
.i_status_bits_firq_mask ( status_bits_firq_mask ),
|
285 |
|
|
.i_imm32 ( imm32 ),
|
286 |
|
|
.i_imm_shift_amount ( imm_shift_amount ),
|
287 |
|
|
.i_shift_imm_zero ( shift_imm_zero ),
|
288 |
|
|
.i_condition ( condition ),
|
289 |
|
|
.i_exclusive_exec ( exclusive_exec ),
|
290 |
|
|
.i_data_access_exec ( data_access_exec ),
|
291 |
|
|
.i_rm_sel ( rm_sel ),
|
292 |
|
|
.i_rds_sel ( rds_sel ),
|
293 |
|
|
.i_rn_sel ( rn_sel ),
|
294 |
|
|
.i_barrel_shift_amount_sel ( barrel_shift_amount_sel ),
|
295 |
|
|
.i_barrel_shift_data_sel ( barrel_shift_data_sel ),
|
296 |
|
|
.i_barrel_shift_function ( barrel_shift_function ),
|
297 |
|
|
.i_alu_function ( alu_function ),
|
298 |
|
|
.i_multiply_function ( multiply_function ),
|
299 |
|
|
.i_interrupt_vector_sel ( interrupt_vector_sel ),
|
300 |
|
|
.i_address_sel ( address_sel ),
|
301 |
|
|
.i_pc_sel ( pc_sel ),
|
302 |
|
|
.i_byte_enable_sel ( byte_enable_sel ),
|
303 |
|
|
.i_status_bits_sel ( status_bits_sel ),
|
304 |
|
|
.i_reg_write_sel ( reg_write_sel ),
|
305 |
|
|
.i_user_mode_regs_load ( user_mode_regs_load ),
|
306 |
|
|
.i_user_mode_regs_store_nxt ( user_mode_regs_store_nxt ),
|
307 |
|
|
.i_firq_not_user_mode ( firq_not_user_mode ),
|
308 |
|
|
.i_write_data_wen ( write_data_wen ),
|
309 |
|
|
.i_base_address_wen ( base_address_wen ),
|
310 |
|
|
.i_pc_wen ( pc_wen ),
|
311 |
|
|
.i_reg_bank_wen ( reg_bank_wen ),
|
312 |
|
|
.i_status_bits_flags_wen ( status_bits_flags_wen ),
|
313 |
|
|
.i_status_bits_mode_wen ( status_bits_mode_wen ),
|
314 |
|
|
.i_status_bits_irq_mask_wen ( status_bits_irq_mask_wen ),
|
315 |
|
|
.i_status_bits_firq_mask_wen ( status_bits_firq_mask_wen ),
|
316 |
|
|
.i_copro_write_data_wen ( copro_write_data_wen )
|
317 |
|
|
);
|
318 |
|
|
|
319 |
|
|
|
320 |
15 |
csantifort |
a23_coprocessor u_coprocessor (
|
321 |
2 |
csantifort |
.i_clk ( i_clk ),
|
322 |
|
|
|
323 |
|
|
.i_fetch_stall ( fetch_stall ),
|
324 |
|
|
.i_copro_opcode1 ( copro_opcode1 ),
|
325 |
|
|
.i_copro_opcode2 ( copro_opcode2 ),
|
326 |
|
|
.i_copro_crn ( copro_crn ),
|
327 |
|
|
.i_copro_crm ( copro_crm ),
|
328 |
|
|
.i_copro_num ( copro_num ),
|
329 |
|
|
.i_copro_operation ( copro_operation ),
|
330 |
|
|
.i_copro_write_data ( copro_write_data ),
|
331 |
|
|
|
332 |
|
|
.i_fault ( decode_fault ),
|
333 |
|
|
.i_fault_status ( decode_fault_status ),
|
334 |
|
|
.i_fault_address ( decode_fault_address ),
|
335 |
|
|
|
336 |
|
|
.o_copro_read_data ( copro_read_data ),
|
337 |
|
|
.o_cache_enable ( cache_enable ),
|
338 |
|
|
.o_cache_flush ( cache_flush ),
|
339 |
|
|
.o_cacheable_area ( cacheable_area )
|
340 |
|
|
);
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
endmodule
|
344 |
|
|
|