Skip to content

feat: add Yosys LEC flow support#111

Open
zhaoxueyan1 wants to merge 1 commit into
mainfrom
integrate-lec
Open

feat: add Yosys LEC flow support#111
zhaoxueyan1 wants to merge 1 commit into
mainfrom
integrate-lec

Conversation

@zhaoxueyan1

Copy link
Copy Markdown
Member

Summary

  • Add yosys_lec tool integration for synthesis and post-route equivalence checking.
  • Add flow builders for synthesis LEC and synthesis-gate-netlist vs post-route-netlist LEC.
  • Teach Yosys synthesis to emit a golden mapped netlist for LEC handoff.
  • Add the ICS55 PDK test submodule and focused yosys_lec tests.

Verification

  • PYTHONPATH=/tmp/ecc-dreamplace-py311-install:/home/zhaoxueyan/code/ecc /home/zhaoxueyan/anaconda3/envs/PlaceOPT/bin/python /tmp/run_ics55_gcd_post_route_lec.py
    • Full flow passed: Synthesis -> Floorplan -> fixFanout -> place -> CTS -> legalization -> route -> postRouteLec.
    • LEC result: status=proven, 316 proven / 0 unproven $equiv cells.
    • Result artifact: /home/zhaoxueyan/code/ecc/test/yosys_lec/runs/ics55_gcd_post_route_lec/postRouteLec_yosys_lec/output/gcd_postRouteLec_result.json.
  • PYTHONPATH=/tmp/ecc-dreamplace-py311-install:/home/zhaoxueyan/code/ecc /home/zhaoxueyan/anaconda3/envs/PlaceOPT/bin/python -m pytest test/test_design_parameters.py test/test_tools_yosys_runner.py test/yosys_lec/test_tools_yosys_lec.py -q
    • 24 passed in 0.67s
  • PYTHONPATH=/tmp/ecc-dreamplace-py311-install:/home/zhaoxueyan/code/ecc /home/zhaoxueyan/anaconda3/envs/PlaceOPT/bin/python -m py_compile ...
  • git diff --cached --check

Copilot AI review requested due to automatic review settings June 9, 2026 04:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Yosys-based LEC (logic equivalence checking) tool integration and flow support so ECC can run equivalence checks after synthesis and after routing, with test coverage against the ICS55 PDK.

Changes:

  • Integrate new yosys_lec tool (builder/runner/subflow) and wire it into EngineFlow/rtl2gds flows.
  • Extend Yosys synthesis to emit an additional “golden” netlist for LEC handoff.
  • Add focused tests and repo layout updates (test assets, gitignore, submodule entry).

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/yosys_lec/test_tools_yosys_lec.py Adds unit tests covering yosys golden netlist generation, yosys_lec step building, and EngineFlow wiring.
test/yosys_lec/.gitignore Ignores generated yosys_lec run artifacts under test/yosys_lec/runs/.
test/test_tools_yosys_runner.py Updates yosys runner tests to account for golden netlist output.
chipcompiler/tools/yosys/scripts/yosys_synthesis.tcl Emits a golden netlist file during synthesis when configured.
chipcompiler/tools/yosys/runner.py Treats missing golden netlist as a synthesis failure when configured.
chipcompiler/tools/yosys/builder.py Adds golden_netlist_file into generated Tcl and defines golden output path.
chipcompiler/tools/yosys_lec/utility.py Exposes yosys availability check for yosys_lec.
chipcompiler/tools/yosys_lec/subflow.py Implements subflow tracking for yosys_lec steps.
chipcompiler/tools/yosys_lec/runner.py Runs yosys-based LEC Tcl and produces a result json on success.
chipcompiler/tools/yosys_lec/builder.py Creates yosys_lec step workspace, config, and run script.
chipcompiler/tools/yosys_lec/__init__.py Exports yosys_lec public API.
chipcompiler/rtl2gds/builder.py Adds build_synthesis_lec_flow and build_post_route_lec_flow.
chipcompiler/rtl2gds/__init__.py Exposes the new LEC flows from the rtl2gds package.
chipcompiler/engine/flow.py Wires LEC steps into workspace step creation and result checks.
chipcompiler/data/step.py Adds LEC and POST_ROUTE_LEC step enums.
chipcompiler/data/parameter.py Adds default LEC parameters (e.g., use_undef) for the ICS55 gcd config.
.gitmodules Adds the ICS55 PDK test submodule entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .gitmodules
Comment on lines +8 to +10
[submodule "test/icsprout55-pdk"]
path = test/icsprout55-pdk
url = git@github.com:openecos-projects/icsprout55-pdk.git

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this.


# Output files
set final_netlist_file {_tcl_quote(netlist_file)}
set golden_netlist_file {_tcl_quote(_abspath(step.output.get("golden_verilog", "")))}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this.

Comment on lines +17 to +20
def _tcl_quote(value: str) -> str:
value = str(value)
escaped = value.replace("\\", "\\\\").replace('"', '\\"')
return f'"{escaped}"'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this.

Comment on lines +33 to +36
def run_step(workspace: Workspace, step: WorkspaceStep, ecc_module=None) -> bool:
sub_flow = YosysLecSubFlow(workspace=workspace, workspace_step=step)

yosys_cmd, yosys_env = get_yosys_runtime()
@Emin017 Emin017 changed the title Add Yosys LEC flow support feat: add Yosys LEC flow support Jun 9, 2026

@Emin017 Emin017 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some review comments and please fix all of Copilot’s review comments.

Comment thread test/icsprout55-pdk

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add make unzip step in ci config.

Comment thread .gitmodules
Comment on lines +8 to +10
[submodule "test/icsprout55-pdk"]
path = test/icsprout55-pdk
url = git@github.com:openecos-projects/icsprout55-pdk.git

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this.

Comment on lines +177 to +181
if (
workspace_step.tool == "yosys_lec"
or workspace_step.name in (StepEnum.LEC.value, StepEnum.POST_ROUTE_LEC.value)
):
return os.path.exists(workspace_step.output.get("json", ""))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to use match:

Suggested change
if (
workspace_step.tool == "yosys_lec"
or workspace_step.name in (StepEnum.LEC.value, StepEnum.POST_ROUTE_LEC.value)
):
return os.path.exists(workspace_step.output.get("json", ""))
match (workspace_step.tool, workspace_step.name):
case ("yosys_lec", _) | (_, StepEnum.LEC.value) | (_, StepEnum.POST_ROUTE_LEC.value):
return os.path.exists(workspace_step.output.get("json", ""))


# Output files
set final_netlist_file {_tcl_quote(netlist_file)}
set golden_netlist_file {_tcl_quote(_abspath(step.output.get("golden_verilog", "")))}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this.

return True

sub_flow.update_step(step_name="run lec", state=StateEnum.Imcomplete)
return False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Failed LEC reruns can still be marked successful

  • check_step_result() accepts any existing LEC result JSON as success. runner.run_step() only writes JSON on proven success and leaves any old JSON in place on failure. Scenario: LEC succeeds
    once, then a rerun fails equivalence; the stale JSON remains, so EngineFlow.run_step() ignores the runner’s False result and sets the step back to Success.

  • Fix: remove/write an incomplete result at run start or on failure, and make check_step_result() parse JSON and require status == "proven".

Comment on lines +17 to +20
def _tcl_quote(value: str) -> str:
value = str(value)
escaped = value.replace("\\", "\\\\").replace('"', '\\"')
return f'"{escaped}"'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants