mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-30 19:22:31 +00:00 
			
		
		
		
	Added opt_rmdff support for $ff cells
This commit is contained in:
		
							parent
							
								
									53655d173b
								
							
						
					
					
						commit
						2ef454c3f5
					
				
					 1 changed files with 13 additions and 5 deletions
				
			
		|  | @ -72,7 +72,11 @@ bool handle_dff(RTLIL::Module *mod, RTLIL::Cell *dff) | |||
| 	RTLIL::SigSpec sig_d, sig_q, sig_c, sig_r; | ||||
| 	RTLIL::Const val_cp, val_rp, val_rv; | ||||
| 
 | ||||
| 	if (dff->type == "$_DFF_N_" || dff->type == "$_DFF_P_") { | ||||
| 	if (dff->type == "$_FF_") { | ||||
| 		sig_d = dff->getPort("\\D"); | ||||
| 		sig_q = dff->getPort("\\Q"); | ||||
| 	} | ||||
| 	else if (dff->type == "$_DFF_N_" || dff->type == "$_DFF_P_") { | ||||
| 		sig_d = dff->getPort("\\D"); | ||||
| 		sig_q = dff->getPort("\\Q"); | ||||
| 		sig_c = dff->getPort("\\C"); | ||||
|  | @ -90,6 +94,10 @@ bool handle_dff(RTLIL::Module *mod, RTLIL::Cell *dff) | |||
| 		val_rp = RTLIL::Const(dff->type[7] == 'P', 1); | ||||
| 		val_rv = RTLIL::Const(dff->type[8] == '1', 1); | ||||
| 	} | ||||
| 	else if (dff->type == "$ff") { | ||||
| 		sig_d = dff->getPort("\\D"); | ||||
| 		sig_q = dff->getPort("\\Q"); | ||||
| 	} | ||||
| 	else if (dff->type == "$dff") { | ||||
| 		sig_d = dff->getPort("\\D"); | ||||
| 		sig_q = dff->getPort("\\Q"); | ||||
|  | @ -121,7 +129,7 @@ bool handle_dff(RTLIL::Module *mod, RTLIL::Cell *dff) | |||
| 		val_init.bits.push_back(bit.wire == NULL ? bit.data : RTLIL::State::Sx); | ||||
| 	} | ||||
| 
 | ||||
| 	if (dff->type == "$dff" && mux_drivers.has(sig_d)) { | ||||
| 	if (dff->type.in("$ff", "$dff") && mux_drivers.has(sig_d)) { | ||||
| 		std::set<RTLIL::Cell*> muxes; | ||||
| 		mux_drivers.find(sig_d, muxes); | ||||
| 		for (auto mux : muxes) { | ||||
|  | @ -138,7 +146,7 @@ bool handle_dff(RTLIL::Module *mod, RTLIL::Cell *dff) | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if (sig_c.is_fully_const() && (!sig_r.size() || !has_init || val_init == val_rv)) { | ||||
| 	if (!sig_c.empty() && sig_c.is_fully_const() && (!sig_r.size() || !has_init || val_init == val_rv)) { | ||||
| 		if (val_rv.bits.size() == 0) | ||||
| 			val_rv = val_init; | ||||
| 		mod->connect(sig_q, val_rv); | ||||
|  | @ -254,10 +262,10 @@ struct OptRmdffPass : public Pass { | |||
| 				if (!design->selected(module, cell)) | ||||
| 					continue; | ||||
| 
 | ||||
| 				if (cell->type.in("$_DFF_N_", "$_DFF_P_", | ||||
| 				if (cell->type.in("$_FF_", "$_DFF_N_", "$_DFF_P_", | ||||
| 						"$_DFF_NN0_", "$_DFF_NN1_", "$_DFF_NP0_", "$_DFF_NP1_", | ||||
| 						"$_DFF_PN0_", "$_DFF_PN1_", "$_DFF_PP0_", "$_DFF_PP1_", | ||||
| 						"$dff", "$adff")) | ||||
| 						"$ff", "$dff", "$adff")) | ||||
| 					dff_list.push_back(cell->name); | ||||
| 
 | ||||
| 				if (cell->type == "$dlatch") | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue