Skip to content

Commit

Permalink
orfs_flow: 'sources' now automatically expand to a variable
Browse files Browse the repository at this point in the history
arguments override sources for compatibility

Signed-off-by: Øyvind Harboe <[email protected]>
  • Loading branch information
oharboe committed Jan 31, 2025
1 parent 9b854c7 commit a1bf257
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ orfs_flow(
orfs_floorplan(
name = "lb_32x128_shared_synth_floorplan",
src = ":lb_32x128_synth",
arguments = get_stage_args("floorplan", {}, LB_ARGS),
# HACK! orfs_floorplan() isn't really meant to be called directly
arguments = get_stage_args("floorplan", {}, LB_ARGS, {}),
data = LB_STAGE_SOURCES["floorplan"],
variant = "blah",
)
Expand Down Expand Up @@ -417,7 +418,6 @@ orfs_flow(
"CORE_UTILIZATION": "10",
"CORE_ASPECT_RATIO": "2",
"SKIP_REPORT_METRICS": "1",
"SDC_FILE": "$(location :constraints-sram-sky130hd.sdc)",
},
pdk = "@docker_orfs//:sky130hd",
sources = {
Expand Down
24 changes: 15 additions & 9 deletions openroad.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1328,22 +1328,28 @@ ALL_VARIABLE_TO_STAGES = {
for variable in _union(*ALL_STAGE_TO_VARIABLES.values())
}

def get_stage_args(stage, stage_arguments, arguments):
def get_stage_args(stage, stage_arguments, arguments, sources):
"""Returns the arguments for a specific stage.
Args:
stage: The stage name.
stage_arguments: the dictionary of stages with each stage having a dictionary of arguments
arguments: a dictionary of arguments automatically assigned to a stage
sources: a dictionary of variables and source files
Returns:
A dictionary of arguments for the stage.
"""
unsorted_dict = ({
arg: value
for arg, value in arguments.items()
if arg in ALL_STAGE_TO_VARIABLES[stage] or arg not in ALL_VARIABLE_TO_STAGES
} |
stage_arguments.get(stage, {}))
unsorted_dict = (
{
arg: " ".join(_map(lambda v: "$(location {})".format(v), value))
for arg, value in sources.items()
if arg in ALL_STAGE_TO_VARIABLES[stage] or arg not in ALL_VARIABLE_TO_STAGES
} | {
arg: value
for arg, value in arguments.items()
if arg in ALL_STAGE_TO_VARIABLES[stage] or arg not in ALL_VARIABLE_TO_STAGES
} | stage_arguments.get(stage, {})
)
return dict(sorted(unsorted_dict.items()))

def get_sources(stage, stage_sources, sources):
Expand Down Expand Up @@ -1522,7 +1528,7 @@ def _orfs_pass(
synth_step = steps[0]
synth_step.impl(
name = _step_name(name, variant, synth_step.stage),
arguments = get_stage_args(synth_step.stage, stage_arguments, arguments),
arguments = get_stage_args(synth_step.stage, stage_arguments, arguments, sources),
data = get_sources(synth_step.stage, stage_sources, sources),
deps = macros,
extra_configs = extra_configs.get(synth_step.stage, []),
Expand All @@ -1547,7 +1553,7 @@ def _orfs_pass(
step.impl(
name = step_name,
src = src,
arguments = get_stage_args(step.stage, stage_arguments, arguments),
arguments = get_stage_args(step.stage, stage_arguments, arguments, sources),
data = get_sources(step.stage, stage_sources, sources),
extra_configs = extra_configs.get(step.stage, []),
variant = variant,
Expand Down

0 comments on commit a1bf257

Please sign in to comment.