mirror of
https://github.com/lowRISC/ibex.git
synced 2025-04-22 04:47:25 -04:00
[RTL] Add MultiplierImplementation parameter in top level
This commit is contained in:
parent
c89e431937
commit
294849bb18
6 changed files with 101 additions and 83 deletions
|
@ -12,15 +12,16 @@ Instantiation Template
|
|||
.. code-block:: verilog
|
||||
|
||||
ibex_core #(
|
||||
.PMPEnable (0),
|
||||
.PMPGranularity (0),
|
||||
.PMPNumRegions (4),
|
||||
.MHPMCounterNum (0),
|
||||
.MHPMCounterWidth (40),
|
||||
.RV32E (0),
|
||||
.RV32M (1),
|
||||
.DmHaltAddr (32'h1A110800),
|
||||
.DmExceptionAddr (32'h1A110808)
|
||||
.PMPEnable ( 0 ),
|
||||
.PMPGranularity ( 0 ),
|
||||
.PMPNumRegions ( 4 ),
|
||||
.MHPMCounterNum ( 0 ),
|
||||
.MHPMCounterWidth ( 40 ),
|
||||
.RV32E ( 0 ),
|
||||
.RV32M ( 1 ),
|
||||
.MultiplierImplementation ( "fast" ),
|
||||
.DmHaltAddr ( 32'h1A110800 ),
|
||||
.DmExceptionAddr ( 32'h1A110808 )
|
||||
) u_core (
|
||||
// Clock and reset
|
||||
.clk_i (),
|
||||
|
@ -68,27 +69,29 @@ Instantiation Template
|
|||
Parameters
|
||||
----------
|
||||
|
||||
+-----------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| Name | Type/Range | Default | Description |
|
||||
+=======================+=============+============+=================================================================+
|
||||
| ``PMPEnable`` | bit | 0 | Enable PMP support |
|
||||
+-----------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``PMPGranularity`` | int (0..31) | 0 | Minimum granularity of PMP address matching |
|
||||
+-----------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``PMPNumRegions`` | int (1..16) | 4 | Number implemented PMP regions (ignored if PMPEnable == 0) |
|
||||
+-----------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``MHPMCounterNum`` | int (0..8) | 0 | Number of performance monitor event counters |
|
||||
+-----------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``MHPMCounterWidth`` | int (64..1) | 40 | Bit width of performance monitor event counters |
|
||||
+-----------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``RV32E`` | bit | 0 | RV32E mode enable (16 integer registers only) |
|
||||
+-----------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``RV32M`` | bit | 1 | M(ultiply) extension enable |
|
||||
+-----------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``DmHaltAddr`` | int | 0x1A110800 | Address to jump to when entering debug mode |
|
||||
+-----------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``DmExceptionAddr`` | int | 0x1A110808 | Address to jump to when an exception occurs while in debug mode |
|
||||
+-----------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
+------------------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| Name | Type/Range | Default | Description |
|
||||
+==============================+=============+============+=================================================================+
|
||||
| ``PMPEnable`` | bit | 0 | Enable PMP support |
|
||||
+------------------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``PMPGranularity`` | int (0..31) | 0 | Minimum granularity of PMP address matching |
|
||||
+------------------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``PMPNumRegions`` | int (1..16) | 4 | Number implemented PMP regions (ignored if PMPEnable == 0) |
|
||||
+------------------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``MHPMCounterNum`` | int (0..8) | 0 | Number of performance monitor event counters |
|
||||
+------------------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``MHPMCounterWidth`` | int (64..1) | 40 | Bit width of performance monitor event counters |
|
||||
+------------------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``RV32E`` | bit | 0 | RV32E mode enable (16 integer registers only) |
|
||||
+------------------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``RV32M`` | bit | 1 | M(ultiply) extension enable |
|
||||
+------------------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``MultiplierImplementation`` | string | "fast" | Multiplicator type, "slow", or "fast" |
|
||||
+------------------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``DmHaltAddr`` | int | 0x1A110800 | Address to jump to when entering debug mode |
|
||||
+------------------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
| ``DmExceptionAddr`` | int | 0x1A110808 | Address to jump to when an exception occurs while in debug mode |
|
||||
+------------------------------+-------------+------------+-----------------------------------------------------------------+
|
||||
|
||||
Interfaces
|
||||
----------
|
||||
|
|
|
@ -54,6 +54,12 @@ parameters:
|
|||
datatype: bool
|
||||
paramtype: vlogparam
|
||||
|
||||
MultiplierImplementation:
|
||||
datatype: str
|
||||
paramtype: vlogparam
|
||||
description: "Multiplier implementation. Valid values: fast, slow"
|
||||
default: fast
|
||||
|
||||
targets:
|
||||
default:
|
||||
filesets:
|
||||
|
|
|
@ -40,6 +40,12 @@ parameters:
|
|||
datatype: bool
|
||||
paramtype: vlogparam
|
||||
|
||||
MultiplierImplementation:
|
||||
datatype: str
|
||||
paramtype: vlogparam
|
||||
description: "Multiplier implementation. Valid values: fast, slow"
|
||||
default: fast
|
||||
|
||||
|
||||
|
||||
targets:
|
||||
|
|
|
@ -11,15 +11,16 @@
|
|||
* Top level module of the ibex RISC-V core
|
||||
*/
|
||||
module ibex_core #(
|
||||
parameter bit PMPEnable = 1'b0,
|
||||
parameter int unsigned PMPGranularity = 0,
|
||||
parameter int unsigned PMPNumRegions = 4,
|
||||
parameter int unsigned MHPMCounterNum = 0,
|
||||
parameter int unsigned MHPMCounterWidth = 40,
|
||||
parameter bit RV32E = 1'b0,
|
||||
parameter bit RV32M = 1'b1,
|
||||
parameter int unsigned DmHaltAddr = 32'h1A110800,
|
||||
parameter int unsigned DmExceptionAddr = 32'h1A110808
|
||||
parameter bit PMPEnable = 1'b0,
|
||||
parameter int unsigned PMPGranularity = 0,
|
||||
parameter int unsigned PMPNumRegions = 4,
|
||||
parameter int unsigned MHPMCounterNum = 0,
|
||||
parameter int unsigned MHPMCounterWidth = 40,
|
||||
parameter bit RV32E = 1'b0,
|
||||
parameter bit RV32M = 1'b1,
|
||||
parameter string MultiplierImplementation = "fast",
|
||||
parameter int unsigned DmHaltAddr = 32'h1A110800,
|
||||
parameter int unsigned DmExceptionAddr = 32'h1A110808
|
||||
) (
|
||||
// Clock and Reset
|
||||
input logic clk_i,
|
||||
|
@ -478,32 +479,33 @@ module ibex_core #(
|
|||
assign unused_illegal_insn_id = illegal_insn_id;
|
||||
|
||||
ibex_ex_block #(
|
||||
.RV32M ( RV32M )
|
||||
.RV32M ( RV32M ),
|
||||
.MultiplierImplementation ( MultiplierImplementation )
|
||||
) ex_block_i (
|
||||
.clk_i ( clk ),
|
||||
.rst_ni ( rst_ni ),
|
||||
.clk_i ( clk ),
|
||||
.rst_ni ( rst_ni ),
|
||||
|
||||
// ALU signal from ID stage
|
||||
.alu_operator_i ( alu_operator_ex ),
|
||||
.alu_operand_a_i ( alu_operand_a_ex ),
|
||||
.alu_operand_b_i ( alu_operand_b_ex ),
|
||||
.alu_operator_i ( alu_operator_ex ),
|
||||
.alu_operand_a_i ( alu_operand_a_ex ),
|
||||
.alu_operand_b_i ( alu_operand_b_ex ),
|
||||
|
||||
// Multipler/Divider signal from ID stage
|
||||
.multdiv_operator_i ( multdiv_operator_ex ),
|
||||
.mult_en_i ( mult_en_ex ),
|
||||
.div_en_i ( div_en_ex ),
|
||||
.multdiv_signed_mode_i ( multdiv_signed_mode_ex ),
|
||||
.multdiv_operand_a_i ( multdiv_operand_a_ex ),
|
||||
.multdiv_operand_b_i ( multdiv_operand_b_ex ),
|
||||
.multdiv_operator_i ( multdiv_operator_ex ),
|
||||
.mult_en_i ( mult_en_ex ),
|
||||
.div_en_i ( div_en_ex ),
|
||||
.multdiv_signed_mode_i ( multdiv_signed_mode_ex ),
|
||||
.multdiv_operand_a_i ( multdiv_operand_a_ex ),
|
||||
.multdiv_operand_b_i ( multdiv_operand_b_ex ),
|
||||
|
||||
// Outputs
|
||||
.alu_adder_result_ex_o ( alu_adder_result_ex ), // to LSU
|
||||
.regfile_wdata_ex_o ( regfile_wdata_ex ), // to ID
|
||||
.alu_adder_result_ex_o ( alu_adder_result_ex ), // to LSU
|
||||
.regfile_wdata_ex_o ( regfile_wdata_ex ), // to ID
|
||||
|
||||
.jump_target_o ( jump_target_ex ), // to IF
|
||||
.branch_decision_o ( branch_decision ), // to ID
|
||||
.jump_target_o ( jump_target_ex ), // to IF
|
||||
.branch_decision_o ( branch_decision ), // to ID
|
||||
|
||||
.ex_valid_o ( ex_valid )
|
||||
.ex_valid_o ( ex_valid )
|
||||
);
|
||||
|
||||
/////////////////////
|
||||
|
|
|
@ -7,15 +7,16 @@
|
|||
* Top level module of the ibex RISC-V core with tracing enabled
|
||||
*/
|
||||
module ibex_core_tracing #(
|
||||
parameter bit PMPEnable = 1'b0,
|
||||
parameter int unsigned PMPGranularity = 0,
|
||||
parameter int unsigned PMPNumRegions = 4,
|
||||
parameter int unsigned MHPMCounterNum = 8,
|
||||
parameter int unsigned MHPMCounterWidth = 40,
|
||||
parameter bit RV32E = 1'b0,
|
||||
parameter bit RV32M = 1'b1,
|
||||
parameter int unsigned DmHaltAddr = 32'h1A110800,
|
||||
parameter int unsigned DmExceptionAddr = 32'h1A110808
|
||||
parameter bit PMPEnable = 1'b0,
|
||||
parameter int unsigned PMPGranularity = 0,
|
||||
parameter int unsigned PMPNumRegions = 4,
|
||||
parameter int unsigned MHPMCounterNum = 8,
|
||||
parameter int unsigned MHPMCounterWidth = 40,
|
||||
parameter bit RV32E = 1'b0,
|
||||
parameter bit RV32M = 1'b1,
|
||||
parameter string MultiplierImplementation = "fast",
|
||||
parameter int unsigned DmHaltAddr = 32'h1A110800,
|
||||
parameter int unsigned DmExceptionAddr = 32'h1A110808
|
||||
) (
|
||||
// Clock and Reset
|
||||
input logic clk_i,
|
||||
|
@ -90,15 +91,16 @@ module ibex_core_tracing #(
|
|||
logic [31:0] rvfi_mem_wdata;
|
||||
|
||||
ibex_core #(
|
||||
.PMPEnable(PMPEnable),
|
||||
.PMPGranularity(PMPGranularity),
|
||||
.PMPNumRegions(PMPNumRegions),
|
||||
.MHPMCounterNum(MHPMCounterNum),
|
||||
.MHPMCounterWidth(MHPMCounterWidth),
|
||||
.RV32E(RV32E),
|
||||
.RV32M(RV32M),
|
||||
.DmHaltAddr(DmHaltAddr),
|
||||
.DmExceptionAddr(DmExceptionAddr)
|
||||
.PMPEnable ( PMPEnable ),
|
||||
.PMPGranularity ( PMPGranularity ),
|
||||
.PMPNumRegions ( PMPNumRegions ),
|
||||
.MHPMCounterNum ( MHPMCounterNum ),
|
||||
.MHPMCounterWidth ( MHPMCounterWidth ),
|
||||
.RV32E ( RV32E ),
|
||||
.RV32M ( RV32M ),
|
||||
.MultiplierImplementation ( MultiplierImplementation ),
|
||||
.DmHaltAddr ( DmHaltAddr ),
|
||||
.DmExceptionAddr ( DmExceptionAddr )
|
||||
) u_ibex_core (
|
||||
.clk_i,
|
||||
.rst_ni,
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
* Execution block: Hosts ALU and MUL/DIV unit
|
||||
*/
|
||||
module ibex_ex_block #(
|
||||
parameter bit RV32M = 1
|
||||
parameter bit RV32M = 1,
|
||||
parameter string MultiplierImplementation = "fast"
|
||||
) (
|
||||
input logic clk_i,
|
||||
input logic rst_ni,
|
||||
|
@ -38,8 +39,6 @@ module ibex_ex_block #(
|
|||
|
||||
import ibex_pkg::*;
|
||||
|
||||
localparam bit MULT_TYPE = 1; // 0 -> SLOW, 1 -> FAST
|
||||
|
||||
logic [31:0] alu_result, multdiv_result;
|
||||
|
||||
logic [32:0] multdiv_alu_operand_b, multdiv_alu_operand_a;
|
||||
|
@ -54,11 +53,11 @@ module ibex_ex_block #(
|
|||
from the multdiv_i module are eliminated
|
||||
*/
|
||||
if (RV32M) begin : gen_multdiv_m
|
||||
assign multdiv_en_sel = MULT_TYPE ? div_en_i : mult_en_i | div_en_i;
|
||||
assign multdiv_en = mult_en_i | div_en_i;
|
||||
assign multdiv_en_sel = MultiplierImplementation == "fast" ? div_en_i : mult_en_i | div_en_i;
|
||||
assign multdiv_en = mult_en_i | div_en_i;
|
||||
end else begin : gen_multdiv_no_m
|
||||
assign multdiv_en_sel = 1'b0;
|
||||
assign multdiv_en = 1'b0;
|
||||
assign multdiv_en_sel = 1'b0;
|
||||
assign multdiv_en = 1'b0;
|
||||
end
|
||||
|
||||
assign regfile_wdata_ex_o = multdiv_en ? multdiv_result : alu_result;
|
||||
|
@ -89,7 +88,7 @@ module ibex_ex_block #(
|
|||
// Multiplier //
|
||||
////////////////
|
||||
|
||||
if (!MULT_TYPE) begin : gen_multdiv_slow
|
||||
if (MultiplierImplementation == "slow") begin : gen_multdiv_slow
|
||||
ibex_multdiv_slow multdiv_i (
|
||||
.clk_i ( clk_i ),
|
||||
.rst_ni ( rst_ni ),
|
||||
|
@ -107,7 +106,7 @@ module ibex_ex_block #(
|
|||
.alu_operand_b_o ( multdiv_alu_operand_b ),
|
||||
.multdiv_result_o ( multdiv_result )
|
||||
);
|
||||
end else begin : gen_multdiv_fast
|
||||
end else if (MultiplierImplementation == "fast") begin : gen_multdiv_fast
|
||||
ibex_multdiv_fast multdiv_i (
|
||||
.clk_i ( clk_i ),
|
||||
.rst_ni ( rst_ni ),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue