| 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 |
71 |
csantifort |
wire [3:0] rm_sel_nxt;
|
| 104 |
|
|
wire [3:0] rds_sel_nxt;
|
| 105 |
|
|
wire [3:0] rn_sel_nxt;
|
| 106 |
2 |
csantifort |
wire [1:0] barrel_shift_amount_sel;
|
| 107 |
|
|
wire [1:0] barrel_shift_data_sel;
|
| 108 |
83 |
csantifort |
wire [1:0] barrel_shift_function;
|
| 109 |
|
|
wire use_carry_in;
|
| 110 |
2 |
csantifort |
wire [8:0] alu_function;
|
| 111 |
|
|
wire [1:0] multiply_function;
|
| 112 |
|
|
wire [2:0] interrupt_vector_sel;
|
| 113 |
|
|
wire [3:0] address_sel;
|
| 114 |
|
|
wire [1:0] pc_sel;
|
| 115 |
|
|
wire [1:0] byte_enable_sel;
|
| 116 |
|
|
wire [2:0] status_bits_sel;
|
| 117 |
|
|
wire [2:0] reg_write_sel;
|
| 118 |
|
|
wire user_mode_regs_load;
|
| 119 |
|
|
wire user_mode_regs_store_nxt;
|
| 120 |
|
|
wire firq_not_user_mode;
|
| 121 |
|
|
|
| 122 |
|
|
wire write_data_wen;
|
| 123 |
|
|
wire copro_write_data_wen;
|
| 124 |
|
|
wire base_address_wen;
|
| 125 |
|
|
wire pc_wen;
|
| 126 |
|
|
wire [14:0] reg_bank_wen;
|
| 127 |
71 |
csantifort |
wire [3:0] reg_bank_wsel;
|
| 128 |
2 |
csantifort |
|
| 129 |
|
|
wire [2:0] copro_opcode1;
|
| 130 |
|
|
wire [2:0] copro_opcode2;
|
| 131 |
|
|
wire [3:0] copro_crn;
|
| 132 |
|
|
wire [3:0] copro_crm;
|
| 133 |
|
|
wire [3:0] copro_num;
|
| 134 |
|
|
wire [1:0] copro_operation;
|
| 135 |
|
|
wire [31:0] copro_read_data;
|
| 136 |
|
|
wire [31:0] copro_write_data;
|
| 137 |
|
|
wire multiply_done;
|
| 138 |
|
|
|
| 139 |
|
|
wire decode_fault;
|
| 140 |
|
|
wire iabt_trigger;
|
| 141 |
|
|
wire dabt_trigger;
|
| 142 |
|
|
|
| 143 |
|
|
wire [7:0] decode_fault_status;
|
| 144 |
|
|
wire [7:0] iabt_fault_status;
|
| 145 |
|
|
wire [7:0] dabt_fault_status;
|
| 146 |
|
|
|
| 147 |
|
|
wire [31:0] decode_fault_address;
|
| 148 |
|
|
wire [31:0] iabt_fault_address;
|
| 149 |
|
|
wire [31:0] dabt_fault_address;
|
| 150 |
|
|
|
| 151 |
|
|
wire adex;
|
| 152 |
|
|
|
| 153 |
|
|
|
| 154 |
|
|
// data abort has priority
|
| 155 |
|
|
assign decode_fault_status = dabt_trigger ? dabt_fault_status : iabt_fault_status;
|
| 156 |
|
|
assign decode_fault_address = dabt_trigger ? dabt_fault_address : iabt_fault_address;
|
| 157 |
|
|
assign decode_fault = dabt_trigger | iabt_trigger;
|
| 158 |
|
|
|
| 159 |
|
|
|
| 160 |
15 |
csantifort |
a23_fetch u_fetch (
|
| 161 |
2 |
csantifort |
.i_clk ( i_clk ),
|
| 162 |
|
|
|
| 163 |
|
|
.i_address ( {execute_address[31:2], 2'd0} ),
|
| 164 |
|
|
.i_address_valid ( execute_address_valid ),
|
| 165 |
|
|
.i_address_nxt ( execute_address_nxt ),
|
| 166 |
|
|
.i_write_data ( write_data ),
|
| 167 |
|
|
.i_write_enable ( write_enable ),
|
| 168 |
|
|
.o_read_data ( read_data ),
|
| 169 |
|
|
.i_priviledged ( priviledged ),
|
| 170 |
|
|
.i_byte_enable ( byte_enable ),
|
| 171 |
|
|
.i_data_access ( data_access ),
|
| 172 |
|
|
.i_exclusive ( exclusive ),
|
| 173 |
|
|
.i_cache_enable ( cache_enable ),
|
| 174 |
|
|
.i_cache_flush ( cache_flush ),
|
| 175 |
|
|
.i_cacheable_area ( cacheable_area ),
|
| 176 |
|
|
|
| 177 |
|
|
.i_system_rdy ( i_system_rdy ),
|
| 178 |
|
|
.o_fetch_stall ( fetch_stall ),
|
| 179 |
|
|
|
| 180 |
|
|
.o_wb_adr ( o_wb_adr ),
|
| 181 |
|
|
.o_wb_sel ( o_wb_sel ),
|
| 182 |
|
|
.o_wb_we ( o_wb_we ),
|
| 183 |
|
|
.i_wb_dat ( i_wb_dat ),
|
| 184 |
|
|
.o_wb_dat ( o_wb_dat ),
|
| 185 |
|
|
.o_wb_cyc ( o_wb_cyc ),
|
| 186 |
|
|
.o_wb_stb ( o_wb_stb ),
|
| 187 |
|
|
.i_wb_ack ( i_wb_ack ),
|
| 188 |
|
|
.i_wb_err ( i_wb_err )
|
| 189 |
|
|
);
|
| 190 |
|
|
|
| 191 |
|
|
|
| 192 |
15 |
csantifort |
a23_decode u_decode (
|
| 193 |
2 |
csantifort |
.i_clk ( i_clk ),
|
| 194 |
|
|
|
| 195 |
|
|
// Instruction fetch or data read signals
|
| 196 |
|
|
.i_read_data ( read_data ),
|
| 197 |
|
|
.i_execute_address ( execute_address ),
|
| 198 |
|
|
.i_adex ( adex ),
|
| 199 |
|
|
.i_iabt ( 1'd0 ),
|
| 200 |
|
|
.i_dabt ( 1'd0 ),
|
| 201 |
|
|
.i_abt_status ( 8'd0 ),
|
| 202 |
|
|
|
| 203 |
|
|
.o_read_data ( read_data_s2 ),
|
| 204 |
|
|
.o_read_data_alignment ( read_data_alignment ),
|
| 205 |
|
|
|
| 206 |
|
|
.i_irq ( i_irq ),
|
| 207 |
|
|
.i_firq ( i_firq ),
|
| 208 |
|
|
.i_fetch_stall ( fetch_stall ),
|
| 209 |
|
|
.i_execute_status_bits ( execute_status_bits ),
|
| 210 |
|
|
.i_multiply_done ( multiply_done ),
|
| 211 |
|
|
|
| 212 |
71 |
csantifort |
.o_status_bits_mode ( status_bits_mode ),
|
| 213 |
2 |
csantifort |
.o_status_bits_irq_mask ( status_bits_irq_mask ),
|
| 214 |
|
|
.o_status_bits_firq_mask ( status_bits_firq_mask ),
|
| 215 |
|
|
.o_imm32 ( imm32 ),
|
| 216 |
|
|
.o_imm_shift_amount ( imm_shift_amount ),
|
| 217 |
|
|
.o_shift_imm_zero ( shift_imm_zero ),
|
| 218 |
|
|
.o_condition ( condition ),
|
| 219 |
|
|
.o_exclusive_exec ( exclusive_exec ),
|
| 220 |
|
|
.o_data_access_exec ( data_access_exec ),
|
| 221 |
|
|
.o_rm_sel ( rm_sel ),
|
| 222 |
|
|
.o_rds_sel ( rds_sel ),
|
| 223 |
|
|
.o_rn_sel ( rn_sel ),
|
| 224 |
71 |
csantifort |
.o_rm_sel_nxt ( rm_sel_nxt ),
|
| 225 |
|
|
.o_rds_sel_nxt ( rds_sel_nxt ),
|
| 226 |
|
|
.o_rn_sel_nxt ( rn_sel_nxt ),
|
| 227 |
2 |
csantifort |
.o_barrel_shift_amount_sel ( barrel_shift_amount_sel ),
|
| 228 |
|
|
.o_barrel_shift_data_sel ( barrel_shift_data_sel ),
|
| 229 |
|
|
.o_barrel_shift_function ( barrel_shift_function ),
|
| 230 |
83 |
csantifort |
.o_use_carry_in ( use_carry_in ),
|
| 231 |
2 |
csantifort |
.o_alu_function ( alu_function ),
|
| 232 |
|
|
.o_multiply_function ( multiply_function ),
|
| 233 |
|
|
.o_interrupt_vector_sel ( interrupt_vector_sel ),
|
| 234 |
|
|
.o_address_sel ( address_sel ),
|
| 235 |
|
|
.o_pc_sel ( pc_sel ),
|
| 236 |
|
|
.o_byte_enable_sel ( byte_enable_sel ),
|
| 237 |
|
|
.o_status_bits_sel ( status_bits_sel ),
|
| 238 |
|
|
.o_reg_write_sel ( reg_write_sel ),
|
| 239 |
|
|
.o_user_mode_regs_load ( user_mode_regs_load ),
|
| 240 |
|
|
.o_user_mode_regs_store_nxt ( user_mode_regs_store_nxt ),
|
| 241 |
|
|
.o_firq_not_user_mode ( firq_not_user_mode ),
|
| 242 |
|
|
.o_write_data_wen ( write_data_wen ),
|
| 243 |
|
|
.o_base_address_wen ( base_address_wen ),
|
| 244 |
|
|
.o_pc_wen ( pc_wen ),
|
| 245 |
|
|
.o_reg_bank_wen ( reg_bank_wen ),
|
| 246 |
71 |
csantifort |
.o_reg_bank_wsel ( reg_bank_wsel ),
|
| 247 |
2 |
csantifort |
.o_status_bits_flags_wen ( status_bits_flags_wen ),
|
| 248 |
|
|
.o_status_bits_mode_wen ( status_bits_mode_wen ),
|
| 249 |
|
|
.o_status_bits_irq_mask_wen ( status_bits_irq_mask_wen ),
|
| 250 |
|
|
.o_status_bits_firq_mask_wen ( status_bits_firq_mask_wen ),
|
| 251 |
|
|
|
| 252 |
|
|
.o_copro_opcode1 ( copro_opcode1 ),
|
| 253 |
|
|
.o_copro_opcode2 ( copro_opcode2 ),
|
| 254 |
|
|
.o_copro_crn ( copro_crn ),
|
| 255 |
|
|
.o_copro_crm ( copro_crm ),
|
| 256 |
|
|
.o_copro_num ( copro_num ),
|
| 257 |
|
|
.o_copro_operation ( copro_operation ),
|
| 258 |
|
|
.o_copro_write_data_wen ( copro_write_data_wen ),
|
| 259 |
|
|
|
| 260 |
|
|
.o_iabt_trigger ( iabt_trigger ),
|
| 261 |
|
|
.o_iabt_address ( iabt_fault_address ),
|
| 262 |
|
|
.o_iabt_status ( iabt_fault_status ),
|
| 263 |
|
|
.o_dabt_trigger ( dabt_trigger ),
|
| 264 |
|
|
.o_dabt_address ( dabt_fault_address ),
|
| 265 |
|
|
.o_dabt_status ( dabt_fault_status )
|
| 266 |
|
|
);
|
| 267 |
|
|
|
| 268 |
|
|
|
| 269 |
15 |
csantifort |
a23_execute u_execute (
|
| 270 |
2 |
csantifort |
.i_clk ( i_clk ),
|
| 271 |
|
|
|
| 272 |
|
|
.i_read_data ( read_data_s2 ),
|
| 273 |
|
|
.i_read_data_alignment ( read_data_alignment ),
|
| 274 |
|
|
.i_copro_read_data ( copro_read_data ),
|
| 275 |
|
|
|
| 276 |
|
|
.o_write_data ( write_data ),
|
| 277 |
|
|
.o_copro_write_data ( copro_write_data ),
|
| 278 |
|
|
.o_address ( execute_address ),
|
| 279 |
|
|
.o_address_valid ( execute_address_valid ),
|
| 280 |
|
|
.o_address_nxt ( execute_address_nxt ),
|
| 281 |
|
|
.o_adex ( adex ),
|
| 282 |
|
|
|
| 283 |
|
|
.o_byte_enable ( byte_enable ),
|
| 284 |
|
|
.o_data_access ( data_access ),
|
| 285 |
|
|
.o_write_enable ( write_enable ),
|
| 286 |
|
|
.o_exclusive ( exclusive ),
|
| 287 |
|
|
.o_priviledged ( priviledged ),
|
| 288 |
|
|
.o_status_bits ( execute_status_bits ),
|
| 289 |
|
|
.o_multiply_done ( multiply_done ),
|
| 290 |
|
|
|
| 291 |
|
|
.i_fetch_stall ( fetch_stall ),
|
| 292 |
|
|
.i_status_bits_mode ( status_bits_mode ),
|
| 293 |
|
|
.i_status_bits_irq_mask ( status_bits_irq_mask ),
|
| 294 |
|
|
.i_status_bits_firq_mask ( status_bits_firq_mask ),
|
| 295 |
|
|
.i_imm32 ( imm32 ),
|
| 296 |
|
|
.i_imm_shift_amount ( imm_shift_amount ),
|
| 297 |
|
|
.i_shift_imm_zero ( shift_imm_zero ),
|
| 298 |
|
|
.i_condition ( condition ),
|
| 299 |
|
|
.i_exclusive_exec ( exclusive_exec ),
|
| 300 |
|
|
.i_data_access_exec ( data_access_exec ),
|
| 301 |
|
|
.i_rm_sel ( rm_sel ),
|
| 302 |
|
|
.i_rds_sel ( rds_sel ),
|
| 303 |
|
|
.i_rn_sel ( rn_sel ),
|
| 304 |
71 |
csantifort |
.i_rm_sel_nxt ( rm_sel_nxt ),
|
| 305 |
|
|
.i_rds_sel_nxt ( rds_sel_nxt ),
|
| 306 |
|
|
.i_rn_sel_nxt ( rn_sel_nxt ),
|
| 307 |
2 |
csantifort |
.i_barrel_shift_amount_sel ( barrel_shift_amount_sel ),
|
| 308 |
|
|
.i_barrel_shift_data_sel ( barrel_shift_data_sel ),
|
| 309 |
|
|
.i_barrel_shift_function ( barrel_shift_function ),
|
| 310 |
83 |
csantifort |
.i_use_carry_in ( use_carry_in ),
|
| 311 |
2 |
csantifort |
.i_alu_function ( alu_function ),
|
| 312 |
|
|
.i_multiply_function ( multiply_function ),
|
| 313 |
|
|
.i_interrupt_vector_sel ( interrupt_vector_sel ),
|
| 314 |
|
|
.i_address_sel ( address_sel ),
|
| 315 |
|
|
.i_pc_sel ( pc_sel ),
|
| 316 |
|
|
.i_byte_enable_sel ( byte_enable_sel ),
|
| 317 |
|
|
.i_status_bits_sel ( status_bits_sel ),
|
| 318 |
|
|
.i_reg_write_sel ( reg_write_sel ),
|
| 319 |
|
|
.i_user_mode_regs_load ( user_mode_regs_load ),
|
| 320 |
|
|
.i_user_mode_regs_store_nxt ( user_mode_regs_store_nxt ),
|
| 321 |
|
|
.i_firq_not_user_mode ( firq_not_user_mode ),
|
| 322 |
|
|
.i_write_data_wen ( write_data_wen ),
|
| 323 |
|
|
.i_base_address_wen ( base_address_wen ),
|
| 324 |
|
|
.i_pc_wen ( pc_wen ),
|
| 325 |
|
|
.i_reg_bank_wen ( reg_bank_wen ),
|
| 326 |
71 |
csantifort |
.i_reg_bank_wsel ( reg_bank_wsel ),
|
| 327 |
2 |
csantifort |
.i_status_bits_flags_wen ( status_bits_flags_wen ),
|
| 328 |
|
|
.i_status_bits_mode_wen ( status_bits_mode_wen ),
|
| 329 |
|
|
.i_status_bits_irq_mask_wen ( status_bits_irq_mask_wen ),
|
| 330 |
|
|
.i_status_bits_firq_mask_wen ( status_bits_firq_mask_wen ),
|
| 331 |
|
|
.i_copro_write_data_wen ( copro_write_data_wen )
|
| 332 |
|
|
);
|
| 333 |
|
|
|
| 334 |
|
|
|
| 335 |
15 |
csantifort |
a23_coprocessor u_coprocessor (
|
| 336 |
2 |
csantifort |
.i_clk ( i_clk ),
|
| 337 |
|
|
|
| 338 |
|
|
.i_fetch_stall ( fetch_stall ),
|
| 339 |
|
|
.i_copro_opcode1 ( copro_opcode1 ),
|
| 340 |
|
|
.i_copro_opcode2 ( copro_opcode2 ),
|
| 341 |
|
|
.i_copro_crn ( copro_crn ),
|
| 342 |
|
|
.i_copro_crm ( copro_crm ),
|
| 343 |
|
|
.i_copro_num ( copro_num ),
|
| 344 |
|
|
.i_copro_operation ( copro_operation ),
|
| 345 |
|
|
.i_copro_write_data ( copro_write_data ),
|
| 346 |
|
|
|
| 347 |
|
|
.i_fault ( decode_fault ),
|
| 348 |
|
|
.i_fault_status ( decode_fault_status ),
|
| 349 |
|
|
.i_fault_address ( decode_fault_address ),
|
| 350 |
|
|
|
| 351 |
|
|
.o_copro_read_data ( copro_read_data ),
|
| 352 |
|
|
.o_cache_enable ( cache_enable ),
|
| 353 |
|
|
.o_cache_flush ( cache_flush ),
|
| 354 |
|
|
.o_cacheable_area ( cacheable_area )
|
| 355 |
|
|
);
|
| 356 |
|
|
|
| 357 |
|
|
|
| 358 |
|
|
endmodule
|
| 359 |
|
|
|