From 0f274291e7e3909a2e3f3783fdecd2c5fd565841 Mon Sep 17 00:00:00 2001 From: Jean THOMAS Date: Mon, 2 Sep 2024 18:12:57 +0200 Subject: [PATCH] vendor._gowin: fix clock name quotes for Gowin IDE 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. --- amaranth/vendor/_gowin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/amaranth/vendor/_gowin.py b/amaranth/vendor/_gowin.py index 0272085fb..d20ed3d65 100644 --- a/amaranth/vendor/_gowin.py +++ b/amaranth/vendor/_gowin.py @@ -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)")}}