mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-28 10:19:26 +00:00 
			
		
		
		
	abstract: factor out emit_mux_anyseq
This commit is contained in:
		
							parent
							
								
									27928f74ac
								
							
						
					
					
						commit
						fe4642887a
					
				
					 1 changed files with 19 additions and 29 deletions
				
			
		|  | @ -11,9 +11,24 @@ struct EnableLogic { | ||||||
| 	bool pol; | 	bool pol; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | void emit_mux_anyseq(Module* mod, const SigSpec& mux_input, const SigSpec& mux_output, EnableLogic enable) { | ||||||
|  | 	auto anyseq = mod->Anyseq(NEW_ID, mux_input.size()); | ||||||
|  | 	SigSpec mux_a, mux_b; | ||||||
|  | 	if (enable.pol) { | ||||||
|  | 		mux_a = mux_input; | ||||||
|  | 		mux_b = anyseq; | ||||||
|  | 	} else { | ||||||
|  | 		mux_a = anyseq; | ||||||
|  | 		mux_b = mux_input; | ||||||
|  | 	} | ||||||
|  | 	(void)mod->addMux(NEW_ID, | ||||||
|  | 		mux_a, | ||||||
|  | 		mux_b, | ||||||
|  | 		enable.wire, | ||||||
|  | 		mux_output); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| bool abstract_state_port(FfData& ff, SigSpec& port_sig, std::set<int> offsets, EnableLogic enable) { | bool abstract_state_port(FfData& ff, SigSpec& port_sig, std::set<int> offsets, EnableLogic enable) { | ||||||
| 	// Construct abstract value
 |  | ||||||
| 	auto anyseq = ff.module->Anyseq(NEW_ID, offsets.size()); |  | ||||||
| 	Wire* abstracted = ff.module->addWire(NEW_ID, offsets.size()); | 	Wire* abstracted = ff.module->addWire(NEW_ID, offsets.size()); | ||||||
| 	SigSpec mux_input; | 	SigSpec mux_input; | ||||||
| 	int abstracted_idx = 0; | 	int abstracted_idx = 0; | ||||||
|  | @ -27,19 +42,7 @@ bool abstract_state_port(FfData& ff, SigSpec& port_sig, std::set<int> offsets, E | ||||||
| 			abstracted_idx++; | 			abstracted_idx++; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	SigSpec mux_a, mux_b; | 	emit_mux_anyseq(ff.module, mux_input, abstracted, enable); | ||||||
| 	if (enable.pol) { |  | ||||||
| 		mux_a = mux_input; |  | ||||||
| 		mux_b = anyseq; |  | ||||||
| 	} else { |  | ||||||
| 		mux_a = anyseq; |  | ||||||
| 		mux_b = mux_input; |  | ||||||
| 	} |  | ||||||
| 	(void)ff.module->addMux(NEW_ID, |  | ||||||
| 		mux_a, |  | ||||||
| 		mux_b, |  | ||||||
| 		enable.wire, |  | ||||||
| 		abstracted); |  | ||||||
| 	(void)ff.emit(); | 	(void)ff.emit(); | ||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
|  | @ -102,7 +105,6 @@ unsigned int abstract_state(Module* mod, EnableLogic enable) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool abstract_value_port(Module* mod, Cell* cell, std::set<int> offsets, IdString port_name, EnableLogic enable) { | bool abstract_value_port(Module* mod, Cell* cell, std::set<int> offsets, IdString port_name, EnableLogic enable) { | ||||||
| 	auto anyseq = mod->Anyseq(NEW_ID, offsets.size()); |  | ||||||
| 	Wire* to_abstract = mod->addWire(NEW_ID, offsets.size()); | 	Wire* to_abstract = mod->addWire(NEW_ID, offsets.size()); | ||||||
| 	SigSpec mux_input; | 	SigSpec mux_input; | ||||||
| 	SigSpec mux_output; | 	SigSpec mux_output; | ||||||
|  | @ -121,19 +123,7 @@ bool abstract_value_port(Module* mod, Cell* cell, std::set<int> offsets, IdStrin | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	cell->setPort(port_name, new_port); | 	cell->setPort(port_name, new_port); | ||||||
| 	SigSpec mux_a, mux_b; | 	emit_mux_anyseq(mod, mux_input, mux_output, enable); | ||||||
| 	if (enable.pol) { |  | ||||||
| 		mux_a = mux_input; |  | ||||||
| 		mux_b = anyseq; |  | ||||||
| 	} else { |  | ||||||
| 		mux_a = anyseq; |  | ||||||
| 		mux_b = mux_input; |  | ||||||
| 	} |  | ||||||
| 	(void)mod->addMux(NEW_ID, |  | ||||||
| 		mux_a, |  | ||||||
| 		mux_b, |  | ||||||
| 		enable.wire, |  | ||||||
| 		mux_output); |  | ||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue