Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orfs flow dry #277

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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