diff --git a/frontends/verilog/Makefile.inc b/frontends/verilog/Makefile.inc index 2c923f0b7..d19e67536 100644 --- a/frontends/verilog/Makefile.inc +++ b/frontends/verilog/Makefile.inc @@ -6,7 +6,7 @@ GENFILES += frontends/verilog/verilog_lexer.cc frontends/verilog/verilog_parser.tab.cc: frontends/verilog/verilog_parser.y $(Q) mkdir -p $(dir $@) - $(P) $(BISON) -Wall -Werror -o $@ -d -r all -b frontends/verilog/verilog_parser $< + $(P) $(BISON) -Wall -Wcex -Werror -o $@ -d -r all -b frontends/verilog/verilog_parser $< frontends/verilog/verilog_parser.tab.hh: frontends/verilog/verilog_parser.tab.cc diff --git a/frontends/verilog/verilog_lexer.l b/frontends/verilog/verilog_lexer.l index 8a3734302..92028c877 100644 --- a/frontends/verilog/verilog_lexer.l +++ b/frontends/verilog/verilog_lexer.l @@ -224,6 +224,7 @@ TIME_SCALE_SUFFIX [munpf]?s "begin" { return TOK_BEGIN; } "end" { return TOK_END; } "if" { return TOK_IF; } +"ifnone" { return TOK_IFNONE; } "else" { return TOK_ELSE; } "for" { return TOK_FOR; } "posedge" { return TOK_POSEDGE; } diff --git a/frontends/verilog/verilog_parser.y b/frontends/verilog/verilog_parser.y index fc236fa29..d1973d3ec 100644 --- a/frontends/verilog/verilog_parser.y +++ b/frontends/verilog/verilog_parser.y @@ -402,7 +402,7 @@ static const AstNode *addAsgnBinopStmt(dict *attr, AstNode * %token TOK_INPUT TOK_OUTPUT TOK_INOUT TOK_WIRE TOK_WAND TOK_WOR TOK_REG TOK_LOGIC %token TOK_INTEGER TOK_SIGNED TOK_ASSIGN TOK_ALWAYS TOK_INITIAL %token TOK_ALWAYS_FF TOK_ALWAYS_COMB TOK_ALWAYS_LATCH -%token TOK_BEGIN TOK_END TOK_IF TOK_ELSE TOK_FOR TOK_WHILE TOK_REPEAT +%token TOK_BEGIN TOK_END TOK_IF TOK_ELSE TOK_IFNONE TOK_FOR TOK_WHILE TOK_REPEAT %token TOK_DPI_FUNCTION TOK_POSEDGE TOK_NEGEDGE TOK_OR TOK_AUTOMATIC %token TOK_CASE TOK_CASEX TOK_CASEZ TOK_ENDCASE TOK_DEFAULT %token TOK_FUNCTION TOK_ENDFUNCTION TOK_TASK TOK_ENDTASK TOK_SPECIFY @@ -1542,18 +1542,60 @@ list_of_specparam_assignments: specparam_assignment: ignspec_id '=' ignspec_expr ; -ignspec_opt_cond: - TOK_IF '(' ignspec_expr ')' | %empty; - path_declaration : simple_path_declaration ';' // | edge_sensitive_path_declaration - // | state_dependent_path_declaration + | state_dependent_path_declaration ';' ; simple_path_declaration : - ignspec_opt_cond parallel_path_description '=' path_delay_value | - ignspec_opt_cond full_path_description '=' path_delay_value + parallel_path_description '=' path_delay_value | + full_path_description '=' path_delay_value + ; + +state_dependent_path_declaration: + TOK_IF '(' module_path_expression ')' simple_path_declaration + // | TOK_IF '(' module_path_expression ')' edge_sensitive_path_declaration + | TOK_IFNONE simple_path_declaration + ; + +module_path_expression: + module_path_primary + // Flatten out unary_operator to avoid shift/reduce conflict + | '!' attr module_path_primary { delete $2; } + | '~' attr module_path_primary { delete $2; } + | '&' attr module_path_primary { delete $2; } + | OP_NAND attr module_path_primary { delete $2; } + | '|' attr module_path_primary { delete $2; } + | OP_NOR attr module_path_primary { delete $2; } + | '^' attr module_path_primary { delete $2; } + | OP_XNOR attr module_path_primary { delete $2; } + // Flatten out binary_operator to avoid shift/reduce conflict + | module_path_expression OP_EQ attr module_path_expression { delete $3; } + | module_path_expression OP_NE attr module_path_expression { delete $3; } + | module_path_expression OP_LAND attr module_path_expression { delete $3; } + | module_path_expression OP_LOR attr module_path_expression { delete $3; } + | module_path_expression '&' attr module_path_expression { delete $3; } + | module_path_expression '|' attr module_path_expression { delete $3; } + | module_path_expression '^' attr module_path_expression { delete $3; } + | module_path_expression OP_XNOR attr module_path_expression { delete $3; } + // | module_path_conditional_expression + ; + +module_path_primary: + number + | TOK_ID { delete $1; } + // Deviate from specification: Normally string would not be allowed, however they are necessary for the ecp5 tests + | TOK_STRING { delete $1; } + // | module_path_concatenation + // | module_path_multiple_concatenation + // | function_subroutine_call + // | '(' module_path_minmax_expression ')' + ; + +number: + integral_number { delete $1; } + | TOK_REALVAL { delete $1; } ; path_delay_value :