Skip to content

Commit fdeedf0

Browse files
committed
Add ifdef guards for configurable parameters in spatz_pkg.sv
1 parent 7885ca9 commit fdeedf0

File tree

1 file changed

+46
-15
lines changed

1 file changed

+46
-15
lines changed

hw/ip/spatz/src/generated/spatz_pkg.sv

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,41 @@ package spatz_pkg;
1111
//////////////////
1212
// Parameters //
1313
//////////////////
14-
14+
1515
// Number of IPUs in each VFU (between 1 and 8)
16-
localparam int unsigned N_IPU = 1;
16+
`ifdef SPATZ_N_IPU
17+
localparam int unsigned N_IPU = `SPATZ_N_IPU;
18+
`else
19+
localparam int unsigned N_IPU = 1;
20+
`endif
1721
// Number of FPUs in each VFU (between 1 and 8)
18-
localparam int unsigned N_FPU = 4;
22+
`ifdef SPATZ_N_FPU
23+
localparam int unsigned N_FPU = `SPATZ_N_FPU;
24+
`else
25+
localparam int unsigned N_FPU = 4;
26+
`endif
1927
// Number of FUs in each VFU
2028
localparam int unsigned N_FU = N_IPU > N_FPU ? N_IPU : N_FPU;
2129
// FPU support
2230
localparam bit FPU = N_FPU != 0;
2331
// Single-precision floating point support
24-
localparam bit RVF = 1;
32+
`ifdef SPATZ_RVF
33+
localparam bit RVF = `SPATZ_RVF;
34+
`else
35+
localparam bit RVF = 1'b1;
36+
`endif
2537
// Double-precision floating-point support
2638
`ifdef SPATZ_RVD
2739
localparam bit RVD = `SPATZ_RVD;
2840
`else
29-
localparam bit RVD = 0; // Default
41+
localparam bit RVD = 0;
3042
`endif
3143
// Vector support
32-
localparam bit RVV = 1;
33-
44+
`ifdef SPATZ_RVV
45+
localparam bit RVV = `SPATZ_RVV;
46+
`else
47+
localparam bit RVV = 1'b1;
48+
`endif
3449
// Maximum size of a single vector element in bits
3550
localparam int unsigned ELEN = RVD ? 64 : 32; // = 64 with RVD=1
3651
// Maximum size of a single vector element in bytes
@@ -39,15 +54,18 @@ package spatz_pkg;
3954
`ifdef SPATZ_VLEN
4055
localparam int unsigned VLEN = `SPATZ_VLEN;
4156
`else
42-
localparam int unsigned VLEN = 256; // Default: 256 bits
57+
localparam int unsigned VLEN = 256;
4358
`endif
4459
// Number of bytes in a vector register
4560
localparam int unsigned VLENB = VLEN / 8;
4661
// Maximum vector length in elements
4762
localparam int unsigned MAXVL = VLEN;
4863
// Number of vector registers
49-
localparam int unsigned NRVREG = 32;
50-
64+
`ifdef SPATZ_NRVREG
65+
localparam int unsigned NRVREG = `SPATZ_NRVREG;
66+
`else
67+
localparam int unsigned NRVREG = 32;
68+
`endif
5169
// Spatz' data width
5270
localparam int unsigned DataWidth = ELEN;
5371
// Spatz' strobe width
@@ -61,8 +79,12 @@ package spatz_pkg;
6179
localparam int unsigned NrWordsPerVector = VLEN/VRFWordWidth;
6280
// Number of VRF words
6381
localparam int unsigned NrVRFWords = NRVREG * NrWordsPerVector;
64-
// Number of VRF banks
65-
localparam int unsigned NrVRFBanks = 4;
82+
// Number of VRF banks (affects banking conflicts and parallel access)
83+
`ifdef SPATZ_NR_VRF_BANKS
84+
localparam int unsigned NrVRFBanks = `SPATZ_NR_VRF_BANKS;
85+
`else
86+
localparam int unsigned NrVRFBanks = 4; // Default
87+
`endif
6688
// Number of elements per VRF Bank
6789
localparam int unsigned NrWordsPerBank = NrVRFWords / NrVRFBanks;
6890

@@ -71,7 +93,11 @@ package spatz_pkg;
7193
localparam int GPRWidth = FPU ? 6 : 5;
7294

7395
// Number of parallel vector instructions
74-
localparam int unsigned NrParallelInstructions = 4;
96+
`ifdef SPATZ_NR_PARALLEL_INSTR
97+
localparam int unsigned NrParallelInstructions = `SPATZ_NR_PARALLEL_INSTR;
98+
`else
99+
localparam int unsigned NrParallelInstructions = 4;
100+
`endif
75101

76102
// Largest element width that Spatz supports
77103
localparam vew_e MAXEW = RVD ? EW_64 : EW_32;
@@ -340,8 +366,13 @@ package spatz_pkg;
340366
// FPU Configuration //
341367
/////////////////////////
342368

343-
// No support for floating-point division and square-root for now
344-
localparam bit FDivSqrt = 1'b0;
369+
// FP division and square-root support
370+
// No support for floating point division/square-root for now
371+
`ifdef SPATZ_XDIVSQRT
372+
localparam bit FDivSqrt = `SPATZ_XDIVSQRT;
373+
`else
374+
localparam bit FDivSqrt = 1'b0;
375+
`endif
345376

346377
localparam int unsigned FLEN = RVD ? 64 : 32;
347378

0 commit comments

Comments
 (0)