mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 05:19:11 +00:00 
			
		
		
		
	Added support for repeat stmt in const functions
This commit is contained in:
		
							parent
							
								
									7c8a7b2131
								
							
						
					
					
						commit
						0b1ce63a19
					
				
					 1 changed files with 19 additions and 0 deletions
				
			
		| 
						 | 
					@ -2001,6 +2001,25 @@ AstNode *AstNode::eval_const_function(AstNode *fcall)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (stmt->type == AST_REPEAT)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								AstNode *num = stmt->children.at(0)->clone();
 | 
				
			||||||
 | 
								num->replace_variables(variables, fcall);
 | 
				
			||||||
 | 
								while (num->simplify(true, false, false, 1, -1, false, true)) { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (num->type != AST_CONSTANT)
 | 
				
			||||||
 | 
									log_error("Non-constant expression in constant function at %s:%d (called from %s:%d).\n",
 | 
				
			||||||
 | 
											stmt->filename.c_str(), stmt->linenum, fcall->filename.c_str(), fcall->linenum);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								block->children.erase(block->children.begin());
 | 
				
			||||||
 | 
								for (int i = 0; i < num->bitsAsConst().as_int(); i++)
 | 
				
			||||||
 | 
									block->children.insert(block->children.begin(), stmt->children.at(1)->clone());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								delete stmt;
 | 
				
			||||||
 | 
								delete num;
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (stmt->type == AST_CASE)
 | 
							if (stmt->type == AST_CASE)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			AstNode *expr = stmt->children.at(0)->clone();
 | 
								AstNode *expr = stmt->children.at(0)->clone();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue