Repository: chipsalliance/f4pga-sdf-timing (language: python)

Issue:
Names with escaped brackets do not match
Hi all,
I have found another issue regarding matching of more obscure valid sdf. Valid names in verilog netlists include names such as `TESTENV/reset_synchronizer_genblk1\[0\]\.ff_1_reg/RESET`. The grammar to match the name does not match to this, instead returning an error that the character "\" is an invalid name. I will provide a pull request for this issue soon. 
Names with escaped brackets do not match
Hi all,
I have found another issue regarding matching of more obscure valid sdf. Valid names in verilog netlists include names such as `TESTENV/reset_synchronizer_genblk1\[0\]\.ff_1_reg/RESET`. The grammar to match the name does not match to this, instead returning an error that the character "\" is an invalid name. I will provide a pull request for this issue soon. 


Discussion / hints:

Fix patch:
diff --git a/sdf_timing/sdflex.py b/sdf_timing/sdflex.py
index 85c253c..3f172aa 100644
--- a/sdf_timing/sdflex.py
+++ b/sdf_timing/sdflex.py
@@ -150,7 +150,7 @@ def t_SLASH(t):
 
 
 def t_STRING(t):
-    r'[a-zA-Z0-9_\/.\[\]]+'
+    r'[a-zA-Z0-9_\/.\[\]\\]+'
     t.type = reserved.get(t.value, 'STRING')
     return t
 


Test patch:
diff --git a/sdf_timing/tests/data/escaped_name.sdf b/sdf_timing/tests/data/escaped_name.sdf
new file mode 100644
index 0000000..47f5560
--- /dev/null
+++ b/sdf_timing/tests/data/escaped_name.sdf
@@ -0,0 +1,16 @@
+(DELAYFILE
+    (SDFVERSION "3.0")
+    (TIMESCALE 1ps)
+
+    (CELL
+        (CELLTYPE "vpr_interconnect")
+        (INSTANCE dut/routing_segment_b0_output_0_0_to_c0_input_0_0)
+        (DELAY
+            (ABSOLUTE
+                (INTERCONNECT clk_i TESTENV/clock_generator/clk_mux/CLK1 (1.4:8.4:8.4)(1.6:7.7:7.7))
+                (INTERCONNECT rstn_i TESTENV/reset_synchronizer_genblk1\[0\]\.ff_1_reg/RESET (3.7:3.5:3.5)(3.8:3.5:3.5))
+                (INTERCONNECT rstn_i TESTENV/reset_synchronizer_genblk1\[0\]\.ff_2_reg/RESET (3.7:3.5:3.5)(3.8:3.5:3.5))
+            )
+        )
+    )
+)
\ No newline at end of file
diff --git a/sdf_timing/tests/data/golden/escaped_name.sdf b/sdf_timing/tests/data/golden/escaped_name.sdf
new file mode 100644
index 0000000..47f5560
--- /dev/null
+++ b/sdf_timing/tests/data/golden/escaped_name.sdf
@@ -0,0 +1,16 @@
+(DELAYFILE
+    (SDFVERSION "3.0")
+    (TIMESCALE 1ps)
+
+    (CELL
+        (CELLTYPE "vpr_interconnect")
+        (INSTANCE dut/routing_segment_b0_output_0_0_to_c0_input_0_0)
+        (DELAY
+            (ABSOLUTE
+                (INTERCONNECT clk_i TESTENV/clock_generator/clk_mux/CLK1 (1.4:8.4:8.4)(1.6:7.7:7.7))
+                (INTERCONNECT rstn_i TESTENV/reset_synchronizer_genblk1\[0\]\.ff_1_reg/RESET (3.7:3.5:3.5)(3.8:3.5:3.5))
+                (INTERCONNECT rstn_i TESTENV/reset_synchronizer_genblk1\[0\]\.ff_2_reg/RESET (3.7:3.5:3.5)(3.8:3.5:3.5))
+            )
+        )
+    )
+)
\ No newline at end of file