build.plat,vendor._lattice: add Diamond escaping quirk.
Partially addresses #546.
This commit is contained in:
parent
f0dd01eadf
commit
8da55299a5
|
@ -330,8 +330,15 @@ class TemplatedPlatform(Platform):
|
||||||
return f"_{ord(match.group(1)[0]):02x}_"
|
return f"_{ord(match.group(1)[0]):02x}_"
|
||||||
return "".join(escape_one(m) for m in re.finditer(r"([^A-Za-z0-9_])|(.)", string))
|
return "".join(escape_one(m) for m in re.finditer(r"([^A-Za-z0-9_])|(.)", string))
|
||||||
|
|
||||||
def tcl_quote(string):
|
def tcl_quote(string, quirk=None):
|
||||||
return '"' + re.sub(r"([$[\\])", r"\\\1", string) + '"'
|
escaped = '"' + re.sub(r"([$[\\])", r"\\\1", string) + '"'
|
||||||
|
if quirk == "Diamond":
|
||||||
|
# Diamond seems to assign `clk\$2` as a name for the Verilog net `\clk$2 `, and
|
||||||
|
# `clk\\\$2` as a name for the Verilog net `\clk\$2 `.
|
||||||
|
return escaped.replace("\\", "\\\\")
|
||||||
|
else:
|
||||||
|
assert quirk is None
|
||||||
|
return escaped
|
||||||
|
|
||||||
def verbose(arg):
|
def verbose(arg):
|
||||||
if get_override_flag("verbose"):
|
if get_override_flag("verbose"):
|
||||||
|
|
|
@ -686,9 +686,9 @@ class LatticePlatform(TemplatedPlatform):
|
||||||
set_hierarchy_separator {/}
|
set_hierarchy_separator {/}
|
||||||
{% for net_signal, port_signal, frequency in platform.iter_clock_constraints() -%}
|
{% for net_signal, port_signal, frequency in platform.iter_clock_constraints() -%}
|
||||||
{% if port_signal is not none -%}
|
{% if port_signal is not none -%}
|
||||||
create_clock -name {{port_signal.name|tcl_quote}} -period {{1000000000/frequency}} [get_ports {{port_signal.name|tcl_quote}}]
|
create_clock -name {{port_signal.name|tcl_quote("Diamond")}} -period {{1000000000/frequency}} [get_ports {{port_signal.name|tcl_quote("Diamond")}}]
|
||||||
{% else -%}
|
{% else -%}
|
||||||
create_clock -name {{net_signal.name|tcl_quote}} -period {{1000000000/frequency}} [get_nets {{net_signal|hierarchy("/")|tcl_quote}}]
|
create_clock -name {{net_signal.name|tcl_quote("Diamond")}} -period {{1000000000/frequency}} [get_nets {{net_signal|hierarchy("/")|tcl_quote("Diamond")}}]
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{{get_override("add_constraints")|default("# (add_constraints placeholder)")}}
|
{{get_override("add_constraints")|default("# (add_constraints placeholder)")}}
|
||||||
|
|
Loading…
Reference in a new issue