mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	Resolve struct member package types
This commit is contained in:
		
							parent
							
								
									db13c6df2b
								
							
						
					
					
						commit
						26db5a11d3
					
				
					 2 changed files with 11 additions and 0 deletions
				
			
		|  | @ -173,6 +173,13 @@ static bool isInLocalScope(const std::string *name) | ||||||
| 
 | 
 | ||||||
| static AstNode *getTypeDefinitionNode(std::string type_name) | static AstNode *getTypeDefinitionNode(std::string type_name) | ||||||
| { | { | ||||||
|  | 	// check package types | ||||||
|  | 	if (type_name.find("::") != std::string::npos && pkg_user_types.count(type_name) > 0) { | ||||||
|  | 		auto typedef_node = pkg_user_types[type_name]; | ||||||
|  | 		log_assert(typedef_node->type == AST_TYPEDEF); | ||||||
|  | 		return typedef_node->children[0]; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	// check current scope then outer scopes for a name | 	// check current scope then outer scopes for a name | ||||||
| 	for (auto it = user_type_stack.rbegin(); it != user_type_stack.rend(); ++it) { | 	for (auto it = user_type_stack.rbegin(); it != user_type_stack.rend(); ++it) { | ||||||
| 		if (it->count(type_name) > 0) { | 		if (it->count(type_name) > 0) { | ||||||
|  |  | ||||||
|  | @ -16,6 +16,7 @@ module top; | ||||||
| 		bit		a; | 		bit		a; | ||||||
| 		logic[7:0]	b; | 		logic[7:0]	b; | ||||||
| 		t_t		t; | 		t_t		t; | ||||||
|  | 		p::p_t		ps; | ||||||
| 	} s_t; | 	} s_t; | ||||||
| 
 | 
 | ||||||
| 	s_t s; | 	s_t s; | ||||||
|  | @ -29,6 +30,7 @@ module top; | ||||||
| 	assign s1 = s; | 	assign s1 = s; | ||||||
| 	assign ps.a = 8'hAA; | 	assign ps.a = 8'hAA; | ||||||
| 	assign ps.b = 8'h55; | 	assign ps.b = 8'h55; | ||||||
|  | 	assign s.ps = ps; | ||||||
| 
 | 
 | ||||||
| 	always_comb begin | 	always_comb begin | ||||||
| 		assert(s.a == 1'b1); | 		assert(s.a == 1'b1); | ||||||
|  | @ -37,6 +39,8 @@ module top; | ||||||
| 		assert(s1.t == 8'h55); | 		assert(s1.t == 8'h55); | ||||||
| 		assert(ps.a == 8'hAA); | 		assert(ps.a == 8'hAA); | ||||||
| 		assert(ps.b == 8'h55); | 		assert(ps.b == 8'h55); | ||||||
|  | 		assert(s.ps.a == 8'hAA); | ||||||
|  | 		assert(s.ps.b == 8'h55); | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| endmodule | endmodule | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue