Skip to content

Commit

Permalink
Merge pull request #582 from davideschiavone/alu_opcode_enum
Browse files Browse the repository at this point in the history
🎨 changing to enumerator for alu opcodes
  • Loading branch information
davideschiavone authored Nov 17, 2020
2 parents 83aaecc + 1c6c786 commit 2b7cd10
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 104 deletions.
2 changes: 1 addition & 1 deletion rtl/cv32e40p_alu.sv
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module cv32e40p_alu import cv32e40p_pkg::*;
input logic clk,
input logic rst_n,
input logic enable_i,
input logic [ALU_OP_WIDTH-1:0] operator_i,
input alu_opcode_e operator_i,
input logic [31:0] operand_a_i,
input logic [31:0] operand_b_i,
input logic [31:0] operand_c_i,
Expand Down
8 changes: 4 additions & 4 deletions rtl/cv32e40p_core.sv
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ module cv32e40p_core import cv32e40p_apu_core_pkg::*;

// ALU Control
logic alu_en_ex;
logic [ALU_OP_WIDTH-1:0] alu_operator_ex;
alu_opcode_e alu_operator_ex;
logic [31:0] alu_operand_a_ex;
logic [31:0] alu_operand_b_ex;
logic [31:0] alu_operand_c_ex;
Expand All @@ -180,7 +180,7 @@ module cv32e40p_core import cv32e40p_apu_core_pkg::*;
logic [ 1:0] alu_clpx_shift_ex;

// Multiplier Control
logic [ 2:0] mult_operator_ex;
mul_opcode_e mult_operator_ex;
logic [31:0] mult_operand_a_ex;
logic [31:0] mult_operand_b_ex;
logic [31:0] mult_operand_c_ex;
Expand Down Expand Up @@ -237,12 +237,12 @@ module cv32e40p_core import cv32e40p_apu_core_pkg::*;

// CSR control
logic csr_access_ex;
logic [1:0] csr_op_ex;
csr_opcode_e csr_op_ex;
logic [23:0] mtvec, utvec;
logic [1:0] mtvec_mode;
logic [1:0] utvec_mode;

logic [1:0] csr_op;
csr_opcode_e csr_op;
csr_num_e csr_addr;
csr_num_e csr_addr_int;
logic [31:0] csr_rdata;
Expand Down
12 changes: 6 additions & 6 deletions rtl/cv32e40p_cs_registers.sv
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ module cv32e40p_cs_registers import cv32e40p_pkg::*;
input logic csr_mtvec_init_i,

// Interface to registers (SRAM like)
input csr_num_e csr_addr_i,
input logic [31:0] csr_wdata_i,
input logic [1:0] csr_op_i,
output logic [31:0] csr_rdata_o,
input csr_num_e csr_addr_i,
input logic [31:0] csr_wdata_i,
input csr_opcode_e csr_op_i,
output logic [31:0] csr_rdata_o,

output logic [2:0] frm_o,
input logic [C_FFLAG-1:0] fflags_i,
Expand Down Expand Up @@ -1473,7 +1473,7 @@ end //PULP_SECURE
end else if( (wcnt_gidx>2) && (wcnt_gidx<(NUM_MHPMCOUNTERS+3))) begin : gen_mhpmcounter
// add +1 if any event is enabled and active
assign mhpmcounter_write_increment[wcnt_gidx] = !mhpmcounter_write_lower[wcnt_gidx] &&
!mhpmcounter_write_upper[wcnt_gidx] &&
!mhpmcounter_write_upper[wcnt_gidx] &&
!mcountinhibit_q[wcnt_gidx] &&
|(hpm_events & mhpmevent_q[wcnt_gidx][NUM_HPM_EVENTS-1:0]);
end else begin : gen_mhpmcounter_not_implemented
Expand All @@ -1482,7 +1482,7 @@ end //PULP_SECURE
end else begin : gen_pulp_perf_counters
// PULP PERF COUNTERS share all events in one register (not compliant with RISC-V)
assign mhpmcounter_write_increment[wcnt_gidx] = !mhpmcounter_write_lower[wcnt_gidx] &&
!mhpmcounter_write_upper[wcnt_gidx] &&
!mhpmcounter_write_upper[wcnt_gidx] &&
!mcountinhibit_q[wcnt_gidx] &&
|(hpm_events & mhpmevent_q[wcnt_gidx][NUM_HPM_EVENTS-1:0]);
end
Expand Down
8 changes: 4 additions & 4 deletions rtl/cv32e40p_decoder.sv
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module cv32e40p_decoder import cv32e40p_pkg::*; import cv32e40p_apu_core_pkg::*;

// ALU signals
output logic alu_en_o, // ALU enable
output logic [ALU_OP_WIDTH-1:0] alu_operator_o, // ALU operation selection
output alu_opcode_e alu_operator_o, // ALU operation selection
output logic [2:0] alu_op_a_mux_sel_o, // operand a selection: reg value, PC, immediate or zero
output logic [2:0] alu_op_b_mux_sel_o, // operand b selection: reg value or immediate
output logic [1:0] alu_op_c_mux_sel_o, // operand c selection: reg value or jump target
Expand All @@ -90,7 +90,7 @@ module cv32e40p_decoder import cv32e40p_pkg::*; import cv32e40p_apu_core_pkg::*;
output logic is_subrot_o,

// MUL related control signals
output logic [2:0] mult_operator_o, // Multiplication operation selection
output mul_opcode_e mult_operator_o, // Multiplication operation selection
output logic mult_int_en_o, // perform integer multiplication
output logic mult_dot_en_o, // perform dot multiplication
output logic [0:0] mult_imm_mux_o, // Multiplication immediate mux selector
Expand Down Expand Up @@ -120,7 +120,7 @@ module cv32e40p_decoder import cv32e40p_pkg::*; import cv32e40p_apu_core_pkg::*;
// CSR manipulation
output logic csr_access_o, // access to CSR
output logic csr_status_o, // access to xstatus CSR
output logic [1:0] csr_op_o, // operation to perform on CSR
output csr_opcode_e csr_op_o, // operation to perform on CSR
input PrivLvl_t current_priv_lvl_i, // The current privilege level

// LD/ST unit signals
Expand Down Expand Up @@ -161,7 +161,7 @@ module cv32e40p_decoder import cv32e40p_pkg::*; import cv32e40p_apu_core_pkg::*;
logic csr_illegal;
logic [1:0] ctrl_transfer_insn;

logic [1:0] csr_op;
csr_opcode_e csr_op;

logic alu_en;
logic mult_int_en;
Expand Down
4 changes: 2 additions & 2 deletions rtl/cv32e40p_ex_stage.sv
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module cv32e40p_ex_stage import cv32e40p_pkg::*; import cv32e40p_apu_core_pkg::*
input logic rst_n,

// ALU signals from ID stage
input logic [ALU_OP_WIDTH-1:0] alu_operator_i,
input alu_opcode_e alu_operator_i,
input logic [31:0] alu_operand_a_i,
input logic [31:0] alu_operand_b_i,
input logic [31:0] alu_operand_c_i,
Expand All @@ -56,7 +56,7 @@ module cv32e40p_ex_stage import cv32e40p_pkg::*; import cv32e40p_apu_core_pkg::*
input logic [ 1:0] alu_clpx_shift_i,

// Multiplier signals
input logic [ 2:0] mult_operator_i,
input mul_opcode_e mult_operator_i,
input logic [31:0] mult_operand_a_i,
input logic [31:0] mult_operand_b_i,
input logic [31:0] mult_operand_c_i,
Expand Down
28 changes: 14 additions & 14 deletions rtl/cv32e40p_id_stage.sv
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,20 @@ module cv32e40p_id_stage import cv32e40p_pkg::*; import cv32e40p_apu_core_pkg::*

// ALU
output logic alu_en_ex_o,
output logic [ALU_OP_WIDTH-1:0] alu_operator_ex_o,
output alu_opcode_e alu_operator_ex_o,
output logic alu_is_clpx_ex_o,
output logic alu_is_subrot_ex_o,
output logic [ 1:0] alu_clpx_shift_ex_o,

// MUL
output logic [ 2:0] mult_operator_ex_o,
output logic [31:0] mult_operand_a_ex_o,
output logic [31:0] mult_operand_b_ex_o,
output logic [31:0] mult_operand_c_ex_o,
output logic mult_en_ex_o,
output logic mult_sel_subword_ex_o,
output logic [ 1:0] mult_signed_mode_ex_o,
output logic [ 4:0] mult_imm_ex_o,
output mul_opcode_e mult_operator_ex_o,
output logic [31:0] mult_operand_a_ex_o,
output logic [31:0] mult_operand_b_ex_o,
output logic [31:0] mult_operand_c_ex_o,
output logic mult_en_ex_o,
output logic mult_sel_subword_ex_o,
output logic [ 1:0] mult_signed_mode_ex_o,
output logic [ 4:0] mult_imm_ex_o,

output logic [31:0] mult_dot_op_a_ex_o,
output logic [31:0] mult_dot_op_b_ex_o,
Expand Down Expand Up @@ -152,7 +152,7 @@ module cv32e40p_id_stage import cv32e40p_pkg::*; import cv32e40p_apu_core_pkg::*

// CSR ID/EX
output logic csr_access_ex_o,
output logic [1:0] csr_op_ex_o,
output csr_opcode_e csr_op_ex_o,
input PrivLvl_t current_priv_lvl_i,
output logic csr_irq_sec_o,
output logic [5:0] csr_cause_o,
Expand Down Expand Up @@ -350,7 +350,7 @@ module cv32e40p_id_stage import cv32e40p_pkg::*; import cv32e40p_apu_core_pkg::*

// ALU Control
logic alu_en;
logic [ALU_OP_WIDTH-1:0] alu_operator;
alu_opcode_e alu_operator;
logic [2:0] alu_op_a_mux_sel;
logic [2:0] alu_op_b_mux_sel;
logic [1:0] alu_op_c_mux_sel;
Expand All @@ -361,7 +361,7 @@ module cv32e40p_id_stage import cv32e40p_pkg::*; import cv32e40p_apu_core_pkg::*
logic [1:0] ctrl_transfer_target_mux_sel;

// Multiplier Control
logic [2:0] mult_operator; // multiplication operation selection
mul_opcode_e mult_operator; // multiplication operation selection
logic mult_en; // multiplication is used instead of ALU
logic mult_int_en; // use integer multiplier
logic mult_sel_subword; // Select a subword when doing multiplications
Expand Down Expand Up @@ -421,7 +421,7 @@ module cv32e40p_id_stage import cv32e40p_pkg::*; import cv32e40p_apu_core_pkg::*

// CSR control
logic csr_access;
logic [1:0] csr_op;
csr_opcode_e csr_op;
logic csr_status;

logic prepost_useincr;
Expand Down Expand Up @@ -1429,7 +1429,7 @@ module cv32e40p_id_stage import cv32e40p_pkg::*; import cv32e40p_apu_core_pkg::*
alu_is_clpx_ex_o <= 1'b0;
alu_is_subrot_ex_o <= 1'b0;

mult_operator_ex_o <= '0;
mult_operator_ex_o <= MUL_MAC32;
mult_operand_a_ex_o <= '0;
mult_operand_b_ex_o <= '0;
mult_operand_c_ex_o <= '0;
Expand Down
4 changes: 2 additions & 2 deletions rtl/cv32e40p_mult.sv
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
// //
////////////////////////////////////////////////////////////////////////////////

module cv32e40p_mult
module cv32e40p_mult import cv32e40p_pkg::*;
(
input logic clk,
input logic rst_n,

input logic enable_i,
input logic [ 2:0] operator_i,
input mul_opcode_e operator_i,

// integer and short multiplier
input logic short_subword_i,
Expand Down
Loading

0 comments on commit 2b7cd10

Please sign in to comment.