Skip to content

Commit 5adb017

Browse files
committed
build: add user_arguments to orfs_design (patch + chameleon usage)
bazel-orfs's orfs_flow already has a user_arguments parameter that bypasses the variables.yaml validator -- intended for project-specific env vars read only by user-supplied .tcl/.mk files. orfs_design didn't forward to it, so config.mk vars like FP_PDN_RAIL_OFFSET (read by chameleon's pdn.cfg, not by ORFS) were rejected. Patch 0004 adds a user_arguments arg to orfs_design that names the config.mk vars to lift out of the validated arguments dict and into orfs_flow's user_arguments dict. Mirrored in flow/designs/design.bzl. Used in flow/designs/sky130hd/chameleon to declare FP_PDN_RAIL_OFFSET and FP_PDN_RAIL_WIDTH as user-only -- chameleon now loads. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 66dc514 commit 5adb017

4 files changed

Lines changed: 64 additions & 4 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ git_override(
5050
"//bazel/bazel-orfs-patches:0001-stages-register-bazel-injected-vars-in-validator.patch",
5151
"//bazel/bazel-orfs-patches:0002-synth_partition-fix-SYNTH_SKIP_KEEP-truthy-check.patch",
5252
"//bazel/bazel-orfs-patches:0003-synth_partition-parse-kept_modules-json-without-greedy-sed.patch",
53+
"//bazel/bazel-orfs-patches:0004-orfs_design-forward-user_arguments-to-orfs_flow.patch",
5354
],
5455
remote = BAZEL_ORFS_REMOTE,
5556
)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
diff --git a/private/orfs_design.bzl b/private/orfs_design.bzl
2+
index 3a0f3c2..cb607fc 100644
3+
--- a/private/orfs_design.bzl
4+
+++ b/private/orfs_design.bzl
5+
@@ -44,7 +44,7 @@ def _convert_sources(sources, pkg):
6+
result[var] = converted
7+
return result
8+
9+
-def orfs_design(name = None, platform = None, design = None, designs = None, mock_openroad = None, mock_yosys = None): # buildifier: disable=unused-variable
10+
+def orfs_design(name = None, platform = None, design = None, designs = None, mock_openroad = None, mock_yosys = None, user_arguments = []): # buildifier: disable=unused-variable
11+
"""Create orfs_flow() targets for a design based on its parsed config.mk.
12+
13+
Call this from a design's BUILD.bazel:
14+
@@ -66,6 +66,12 @@ def orfs_design(name = None, platform = None, design = None, designs = None, moc
15+
mock_yosys: Label for mock-yosys binary. When set, lint flow uses
16+
this instead of real Yosys for synthesis.
17+
Example: "//mock/yosys/src/bin:yosys".
18+
+ user_arguments: List of variable names from config.mk that are
19+
+ project-specific (read by user-supplied .tcl/.mk, not by
20+
+ ORFS itself, e.g. FP_PDN_RAIL_OFFSET in a custom pdn.cfg).
21+
+ Routed through orfs_flow(user_arguments=...) to bypass the
22+
+ variables.yaml validator instead of being checked as known
23+
+ ORFS arguments.
24+
"""
25+
if designs == None:
26+
fail("orfs_design() requires designs argument: pass DESIGNS from @orfs_designs//:designs.bzl")
27+
@@ -158,6 +164,13 @@ def orfs_design(name = None, platform = None, design = None, designs = None, moc
28+
# Real flow — uses Docker image with real OpenROAD/Yosys
29+
arguments = dict(config["arguments"])
30+
31+
+ # Move caller-flagged design-specific knobs out of arguments and into
32+
+ # user_arguments so they bypass the variables.yaml validator.
33+
+ user_args = {}
34+
+ for var in user_arguments:
35+
+ if var in arguments:
36+
+ user_args[var] = arguments.pop(var)
37+
+
38+
# Default SYNTH_NUM_PARTITIONS to a static value so that the action graph
39+
# is identical across machines and remote cache hits are possible. Users
40+
# who prefer local parallelism over caching can pass NUM_CPUS explicitly.
41+
@@ -174,6 +187,7 @@ def orfs_design(name = None, platform = None, design = None, designs = None, moc
42+
verilog_files = verilog_files,
43+
pdk = "//flow:" + platform,
44+
arguments = arguments,
45+
+ user_arguments = user_args,
46+
sources = sources,
47+
macros = macros if macros else [],
48+
stage_data = {"synth": extra_data} if extra_data else {},

flow/designs/design.bzl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ _GROUPS = {
1414
"gds": (["gds", "gds.gz"], ["gds", "gds.gz"]),
1515
}
1616

17-
def design():
18-
"""Standard BUILD body for flow/designs/<platform>/<design>/."""
17+
def design(user_arguments = []):
18+
"""Standard BUILD body for flow/designs/<platform>/<design>/.
19+
20+
user_arguments: see orfs_design — list of config.mk var names that
21+
are project-specific (read by the design's own .tcl/.mk, not by
22+
ORFS) and should bypass the variables.yaml validator.
23+
"""
1924
native.exports_files(native.glob(["*"]))
20-
orfs_design(designs = DESIGNS)
25+
orfs_design(designs = DESIGNS, user_arguments = user_arguments)
2126

2227
def files(group, extra_srcs = None):
2328
"""Public exports_files + named filegroup over conventional extensions."""
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
load("//flow/designs:design.bzl", "design")
22

3-
design()
3+
# FP_PDN_RAIL_{OFFSET,WIDTH} are read by chameleon's own pdn.cfg, not
4+
# by ORFS itself — route them through user_arguments so the validator
5+
# doesn't reject them as unknown ORFS variables.
6+
design(user_arguments = [
7+
"FP_PDN_RAIL_OFFSET",
8+
"FP_PDN_RAIL_WIDTH",
9+
])

0 commit comments

Comments
 (0)