Skip to content

Commit 5b09b29

Browse files
committed
orfs: plumb polarity_mode + docs
1 parent 4d71e52 commit 5b09b29

File tree

7 files changed

+55
-33
lines changed

7 files changed

+55
-33
lines changed

doc-DFT-howto.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This auto-wires the two ORFS DFT hook scripts:
2727
Note:
2828
- If your design contains mixed clock domains and/or negedge flops, ORFS defaults `DFT_LOCKUP_POLICY=auto` and may fall back to `DFT_CLOCK_MIXING=no_mix`, which can increase the number of scan chains/ports.
2929
- To keep `clock_mix`, set `DFT_LOCKUP_POLICY=off` and configure lockup insertion (at minimum: `DFT_LOCKUP_CELL_RISING` + `DFT_LOCKUP_CLOCK_PIN_RISING`, and likewise `*_FALLING` if negedge scan flops exist).
30+
- Polarity defaults to `DFT_POLARITY_MODE=mid` (mixed polarity allowed; falling-edge flops are stitched before rising-edge flops within each chain). To forbid mixing polarities within a chain, set `DFT_POLARITY_MODE=strict` (may require additional chains when both polarities exist).
3031

3132
## Optional: Routing-aware ordering (trial route, then stitch)
3233

docs/user/FlowVariables.md

Lines changed: 28 additions & 31 deletions
Large diffs are not rendered by default.

flow/scripts/dft_scan_post_floorplan.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ proc dft_set_scan_enable_case_analysis {scan_enable_name} {
4949
# - DFT_MAX_CHAINS (explicit cap), and/or
5050
# - DFT_MAX_CHAIN_LENGTH (aka DFT_MAX_LENGTH) to bound chain length in bits.
5151
set clock_mixing [dft_get_env DFT_CLOCK_MIXING "no_mix"]
52+
set polarity_mode [dft_get_env DFT_POLARITY_MODE "mid"]
5253
set scan_enable_pattern [dft_get_env DFT_SCAN_ENABLE_NAME_PATTERN "scan_enable_{}"]
5354
set scan_in_pattern [dft_get_env DFT_SCAN_IN_NAME_PATTERN "scan_in_{}"]
5455
set scan_out_pattern [dft_get_env DFT_SCAN_OUT_NAME_PATTERN "scan_out_{}"]
@@ -89,6 +90,7 @@ set max_chains [dft_get_env DFT_MAX_CHAINS ""]
8990

9091
set dft_args [list \
9192
-clock_mixing $clock_mixing \
93+
-polarity_mode $polarity_mode \
9294
-scan_enable_name_pattern $scan_enable_pattern \
9395
-scan_in_name_pattern $scan_in_pattern \
9496
-scan_out_name_pattern $scan_out_pattern \

flow/scripts/dft_scan_pre_global_route.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,7 @@ proc dft_build_dft_config_args {{clock_mixing_override ""}} {
13091309
if { $clock_mixing_override != "" } {
13101310
set clock_mixing $clock_mixing_override
13111311
}
1312+
set polarity_mode [dft_get_env DFT_POLARITY_MODE "mid"]
13121313

13131314
set scan_enable_pattern [dft_get_env DFT_SCAN_ENABLE_NAME_PATTERN "scan_enable_{}"]
13141315
set scan_in_pattern [dft_get_env DFT_SCAN_IN_NAME_PATTERN "scan_in_{}"]
@@ -1349,6 +1350,7 @@ proc dft_build_dft_config_args {{clock_mixing_override ""}} {
13491350

13501351
set dft_args [list \
13511352
-clock_mixing $clock_mixing \
1353+
-polarity_mode $polarity_mode \
13521354
-scan_enable_name_pattern $scan_enable_pattern \
13531355
-scan_in_name_pattern $scan_in_pattern \
13541356
-scan_out_name_pattern $scan_out_pattern \

flow/scripts/variables.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,17 @@ DFT_CLOCK_MIXING:
10041004
stages:
10051005
- floorplan
10061006
- grt
1007+
DFT_POLARITY_MODE:
1008+
description: >
1009+
How scan architect handles rising-edge and falling-edge scan flops within
1010+
a scan chain. Pass-through to `set_dft_config -polarity_mode` (`mid` or
1011+
`strict`). `mid` allows mixed polarity per chain by stitching falling-edge
1012+
flops before rising-edge flops. `strict` forbids mixing polarities within
1013+
a chain, requiring separate chains when both polarities are present.
1014+
default: mid
1015+
stages:
1016+
- floorplan
1017+
- grt
10071018
DFT_CHAIN_COUNT:
10081019
description: >
10091020
Exact number of scan chains to generate (pass-through to

flow/util/dft_preplaced_regress.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def run_openroad_execute_dft_plan(
101101
chain_count: int,
102102
max_imbalance: float,
103103
clock_mixing: str,
104+
polarity_mode: str,
104105
scan_order_metric: Optional[str],
105106
scan_order_solver: str,
106107
scanopt_rounds: Optional[int],
@@ -190,6 +191,7 @@ def run_openroad_execute_dft_plan(
190191
f"-chain_count {chain_count}",
191192
f"-max_imbalance {max_imbalance}",
192193
f"-clock_mixing {clock_mixing}",
194+
f"-polarity_mode {polarity_mode}",
193195
f"-scan_order_solver {scan_order_solver}",
194196
"-scan_enable_name_pattern scan_enable_{}",
195197
"-scan_in_name_pattern scan_in_{}",
@@ -427,6 +429,11 @@ def main(argv: Optional[List[str]] = None) -> int:
427429
help="Comma-separated list (percent).",
428430
)
429431
ap.add_argument("--clock-mixing", default="no_mix")
432+
ap.add_argument(
433+
"--polarity-mode",
434+
default="mid",
435+
help="Polarity handling policy: mid (default) or strict.",
436+
)
430437
ap.add_argument("--scan-order-metric", default=None)
431438
ap.add_argument("--scan-order-solver", default="SCANOPT")
432439
ap.add_argument("--scanopt-rounds", type=int, default=500000)
@@ -486,7 +493,8 @@ def main(argv: Optional[List[str]] = None) -> int:
486493
metric = args.scan_order_metric or "DEFAULT"
487494
print(
488495
f"=== execute_dft_plan: {tag} "
489-
f"(solver={args.scan_order_solver}, metric={metric}, clock_mixing={args.clock_mixing}) ==="
496+
f"(solver={args.scan_order_solver}, metric={metric}, "
497+
f"clock_mixing={args.clock_mixing}, polarity_mode={args.polarity_mode}) ==="
490498
)
491499
out_def = out_prefix.with_name(f"{out_prefix.name}_{tag}.def")
492500
out_v = out_prefix.with_name(f"{out_prefix.name}_{tag}.v")
@@ -508,6 +516,7 @@ def main(argv: Optional[List[str]] = None) -> int:
508516
chain_count=k,
509517
max_imbalance=imb,
510518
clock_mixing=args.clock_mixing,
519+
polarity_mode=args.polarity_mode,
511520
scan_order_metric=args.scan_order_metric,
512521
scan_order_solver=args.scan_order_solver,
513522
scanopt_rounds=args.scanopt_rounds,

0 commit comments

Comments
 (0)