mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 05:19:11 +00:00 
			
		
		
		
	Allow localparams in constant functions
This commit is contained in:
		
							parent
							
								
									082cbcb4c7
								
							
						
					
					
						commit
						74abc3bbfd
					
				
					 2 changed files with 18 additions and 3 deletions
				
			
		| 
						 | 
					@ -4488,6 +4488,18 @@ AstNode *AstNode::eval_const_function(AstNode *fcall)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		log_assert(variables.count(str) != 0);
 | 
							log_assert(variables.count(str) != 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (stmt->type == AST_LOCALPARAM)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								while (stmt->simplify(true, false, false, 1, -1, false, true)) { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (!backup_scope.count(stmt->str))
 | 
				
			||||||
 | 
									backup_scope[stmt->str] = current_scope[stmt->str];
 | 
				
			||||||
 | 
								current_scope[stmt->str] = stmt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								block->children.erase(block->children.begin());
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (stmt->type == AST_ASSIGN_EQ)
 | 
							if (stmt->type == AST_ASSIGN_EQ)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if (stmt->children.at(0)->type == AST_IDENTIFIER && stmt->children.at(0)->children.size() != 0 &&
 | 
								if (stmt->children.at(0)->type == AST_IDENTIFIER && stmt->children.at(0)->children.size() != 0 &&
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,15 +1,18 @@
 | 
				
			||||||
module top(out);
 | 
					module top(out);
 | 
				
			||||||
	function integer operation;
 | 
						function integer operation;
 | 
				
			||||||
		input integer num;
 | 
							input integer num;
 | 
				
			||||||
 | 
							localparam incr = 1;
 | 
				
			||||||
 | 
							localparam mult = 1;
 | 
				
			||||||
		begin
 | 
							begin
 | 
				
			||||||
			operation = 0;
 | 
								operation = 0;
 | 
				
			||||||
			begin : op_i
 | 
								begin : op_i
 | 
				
			||||||
				integer i;
 | 
									integer i;
 | 
				
			||||||
				for (i = 0; i < 2; i = i + 1)
 | 
									for (i = 0; i * mult < 2; i = i + incr)
 | 
				
			||||||
				begin : op_j
 | 
									begin : op_j
 | 
				
			||||||
					integer j;
 | 
										integer j;
 | 
				
			||||||
					for (j = i; j < i * 2; j = j + 1)
 | 
										localparam other_mult = 2;
 | 
				
			||||||
						num = num + 1;
 | 
										for (j = i; j < i * other_mult; j = j + incr)
 | 
				
			||||||
 | 
											num = num + incr;
 | 
				
			||||||
				end
 | 
									end
 | 
				
			||||||
				num = num * 2;
 | 
									num = num * 2;
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue