config_system: Add new config system using structs

The "old" config system is quite rigid in terms of user
parameterization. To avoid adding more and more generics to the
parameter port I've packaged the parameters to use a single struct
`ariane_cfg_t` which can then be passed to all submodules in need of the
parameter value.

We can slowly transition to this new system. One drawback is the missing
capability to calculate parameters based on other parameters. Functions
would be needed to do so. Or, imho, the better approach would be a
Python script which generates the appropriate parameters.
This commit is contained in:
Florian Zaruba 2019-04-07 18:58:05 +02:00
parent 1fa1489512
commit ddbc23819a
3 changed files with 42 additions and 3 deletions

View file

@ -28,6 +28,31 @@ package ariane_pkg;
// ---------------
// Global Config
// ---------------
// This is the new user config interface system. If you need to parameterize something
// within Ariane add a field here and assign a default value to the config. Please make
// sure to add a propper parameter check to the `check_cfg` function.
typedef struct packed {
int NrNonIdempotentRules; // Number of non idempotent rules
logic [2**16-1:0][63:0] NonIdempotentAddrBase; // base which needs to match
logic [2**16-1:0][63:0] NonIdempotentAddrMaks; // bit mask which bits to consider when matching the rule
} ariane_cfg_t;
localparam ariane_cfg_t ArianeDefaultConfig = '{
NrNonIdempotentRules: 2,
NonIdempotentAddrBase: {64'b0, 64'b0},
NonIdempotentAddrMaks: {64'b0, 64'b0}
};
// Function being called to check parameters
function automatic void check_cfg (ariane_cfg_t Cfg);
// pragma translate_off
`ifndef VERILATOR
assert(Cfg.NrNonIdempotentRules <= 16);
`endif
// pragma translate_on
endfunction
// TODO: Slowly move those parameters to the new system.
localparam NR_SB_ENTRIES = 8; // number of scoreboard entries
localparam TRANS_ID_BITS = $clog2(NR_SB_ENTRIES); // depending on the number of scoreboard entries we need that many bits
// to uniquely identify the entry in the scoreboard

View file

@ -25,7 +25,8 @@ module ariane #(
parameter int unsigned AxiIdWidth = 4,
parameter bit SwapEndianess = 0, // swap endianess in l15 adapter
parameter logic [63:0] CachedAddrEnd = 64'h80_0000_0000, // end of cached region
parameter logic [63:0] CachedAddrBeg = 64'h00_8000_0000 // begin of cached region
parameter logic [63:0] CachedAddrBeg = 64'h00_8000_0000, // begin of cached region
parameter ariane_pkg::ariane_cfg_t Cfg = ariane_pkg::ArianeDefaultConfig
) (
input logic clk_i,
input logic rst_ni,
@ -339,7 +340,9 @@ module ariane #(
// ---------
// EX
// ---------
ex_stage ex_stage_i (
ex_stage #(
.Cfg ( Cfg )
) ex_stage_i (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.flush_i ( flush_ctrl_ex ),
@ -650,6 +653,15 @@ module ariane #(
);
`endif
// -------------------
// Parameter Check
// -------------------
// pragma translate_off
`ifndef VERILATOR
initial ariane_pkg::check_cfg(Cfg);
`endif
// pragma translate_on
// -------------------
// Instruction Tracer
// -------------------

View file

@ -15,7 +15,9 @@
import ariane_pkg::*;
module ex_stage (
module ex_stage #(
parameter ariane_pkg::ariane_cfg_t Cfg = ariane_pkg::ArianeDefaultConfig
) (
input logic clk_i, // Clock
input logic rst_ni, // Asynchronous reset active low
input logic flush_i,