Skip to content

Commit 84d6e51

Browse files
authored
Merge pull request #208 from pulp-platform/vcs-fixes
axi_xbar: Work around constant function calls for VCS
2 parents 1439a77 + 6a6fdcc commit 84d6e51

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1818
- `axi_id_remap`: Improve compatibility with Verilator by excluding `assert`s for that tool.
1919
- `axi_lite_demux`: Improve compatibility with VCS (issue #187 reported for `axi_demux`, which was
2020
fixed in v0.29.2).
21+
- `axi_xbar`: Improve compatibility with VCS by adding VCS-specific code that does not use constant
22+
function calls (#208).
2123

2224

2325
## 0.32.0 - 2022-01-25

src/axi_xbar.sv

+26
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ import cf_math_pkg::idx_width;
3434
parameter type mst_req_t = logic,
3535
parameter type mst_resp_t = logic,
3636
parameter type rule_t = axi_pkg::xbar_rule_64_t
37+
`ifdef VCS
38+
, localparam int unsigned MstPortsIdxWidth =
39+
(Cfg.NoMstPorts == 32'd1) ? 32'd1 : unsigned'($clog2(Cfg.NoMstPorts))
40+
`endif
3741
) (
3842
input logic clk_i,
3943
input logic rst_ni,
@@ -44,12 +48,22 @@ import cf_math_pkg::idx_width;
4448
input mst_resp_t [Cfg.NoMstPorts-1:0] mst_ports_resp_i,
4549
input rule_t [Cfg.NoAddrRules-1:0] addr_map_i,
4650
input logic [Cfg.NoSlvPorts-1:0] en_default_mst_port_i,
51+
`ifdef VCS
52+
input logic [Cfg.NoSlvPorts-1:0][MstPortsIdxWidth-1:0] default_mst_port_i
53+
`else
4754
input logic [Cfg.NoSlvPorts-1:0][idx_width(Cfg.NoMstPorts)-1:0] default_mst_port_i
55+
`endif
4856
);
4957

5058
typedef logic [Cfg.AxiAddrWidth-1:0] addr_t;
5159
// to account for the decoding error slave
60+
`ifdef VCS
61+
localparam int unsigned MstPortsIdxWidthOne =
62+
(Cfg.NoMstPorts == 32'd1) ? 32'd1 : unsigned'($clog2(Cfg.NoMstPorts + 1));
63+
typedef logic [MstPortsIdxWidthOne-1:0] mst_port_idx_t;
64+
`else
5265
typedef logic [idx_width(Cfg.NoMstPorts + 1)-1:0] mst_port_idx_t;
66+
`endif
5367

5468
// signals from the axi_demuxes, one index more for decode error
5569
slv_req_t [Cfg.NoSlvPorts-1:0][Cfg.NoMstPorts:0] slv_reqs;
@@ -63,7 +77,11 @@ import cf_math_pkg::idx_width;
6377
slv_resp_t [Cfg.NoMstPorts-1:0][Cfg.NoSlvPorts-1:0] mst_resps;
6478

6579
for (genvar i = 0; i < Cfg.NoSlvPorts; i++) begin : gen_slv_port_demux
80+
`ifdef VCS
81+
logic [MstPortsIdxWidth-1:0] dec_aw, dec_ar;
82+
`else
6683
logic [idx_width(Cfg.NoMstPorts)-1:0] dec_aw, dec_ar;
84+
`endif
6785
mst_port_idx_t slv_aw_select, slv_ar_select;
6886
logic dec_aw_valid, dec_aw_error;
6987
logic dec_ar_valid, dec_ar_error;
@@ -247,6 +265,10 @@ import cf_math_pkg::idx_width;
247265
parameter int unsigned AXI_USER_WIDTH = 0,
248266
parameter axi_pkg::xbar_cfg_t Cfg = '0,
249267
parameter type rule_t = axi_pkg::xbar_rule_64_t
268+
`ifdef VCS
269+
, localparam int unsigned MstPortsIdxWidth =
270+
(Cfg.NoMstPorts == 32'd1) ? 32'd1 : unsigned'($clog2(Cfg.NoMstPorts))
271+
`endif
250272
) (
251273
input logic clk_i,
252274
input logic rst_ni,
@@ -255,7 +277,11 @@ import cf_math_pkg::idx_width;
255277
AXI_BUS.Master mst_ports [Cfg.NoMstPorts-1:0],
256278
input rule_t [Cfg.NoAddrRules-1:0] addr_map_i,
257279
input logic [Cfg.NoSlvPorts-1:0] en_default_mst_port_i,
280+
`ifdef VCS
281+
input logic [Cfg.NoSlvPorts-1:0][MstPortsIdxWidth-1:0] default_mst_port_i
282+
`else
258283
input logic [Cfg.NoSlvPorts-1:0][idx_width(Cfg.NoMstPorts)-1:0] default_mst_port_i
284+
`endif
259285
);
260286

261287
localparam int unsigned AxiIdWidthMstPorts = Cfg.AxiIdWidthSlvPorts + $clog2(Cfg.NoSlvPorts);

0 commit comments

Comments
 (0)