mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 19:52:31 +00:00 
			
		
		
		
	Fixes and improvements in AST const folding
This commit is contained in:
		
							parent
							
								
									db98a18edb
								
							
						
					
					
						commit
						59dd02baa2
					
				
					 2 changed files with 11 additions and 1 deletions
				
			
		|  | @ -647,7 +647,7 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint) | ||||||
| 				current_module->wires[str] = wire; | 				current_module->wires[str] = wire; | ||||||
| 			} | 			} | ||||||
| 			else if (id2ast->type == AST_PARAMETER || id2ast->type == AST_LOCALPARAM) { | 			else if (id2ast->type == AST_PARAMETER || id2ast->type == AST_LOCALPARAM) { | ||||||
| 				chunk = RTLIL::Const(id2ast->bits); | 				chunk = RTLIL::Const(id2ast->children[0]->bits); | ||||||
| 				goto use_const_chunk; | 				goto use_const_chunk; | ||||||
| 			} | 			} | ||||||
| 			else if (!id2ast || (id2ast->type != AST_WIRE && id2ast->type != AST_AUTOWIRE && | 			else if (!id2ast || (id2ast->type != AST_WIRE && id2ast->type != AST_AUTOWIRE && | ||||||
|  |  | ||||||
|  | @ -749,6 +749,7 @@ skip_dynamic_range_lvalue_expansion:; | ||||||
| 	// perform const folding when activated
 | 	// perform const folding when activated
 | ||||||
| 	if (const_fold && newNode == NULL) | 	if (const_fold && newNode == NULL) | ||||||
| 	{ | 	{ | ||||||
|  | 		std::vector<RTLIL::State> tmp_bits; | ||||||
| 		RTLIL::Const (*const_func)(const RTLIL::Const&, const RTLIL::Const&, bool, bool, int); | 		RTLIL::Const (*const_func)(const RTLIL::Const&, const RTLIL::Const&, bool, bool, int); | ||||||
| 		RTLIL::Const dummy_arg; | 		RTLIL::Const dummy_arg; | ||||||
| 
 | 
 | ||||||
|  | @ -864,7 +865,16 @@ skip_dynamic_range_lvalue_expansion:; | ||||||
| 					newNode = children[2]->clone(); | 					newNode = children[2]->clone(); | ||||||
| 			} | 			} | ||||||
| 			break; | 			break; | ||||||
|  | 		case AST_CONCAT: | ||||||
|  | 			for (auto it = children.begin(); it != children.end(); it++) { | ||||||
|  | 				if ((*it)->type != AST_CONSTANT) | ||||||
|  | 					goto not_const; | ||||||
|  | 				tmp_bits.insert(tmp_bits.end(), (*it)->bits.begin(), (*it)->bits.end()); | ||||||
|  | 			} | ||||||
|  | 			newNode = mkconst_bits(tmp_bits, is_signed); | ||||||
|  | 			break; | ||||||
| 		default: | 		default: | ||||||
|  | 		not_const: | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue