Skip to content

Commit 7befb1d

Browse files
committed
verif: Remove decoupled LEVEL_BITS and MAX_FENCES and constraint
1 parent e330ea4 commit 7befb1d

6 files changed

Lines changed: 12 additions & 31 deletions

File tree

‎target/verif/config/generated/testbench.mk.tpl‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ RANDOM_GNT?=${RANDOM_GNT}
1111
INVERT_PRIO?=${INVERT_PRIO}
1212
PRIORITY_CNT_NUMERATOR?=${PRIORITY_CNT_NUMERATOR}
1313
PRIORITY_CNT_DENOMINATOR?=${PRIORITY_CNT_DENOMINATOR}
14-
LEVEL_BITS?=${LEVEL_BITS}

‎target/verif/config/testbench.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"RANDOM_GNT": 0,
77
"INVERT_PRIO": 0,
88
"PRIORITY_CNT_NUMERATOR": 10,
9-
"PRIORITY_CNT_DENOMINATOR": 11,
10-
"LEVEL_BITS": 5
9+
"PRIORITY_CNT_DENOMINATOR": 11
1110
}
1211
}

‎target/verif/simvectors/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ Weighted random traffic across hot regions.
219219

220220
4. Dependency gate for `wait_for_jobs`
221221
- For each dependent pattern, generator inserts a synthetic idle+`PAUSE` gate before real traffic.
222-
- Each gate crossing increments the driver's `fence_idx` counter. The required `fence_idx` values are packed into `LEVEL_BITS`-bit fields in `FENCE_REQ_LEVELS_PACKED`, so the maximum supported `fence_idx` value is `2^LEVEL_BITS - 1`.
223-
- `LEVEL_BITS` is configured in `testbench.json` (default: 4, i.e. max 15 fence crossings per driver). Increase it if generation fails with a fence level overflow error.
222+
- Each gate crossing increments the driver's `fence_idx` counter. The required `fence_idx` values are packed into `LEVEL_BITS`-bit fields in `FENCE_REQ_LEVELS_PACKED`.
223+
- `LEVEL_BITS` is auto-derived by main.py as the minimum bits to represent the maximum required `fence_idx` in the workload (`max_req_level.bit_length()`), and emitted to `fence_masks.mk`. Both the packed field width and the fence array depth (`2^LEVEL_BITS`) are derived from it, so they always match the workload with no manual configuration.
224224

225225
5. `idle` pattern
226226
- Explicitly emits idle and `PAUSE`.

‎target/verif/simvectors/main.py‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ def main(argv=None):
7272
testbench_config = load_config(args.testbench_config, "Testbench configuration")
7373
workload_config = load_config(args.workload_config, "Workload configuration")
7474

75-
# Testbench parameters
76-
tb_params = testbench_config['parameters']
77-
LEVEL_BITS = int(tb_params.get('LEVEL_BITS', 4))
78-
7975
# Hardware parameters
8076
hw_params = hardware_config['parameters']
8177
N_BANKS = hw_params['N_BANKS']
@@ -1105,15 +1101,9 @@ def _resolve_req_levels(wait_for_jobs_list):
11051101
for f in range(max_fences):
11061102
for j in range(N_DRIVERS):
11071103
max_req_level = max(max_req_level, int(req_levels[i][f][j]))
1104+
# Derive minimum LEVEL_BITS to represent max_req_level (at least 1 bit).
1105+
LEVEL_BITS = max(1, max_req_level.bit_length())
11081106
max_level_val = (1 << LEVEL_BITS) - 1
1109-
if max_req_level > max_level_val:
1110-
print(
1111-
"ERROR: Fence dependency level overflow: "
1112-
f"required fence_idx={max_req_level}, but packed format supports only 0..{max_level_val} "
1113-
f"(LEVEL_BITS={LEVEL_BITS}). "
1114-
f"Reduce the number of fence crossings per dependent job or increase LEVEL_BITS in testbench.json."
1115-
)
1116-
sys.exit(1)
11171107

11181108
packed_width = N_DRIVERS * LEVEL_BITS
11191109
packed_hex_digits = (packed_width + 3) // 4
@@ -1138,6 +1128,9 @@ def _resolve_req_levels(wait_for_jobs_list):
11381128
f"# fence f = PAUSE after pattern f; fence_idx[i]==k means i completed k patterns.\n"
11391129
f"# FENCE_MASKS[i][f][j]=1: j is a dependency of i at fence f.\n"
11401130
f"# FENCE_REQ_LEVELS_PACKED[i][f]: packed {packed_width}-bit vector, bits [j*LEVEL_BITS+LEVEL_BITS-1:j*LEVEL_BITS] = min fence_idx[j].\n"
1131+
f"# LEVEL_BITS: minimum bits to encode the max required fence_idx ({max_req_level}) for this workload.\n"
1132+
f"# Array depth and packed field width are both derived as 2^LEVEL_BITS.\n"
1133+
f"LEVEL_BITS := {LEVEL_BITS}\n"
11411134
f"FENCE_MASKS_PARAM := {fence_masks_param}\n"
11421135
f"FENCE_REQ_LEVELS_PACKED_PARAM := {fence_req_levels_packed_param}\n",
11431136
encoding='utf-8',

‎target/verif/src/tb_hci.sv‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -542,17 +542,5 @@ module tb_hci
542542
end
543543
endgenerate
544544

545-
// Advisory check only. The hard overflow guard is in Python generation
546-
// before packing FENCE_REQ_LEVELS into 4-bit fields.
547-
// In case of failure due to this asser, modify tb_hci_pkg.sv and generation of fence_masks.mk
548-
initial begin
549-
if (MAX_FENCES > 16) begin
550-
$warning(
551-
"MAX_FENCES=%0d exceeds the nominal 4-bit fence-level range; "
552-
"ensure no dependency requires a level > 15.",
553-
MAX_FENCES
554-
);
555-
end
556-
end
557545

558546
endmodule

‎target/verif/src/tb_hci_pkg.sv‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ package tb_hci_pkg;
9898
// For a trailing pattern fence, the mask is zero and the fence is a free pass.
9999
//
100100
// Both arrays are generated by main.py and passed via defines.
101+
// LEVEL_BITS: bits used to encode each required fence_idx value in the packed vector.
102+
// Supports fence_idx values 0..2^LEVEL_BITS-1. Set in testbench.json.
103+
localparam int unsigned LEVEL_BITS = `ifdef LEVEL_BITS `LEVEL_BITS `else 4 `endif;
104+
// MAX_FENCES: depth of the fence arrays, sized to hold all encodable fence_idx values.
101105
localparam int unsigned MAX_FENCES = 2**LEVEL_BITS;
102106
localparam logic [N_DRIVERS-1:0] FENCE_MASKS [N_DRIVERS][MAX_FENCES] =
103107
`ifdef FENCE_MASKS_PARAM `FENCE_MASKS_PARAM `else '{default: '{default: '0}} `endif;
104-
localparam int unsigned LEVEL_BITS =
105-
`ifdef LEVEL_BITS `LEVEL_BITS `else 4 `endif;
106108
// FENCE_REQ_LEVELS_PACKED[i][f] is a packed vector of N_DRIVERS × LEVEL_BITS bits.
107109
// Bits [j*LEVEL_BITS+LEVEL_BITS-1:j*LEVEL_BITS] hold the required fence_idx[j] before driver i can pass fence f.
108110
localparam logic [N_DRIVERS*LEVEL_BITS-1:0] FENCE_REQ_LEVELS_PACKED [N_DRIVERS][MAX_FENCES] =

0 commit comments

Comments
 (0)