mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-30 19:22:31 +00:00 
			
		
		
		
	Only run derive on blackbox modules when ports have dynamic size
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
		
							parent
							
								
									ce6695e22c
								
							
						
					
					
						commit
						ae9286386d
					
				
					 4 changed files with 24 additions and 1 deletions
				
			
		|  | @ -239,6 +239,7 @@ namespace AST | |||
| 		bool has_const_only_constructs(bool &recommend_const_eval); | ||||
| 		void replace_variables(std::map<std::string, varinfo_t> &variables, AstNode *fcall); | ||||
| 		AstNode *eval_const_function(AstNode *fcall); | ||||
| 		bool is_simple_const_expr(); | ||||
| 
 | ||||
| 		// create a human-readable text representation of the AST (for debugging)
 | ||||
| 		void dumpAst(FILE *f, std::string indent) const; | ||||
|  |  | |||
|  | @ -328,6 +328,15 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage, | |||
| 		for (size_t i = 0; i < children.size(); i++) { | ||||
| 			AstNode *node = children[i]; | ||||
| 			if (node->type == AST_WIRE) { | ||||
| 				if (node->children.size() == 1 && node->children[0]->type == AST_RANGE) { | ||||
| 					for (auto c : node->children[0]->children) { | ||||
| 						if (!c->is_simple_const_expr()) { | ||||
| 							if (attributes.count("\\dynports")) | ||||
| 								delete attributes.at("\\dynports"); | ||||
| 							attributes["\\dynports"] = AstNode::mkconst_int(1, true); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				if (this_wire_scope.count(node->str) > 0) { | ||||
| 					AstNode *first_node = this_wire_scope[node->str]; | ||||
| 					if (first_node->is_input && node->is_reg) | ||||
|  | @ -3323,6 +3332,16 @@ bool AstNode::has_const_only_constructs(bool &recommend_const_eval) | |||
| 	return false; | ||||
| } | ||||
| 
 | ||||
| bool AstNode::is_simple_const_expr() | ||||
| { | ||||
| 	if (type == AST_IDENTIFIER) | ||||
| 		return false; | ||||
| 	for (auto child : children) | ||||
| 		if (!child->is_simple_const_expr()) | ||||
| 			return false; | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| // helper function for AstNode::eval_const_function()
 | ||||
| void AstNode::replace_variables(std::map<std::string, AstNode::varinfo_t> &variables, AstNode *fcall) | ||||
| { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue