From dcd9f0af23f9b580b044890452ecf1aef59bbb85 Mon Sep 17 00:00:00 2001 From: TimRudy <3942818+TimRudy@users.noreply.github.com> Date: Wed, 24 Feb 2021 15:48:15 -0500 Subject: [PATCH] Extend "delay" expressions to handle pair and triplet, i.e. rise, fall and turn-off (#2566) --- frontends/verilog/verilog_parser.y | 9 +- tests/verilog/delay_mintypmax.ys | 213 +++++++++++++++++++++++++++ tests/verilog/delay_risefall.ys | 225 +++++++++++++++++++++++++++++ 3 files changed, 445 insertions(+), 2 deletions(-) create mode 100644 tests/verilog/delay_mintypmax.ys create mode 100644 tests/verilog/delay_risefall.ys diff --git a/frontends/verilog/verilog_parser.y b/frontends/verilog/verilog_parser.y index 7fbd2aa27..89e686818 100644 --- a/frontends/verilog/verilog_parser.y +++ b/frontends/verilog/verilog_parser.y @@ -609,12 +609,17 @@ interface_body_stmt: param_decl | localparam_decl | typedef_decl | defparam_decl | wire_decl | always_stmt | assign_stmt | modport_stmt; +mintypmax_expr: + expr { delete $1; } | + expr ':' expr ':' expr { delete $1; delete $3; delete $5; }; + non_opt_delay: '#' TOK_ID { delete $2; } | '#' TOK_CONSTVAL { delete $2; } | '#' TOK_REALVAL { delete $2; } | - '#' '(' expr ')' { delete $3; } | - '#' '(' expr ':' expr ':' expr ')' { delete $3; delete $5; delete $7; }; + '#' '(' mintypmax_expr ')' | + '#' '(' mintypmax_expr ',' mintypmax_expr ')' | + '#' '(' mintypmax_expr ',' mintypmax_expr ',' mintypmax_expr ')'; delay: non_opt_delay | %empty; diff --git a/tests/verilog/delay_mintypmax.ys b/tests/verilog/delay_mintypmax.ys new file mode 100644 index 000000000..74359f557 --- /dev/null +++ b/tests/verilog/delay_mintypmax.ys @@ -0,0 +1,213 @@ +logger -expect-no-warnings +read_verilog <> b) >>> c; +endmodule +EOT + +design -reset +logger -expect-no-warnings +read_verilog < inA[1]) out <= 1'b1; + else if (inA[0] < inA[1] - hyst) out <= 1'b0; + end +endmodule +EOT + +design -reset +logger -expect-no-warnings +read_verilog <> b) >>> c; +endmodule +EOT + +design -reset +logger -expect-no-warnings +read_verilog < inA[1]) out <= 1'b1; + else if (inA[0] < inA[1] - hyst) out <= 1'b0; + end +endmodule +EOT + +design -reset +logger -expect-no-warnings +read_verilog < inA[1]) out <= 1'b1; + else if (inA[0] < inA[1] - hyst) out <= 1'b0; + end +endmodule +EOT + +design -reset +logger -expect-no-warnings +read_verilog <