mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-08 15:13:24 +00:00
Accept (and ignore) SystemVerilog unique/priority if.
Add support to the "read_verilog -sv" parser to validate the "unique", "unique0", and "priority" keywords in contexts where they're legal according to 1800-2012 12.4.2. This affects only the grammar accepted; the behaviour of conditionals is not changed. (But accepting this syntax will provide scope for possible optimisations as future work.) Three test cases ("unique_if", "unique_if_else", and "unique_if_else_begin") verify that the keywords are accepted where legal and rejected where illegal, as described in the final paragraph of 12.4.2.
This commit is contained in:
parent
6c67b29bbb
commit
9770ece187
6 changed files with 66 additions and 2 deletions
|
@ -426,7 +426,7 @@ static const AstNode *addAsgnBinopStmt(dict<IdString, AstNode*> *attr, AstNode *
|
|||
%type <boolean> opt_property always_comb_or_latch always_or_always_ff
|
||||
%type <boolean> opt_signedness_default_signed opt_signedness_default_unsigned
|
||||
%type <integer> integer_atom_type integer_vector_type
|
||||
%type <al> attr case_attr
|
||||
%type <al> attr if_attr case_attr
|
||||
%type <ast> struct_union
|
||||
%type <ast_node_type> asgn_binop inc_or_dec_op
|
||||
%type <ast> genvar_identifier
|
||||
|
@ -2871,7 +2871,7 @@ behavioral_stmt:
|
|||
ast_stack.pop_back();
|
||||
ast_stack.pop_back();
|
||||
} |
|
||||
attr TOK_IF '(' expr ')' {
|
||||
if_attr TOK_IF '(' expr ')' {
|
||||
AstNode *node = new AstNode(AST_CASE);
|
||||
AstNode *block = new AstNode(AST_BLOCK);
|
||||
AstNode *cond = new AstNode(AST_COND, AstNode::mkconst_int(1, false, 1), block);
|
||||
|
@ -2901,6 +2901,29 @@ behavioral_stmt:
|
|||
ast_stack.pop_back();
|
||||
};
|
||||
|
||||
if_attr:
|
||||
attr {
|
||||
$$ = $1;
|
||||
} |
|
||||
attr TOK_UNIQUE0 {
|
||||
AstNode *context = ast_stack.back();
|
||||
if( context && context->type == AST_BLOCK && context->get_bool_attribute(ID::promoted_if) )
|
||||
frontend_verilog_yyerror("unique0 keyword cannot be used for 'else if' branch.");
|
||||
$$ = $1; // accept unique0 keyword, but ignore it for now
|
||||
} |
|
||||
attr TOK_PRIORITY {
|
||||
AstNode *context = ast_stack.back();
|
||||
if( context && context->type == AST_BLOCK && context->get_bool_attribute(ID::promoted_if) )
|
||||
frontend_verilog_yyerror("priority keyword cannot be used for 'else if' branch.");
|
||||
$$ = $1; // accept priority keyword, but ignore it for now
|
||||
} |
|
||||
attr TOK_UNIQUE {
|
||||
AstNode *context = ast_stack.back();
|
||||
if( context && context->type == AST_BLOCK && context->get_bool_attribute(ID::promoted_if) )
|
||||
frontend_verilog_yyerror("unique keyword cannot be used for 'else if' branch.");
|
||||
$$ = $1; // accept unique keyword, but ignore it for now
|
||||
};
|
||||
|
||||
case_attr:
|
||||
attr {
|
||||
$$ = $1;
|
||||
|
@ -2948,6 +2971,7 @@ behavioral_stmt_list:
|
|||
optional_else:
|
||||
TOK_ELSE {
|
||||
AstNode *block = new AstNode(AST_BLOCK);
|
||||
block->attributes[ID::promoted_if] = AstNode::mkconst_int(1, false );
|
||||
AstNode *cond = new AstNode(AST_COND, new AstNode(AST_DEFAULT), block);
|
||||
SET_AST_NODE_LOC(cond, @1, @1);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue