Skip to content

Commit

Permalink
yosys: avoid resynthesis on ORFS upgrade when yosys doesn't change
Browse files Browse the repository at this point in the history
This still works:

bazel run //sram:sdq_17x64_synth $(pwd)/tmp open_synth

Signed-off-by: Øyvind Harboe <[email protected]>
  • Loading branch information
oharboe committed Oct 23, 2024
1 parent 128438d commit eaf9a94
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions openroad.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,13 @@ def yosys_environment(ctx):
def config_environment(config):
return {"DESIGN_CONFIG": config.path}

def flow_inputs(ctx):
def flow_inputs(ctx, openroad = True):
return depset(
[
ctx.executable._klayout,
ctx.executable._make,
ctx.executable._openroad,
ctx.file._makefile,
] +
] + ([ctx.executable._openroad] if openroad else []) +
ctx.files._ruby +
ctx.files._ruby_dynamic +
ctx.files._tcl +
Expand Down Expand Up @@ -637,7 +636,7 @@ def _yosys_impl(ctx):
ctx.files.verilog_files +
ctx.files.extra_configs,
transitive = [
flow_inputs(ctx),
flow_inputs(ctx, openroad = False),
yosys_inputs(ctx),
data_inputs(ctx),
pdk_inputs(ctx),
Expand Down Expand Up @@ -678,7 +677,7 @@ def _yosys_impl(ctx):
[canon_output, config] +
ctx.files.extra_configs,
transitive = [
flow_inputs(ctx),
flow_inputs(ctx, openroad = False),
yosys_inputs(ctx),
data_inputs(ctx),
pdk_inputs(ctx),
Expand All @@ -688,7 +687,22 @@ def _yosys_impl(ctx):
outputs = synth_outputs + synth_logs,
)

outputs = [canon_output] + synth_outputs
# Dummy action to make sure that the flow environment is available to
# bazel run foo_synth without causing resynthesis when upgrading
# ORFS where yosys did not change, saves many hours of synthesis
dummy_output = _declare_artifact(ctx, "results", "dummy.txt")
ctx.actions.run_shell(
command = "touch " + dummy_output.path,
env = flow_environment(ctx),
inputs = depset(
transitive = [
flow_inputs(ctx),
],
),
outputs = [dummy_output],
)

outputs = [canon_output] + synth_outputs + [dummy_output]

config_short = _declare_artifact(ctx, "results", "1_synth.short.mk")
ctx.actions.write(
Expand Down

0 comments on commit eaf9a94

Please sign in to comment.