Skip to content

Commit

Permalink
vendor._gowin: fix clock name quotes for Gowin IDE
Browse files Browse the repository at this point in the history
Gowin IDE seems unhappy with quotes in clock signal names. For instance,
with the following SDC:

create_clock -name "clk50_0__io" -period 20.0 [get_ports
    {clk50_0__io}]

Gowin IDE will complain with the following error message:

ERROR  (TA2000) : "top.sdc":2 | 'syntax error' near token '-period'

Changing quotes with curly braces fixes the issue.
  • Loading branch information
jeanthom authored and whitequark committed Sep 3, 2024
1 parent 9243901 commit 0f27429
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions amaranth/vendor/_gowin.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,15 @@ def _osc_div(self):
file delete -force {{name}}.fs
file copy -force impl/pnr/project.fs {{name}}.fs
""",
# Gowin is using neither Tcl nor the Synopsys code to parse SDC files, so the grammar
# deviates from the usual (eg. no quotes, no nested braces).
"{{name}}.sdc": r"""
// {{autogenerated}}
{% for signal, frequency in platform.iter_signal_clock_constraints() -%}
create_clock -name {{signal.name|tcl_quote}} -period {{1000000000/frequency}} [get_nets {{signal|hierarchy("/")|tcl_quote}}]
create_clock -name {{ "{" }}{{signal.name}}{{ "}" }} -period {{1000000000/frequency}} [get_nets {{signal|hierarchy("/")|tcl_quote}}]
{% endfor %}
{% for port, frequency in platform.iter_port_clock_constraints() -%}
create_clock -name {{port.name|tcl_quote}} -period {{1000000000/frequency}} [get_ports
create_clock -name {{ "{" }}{{port.name}}{{ "}" }} -period {{1000000000/frequency}} [get_ports
{{ "{" }}{{port.name}}{{ "}" }}]
{% endfor %}
{{get_override("add_constraints")|default("// (add_constraints placeholder)")}}
Expand Down

0 comments on commit 0f27429

Please sign in to comment.