Line 86... |
Line 86... |
input i_exclusive_exec, // swap access
|
input i_exclusive_exec, // swap access
|
|
|
input [3:0] i_rm_sel,
|
input [3:0] i_rm_sel,
|
input [3:0] i_rds_sel,
|
input [3:0] i_rds_sel,
|
input [3:0] i_rn_sel,
|
input [3:0] i_rn_sel,
|
|
input [3:0] i_rm_sel_nxt,
|
|
input [3:0] i_rds_sel_nxt,
|
|
input [3:0] i_rn_sel_nxt,
|
input [1:0] i_barrel_shift_amount_sel,
|
input [1:0] i_barrel_shift_amount_sel,
|
input [1:0] i_barrel_shift_data_sel,
|
input [1:0] i_barrel_shift_data_sel,
|
input [1:0] i_barrel_shift_function,
|
input [1:0] i_barrel_shift_function,
|
input [8:0] i_alu_function,
|
input [8:0] i_alu_function,
|
input [1:0] i_multiply_function,
|
input [1:0] i_multiply_function,
|
Line 100... |
Line 103... |
input [2:0] i_status_bits_sel,
|
input [2:0] i_status_bits_sel,
|
input [2:0] i_reg_write_sel,
|
input [2:0] i_reg_write_sel,
|
input i_user_mode_regs_load,
|
input i_user_mode_regs_load,
|
input i_user_mode_regs_store_nxt,
|
input i_user_mode_regs_store_nxt,
|
input i_firq_not_user_mode,
|
input i_firq_not_user_mode,
|
|
input i_firq_not_user_mode_nxt,
|
|
|
input i_write_data_wen,
|
input i_write_data_wen,
|
input i_base_address_wen, // save LDM base address register,
|
input i_base_address_wen, // save LDM base address register,
|
// in case of data abort
|
// in case of data abort
|
input i_pc_wen,
|
input i_pc_wen,
|
input [14:0] i_reg_bank_wen,
|
input [14:0] i_reg_bank_wen,
|
|
input [3:0] i_reg_bank_wsel,
|
input i_status_bits_flags_wen,
|
input i_status_bits_flags_wen,
|
input i_status_bits_mode_wen,
|
input i_status_bits_mode_wen,
|
input i_status_bits_irq_mask_wen,
|
input i_status_bits_irq_mask_wen,
|
input i_status_bits_firq_mask_wen,
|
input i_status_bits_firq_mask_wen,
|
input i_copro_write_data_wen
|
input i_copro_write_data_wen
|
Line 145... |
Line 150... |
wire barrel_shift_carry;
|
wire barrel_shift_carry;
|
|
|
wire [3:0] status_bits_flags_nxt;
|
wire [3:0] status_bits_flags_nxt;
|
reg [3:0] status_bits_flags = 'd0;
|
reg [3:0] status_bits_flags = 'd0;
|
wire [1:0] status_bits_mode_nxt;
|
wire [1:0] status_bits_mode_nxt;
|
|
wire [1:0] status_bits_mode_nr;
|
reg [1:0] status_bits_mode = SVC;
|
reg [1:0] status_bits_mode = SVC;
|
|
// raw rs select
|
|
wire [1:0] status_bits_mode_rds_nxt;
|
|
wire [1:0] status_bits_mode_rds_nr;
|
|
reg [1:0] status_bits_mode_rds;
|
// one-hot encoded rs select
|
// one-hot encoded rs select
|
wire [3:0] status_bits_mode_rds_oh_nxt;
|
wire [3:0] status_bits_mode_rds_oh_nxt;
|
reg [3:0] status_bits_mode_rds_oh = 1'd1 << OH_SVC;
|
reg [3:0] status_bits_mode_rds_oh = 1'd1 << OH_SVC;
|
wire status_bits_mode_rds_oh_update;
|
wire status_bits_mode_rds_oh_update;
|
wire status_bits_irq_mask_nxt;
|
wire status_bits_irq_mask_nxt;
|
Line 159... |
Line 169... |
|
|
wire execute; // high when condition execution is true
|
wire execute; // high when condition execution is true
|
wire [31:0] reg_write_nxt;
|
wire [31:0] reg_write_nxt;
|
wire pc_wen;
|
wire pc_wen;
|
wire [14:0] reg_bank_wen;
|
wire [14:0] reg_bank_wen;
|
|
wire [3:0] reg_bank_wsel;
|
wire [31:0] multiply_out;
|
wire [31:0] multiply_out;
|
wire [1:0] multiply_flags;
|
wire [1:0] multiply_flags;
|
reg [31:0] base_address = 'd0; // Saves base address during LDM instruction in
|
reg [31:0] base_address = 'd0; // Saves base address during LDM instruction in
|
// case of data abort
|
// case of data abort
|
|
|
Line 216... |
Line 227... |
// status_bits_mode speeds up the critical path from status_bits_mode through the
|
// status_bits_mode speeds up the critical path from status_bits_mode through the
|
// register_bank, barrel_shifter and alu. It moves a mux needed for the
|
// register_bank, barrel_shifter and alu. It moves a mux needed for the
|
// i_user_mode_regs_store_nxt signal back into the previous stage -
|
// i_user_mode_regs_store_nxt signal back into the previous stage -
|
// so its really part of the decode stage even though the logic is right here
|
// so its really part of the decode stage even though the logic is right here
|
// In addition the signal is one-hot encoded to further speed up the logic
|
// In addition the signal is one-hot encoded to further speed up the logic
|
|
// Raw version is also kept for ram-based register bank implementation.
|
|
|
assign status_bits_mode_rds_oh_nxt = i_user_mode_regs_store_nxt ? 1'd1 << OH_USR :
|
assign status_bits_mode_rds_nxt = i_user_mode_regs_store_nxt ? OH_USR :
|
status_bits_mode_update ? oh_status_bits_mode(status_bits_mode_nxt) :
|
status_bits_mode_update ? status_bits_mode_nxt :
|
oh_status_bits_mode(status_bits_mode) ;
|
status_bits_mode ;
|
|
|
|
assign status_bits_mode_rds_oh_nxt = oh_status_bits_mode(status_bits_mode_rds_nxt);
|
|
|
|
|
assign status_bits_irq_mask_nxt = i_status_bits_sel == 3'd0 ? i_status_bits_irq_mask :
|
assign status_bits_irq_mask_nxt = i_status_bits_sel == 3'd0 ? i_status_bits_irq_mask :
|
i_status_bits_sel == 3'd1 ? alu_out [27] :
|
i_status_bits_sel == 3'd1 ? alu_out [27] :
|
i_copro_read_data [27] ;
|
i_copro_read_data [27] ;
|
Line 378... |
Line 392... |
assign pc_wen = i_pc_wen || !execute;
|
assign pc_wen = i_pc_wen || !execute;
|
|
|
// only update register bank if current instruction executes
|
// only update register bank if current instruction executes
|
assign reg_bank_wen = {{15{execute}} & i_reg_bank_wen};
|
assign reg_bank_wen = {{15{execute}} & i_reg_bank_wen};
|
|
|
|
assign reg_bank_wsel = {{4{~execute}} | i_reg_bank_wsel};
|
|
|
|
|
// ========================================================
|
// ========================================================
|
// Priviledged output flag
|
// Priviledged output flag
|
// ========================================================
|
// ========================================================
|
// Need to look at status_bits_mode_nxt so switch to priviledged mode
|
// Need to look at status_bits_mode_nxt so switch to priviledged mode
|
Line 414... |
Line 430... |
assign status_bits_mode_update = !i_fetch_stall && execute && i_status_bits_mode_wen;
|
assign status_bits_mode_update = !i_fetch_stall && execute && i_status_bits_mode_wen;
|
assign status_bits_mode_rds_oh_update = !i_fetch_stall;
|
assign status_bits_mode_rds_oh_update = !i_fetch_stall;
|
assign status_bits_irq_mask_update = !i_fetch_stall && execute && i_status_bits_irq_mask_wen;
|
assign status_bits_irq_mask_update = !i_fetch_stall && execute && i_status_bits_irq_mask_wen;
|
assign status_bits_firq_mask_update = !i_fetch_stall && execute && i_status_bits_firq_mask_wen;
|
assign status_bits_firq_mask_update = !i_fetch_stall && execute && i_status_bits_firq_mask_wen;
|
|
|
|
assign status_bits_mode_rds_nr = status_bits_mode_rds_oh_update ? status_bits_mode_rds_nxt :
|
|
status_bits_mode_rds ;
|
|
|
|
assign status_bits_mode_nr = status_bits_mode_update ? status_bits_mode_nxt :
|
|
status_bits_mode ;
|
|
|
always @( posedge i_clk )
|
always @( posedge i_clk )
|
begin
|
begin
|
o_priviledged <= priviledged_update ? priviledged_nxt : o_priviledged;
|
o_priviledged <= priviledged_update ? priviledged_nxt : o_priviledged;
|
o_exclusive <= exclusive_update ? i_exclusive_exec : o_exclusive;
|
o_exclusive <= exclusive_update ? i_exclusive_exec : o_exclusive;
|
Line 431... |
Line 452... |
o_copro_write_data <= copro_write_data_update ? write_data_nxt : o_copro_write_data;
|
o_copro_write_data <= copro_write_data_update ? write_data_nxt : o_copro_write_data;
|
|
|
base_address <= base_address_update ? rn : base_address;
|
base_address <= base_address_update ? rn : base_address;
|
|
|
status_bits_flags <= status_bits_flags_update ? status_bits_flags_nxt : status_bits_flags;
|
status_bits_flags <= status_bits_flags_update ? status_bits_flags_nxt : status_bits_flags;
|
status_bits_mode <= status_bits_mode_update ? status_bits_mode_nxt : status_bits_mode;
|
status_bits_mode <= status_bits_mode_nr;
|
status_bits_mode_rds_oh <= status_bits_mode_rds_oh_update ? status_bits_mode_rds_oh_nxt : status_bits_mode_rds_oh;
|
status_bits_mode_rds_oh <= status_bits_mode_rds_oh_update ? status_bits_mode_rds_oh_nxt : status_bits_mode_rds_oh;
|
|
status_bits_mode_rds <= status_bits_mode_rds_nr;
|
status_bits_irq_mask <= status_bits_irq_mask_update ? status_bits_irq_mask_nxt : status_bits_irq_mask;
|
status_bits_irq_mask <= status_bits_irq_mask_update ? status_bits_irq_mask_nxt : status_bits_irq_mask;
|
status_bits_firq_mask <= status_bits_firq_mask_update ? status_bits_firq_mask_nxt : status_bits_firq_mask;
|
status_bits_firq_mask <= status_bits_firq_mask_update ? status_bits_firq_mask_nxt : status_bits_firq_mask;
|
end
|
end
|
|
|
|
|