Skip to content

Commit f2ede55

Browse files
committed
build.plat: introduce quote_sdc
quote_sdc is needed because synplify excepts signal names to be quoted but wrapped in curly braces.
1 parent 0aa962d commit f2ede55

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

nmigen/build/plat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ def tcl_escape(string):
395395
def tcl_quote(string):
396396
return '"' + re.sub(r"([$[\\])", r"\\\1", string) + '"'
397397

398+
def sdc_quote(string):
399+
return "{" + re.sub(r"([${}\\])", r"\\\1", string) + "}"
400+
398401
def verbose(arg):
399402
if "NMIGEN_verbose" in os.environ:
400403
return arg
@@ -417,6 +420,7 @@ def render(source, origin, syntax=None):
417420
compiled.environment.filters["ascii_escape"] = ascii_escape
418421
compiled.environment.filters["tcl_escape"] = tcl_escape
419422
compiled.environment.filters["tcl_quote"] = tcl_quote
423+
compiled.environment.filters["sdc_quote"] = sdc_quote
420424
except jinja2.TemplateSyntaxError as e:
421425
e.args = ("{} (at {}:{})".format(e.message, origin, e.lineno),)
422426
raise

nmigen/vendor/lattice_ecp5.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ class LatticeECP5Platform(TemplatedPlatform):
240240
set_hierarchy_separator {/}
241241
{% for net_signal, port_signal, frequency in platform.iter_clock_constraints() -%}
242242
{% if port_signal is not none -%}
243-
create_clock -name {{port_signal.name|tcl_quote}} -period {{1000000000/frequency}} [get_ports {{port_signal.name|tcl_quote}}]
243+
create_clock -name {{port_signal.name|sdc_quote}} -period {{1000000000/frequency}} [get_ports {{port_signal.name|sdc_quote}}]
244244
{% else -%}
245-
create_clock -name {{net_signal.name|tcl_quote}} -period {{1000000000/frequency}} [get_nets {{net_signal|hierarchy("/")|tcl_quote}}]
245+
create_clock -name {{net_signal.name|sdc_quote}} -period {{1000000000/frequency}} [get_nets {{net_signal|hierarchy("/")|sdc_quote}}]
246246
{% endif %}
247247
{% endfor %}
248248
{{get_override("add_constraints")|default("# (add_constraints placeholder)")}}

nmigen/vendor/lattice_machxo_2_3l.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ class LatticeMachXO2Or3LPlatform(TemplatedPlatform):
107107
set_hierarchy_separator {/}
108108
{% for net_signal, port_signal, frequency in platform.iter_clock_constraints() -%}
109109
{% if port_signal is not none -%}
110-
create_clock -name {{port_signal.name|tcl_quote}} -period {{1000000000/frequency}} [get_ports {{port_signal.name|tcl_quote}}]
110+
create_clock -name {{port_signal.name|sdc_quote}} -period {{1000000000/frequency}} [get_ports {{port_signal.name|sdc_quote}}]
111111
{% else -%}
112-
create_clock -name {{net_signal.name|tcl_quote}} -period {{1000000000/frequency}} [get_nets {{net_signal|hierarchy("/")|tcl_quote}}]
112+
create_clock -name {{net_signal.name|sdc_quote}} -period {{1000000000/frequency}} [get_nets {{net_signal|hierarchy("/")|sdc_quote}}]
113113
{% endif %}
114114
{% endfor %}
115115
{{get_override("add_constraints")|default("# (add_constraints placeholder)")}}

0 commit comments

Comments
 (0)