mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-30 19:22:31 +00:00 
			
		
		
		
	Merge pull request #5141 from garytwong/unique-if
Accept (and ignore) SystemVerilog unique/priority if.
This commit is contained in:
		
						commit
						489a12d6c1
					
				
					 9 changed files with 189 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