mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 13:29:12 +00:00 
			
		
		
		
	Added RTLIL::Module::Add{Inv,And,Or,Xor,Mux}Gate API
This commit is contained in:
		
							parent
							
								
									9a1accf692
								
							
						
					
					
						commit
						77e5968323
					
				
					 2 changed files with 48 additions and 0 deletions
				
			
		| 
						 | 
					@ -932,6 +932,48 @@ DEF_METHOD(addPmux,     "$pmux",       1)
 | 
				
			||||||
DEF_METHOD(addSafePmux, "$safe_pmux",  1)
 | 
					DEF_METHOD(addSafePmux, "$safe_pmux",  1)
 | 
				
			||||||
#undef DEF_METHOD
 | 
					#undef DEF_METHOD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DEF_METHOD_2(_func, _type, _P1, _P2) \
 | 
				
			||||||
 | 
						RTLIL::Cell* RTLIL::Module::_func(RTLIL::IdString name, RTLIL::SigSpec sig1, RTLIL::SigSpec sig2) { \
 | 
				
			||||||
 | 
							RTLIL::Cell *cell = new RTLIL::Cell;                \
 | 
				
			||||||
 | 
							cell->name = name;                                  \
 | 
				
			||||||
 | 
							cell->type = _type;                                 \
 | 
				
			||||||
 | 
							cell->connections["\\" #_P1] = sig1;               \
 | 
				
			||||||
 | 
							cell->connections["\\" #_P2] = sig2;               \
 | 
				
			||||||
 | 
							add(cell);                                          \
 | 
				
			||||||
 | 
							return cell;                                        \
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					#define DEF_METHOD_3(_func, _type, _P1, _P2, _P3) \
 | 
				
			||||||
 | 
						RTLIL::Cell* RTLIL::Module::_func(RTLIL::IdString name, RTLIL::SigSpec sig1, RTLIL::SigSpec sig2, RTLIL::SigSpec sig3) { \
 | 
				
			||||||
 | 
							RTLIL::Cell *cell = new RTLIL::Cell;                \
 | 
				
			||||||
 | 
							cell->name = name;                                  \
 | 
				
			||||||
 | 
							cell->type = _type;                                 \
 | 
				
			||||||
 | 
							cell->connections["\\" #_P1] = sig1;               \
 | 
				
			||||||
 | 
							cell->connections["\\" #_P2] = sig2;               \
 | 
				
			||||||
 | 
							cell->connections["\\" #_P3] = sig3;               \
 | 
				
			||||||
 | 
							add(cell);                                          \
 | 
				
			||||||
 | 
							return cell;                                        \
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					#define DEF_METHOD_4(_func, _type, _P1, _P2, _P3, _P4) \
 | 
				
			||||||
 | 
						RTLIL::Cell* RTLIL::Module::_func(RTLIL::IdString name, RTLIL::SigSpec sig1, RTLIL::SigSpec sig2, RTLIL::SigSpec sig3, RTLIL::SigSpec sig4) { \
 | 
				
			||||||
 | 
							RTLIL::Cell *cell = new RTLIL::Cell;                \
 | 
				
			||||||
 | 
							cell->name = name;                                  \
 | 
				
			||||||
 | 
							cell->type = _type;                                 \
 | 
				
			||||||
 | 
							cell->connections["\\" #_P1] = sig1;                \
 | 
				
			||||||
 | 
							cell->connections["\\" #_P2] = sig2;                \
 | 
				
			||||||
 | 
							cell->connections["\\" #_P3] = sig3;                \
 | 
				
			||||||
 | 
							cell->connections["\\" #_P4] = sig4;                \
 | 
				
			||||||
 | 
							add(cell);                                          \
 | 
				
			||||||
 | 
							return cell;                                        \
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					DEF_METHOD_2(addInvGate, "$_INV_", A, Y)
 | 
				
			||||||
 | 
					DEF_METHOD_3(addAndGate, "$_AND_", A, B, Y)
 | 
				
			||||||
 | 
					DEF_METHOD_3(addOrGate,  "$_OR_",  A, B, Y)
 | 
				
			||||||
 | 
					DEF_METHOD_3(addXorGate, "$_XOR_", A, B, Y)
 | 
				
			||||||
 | 
					DEF_METHOD_4(addMuxGate, "$_MUX_", A, B, S, Y)
 | 
				
			||||||
 | 
					#undef DEF_METHOD_2
 | 
				
			||||||
 | 
					#undef DEF_METHOD_3
 | 
				
			||||||
 | 
					#undef DEF_METHOD_4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RTLIL::Cell* RTLIL::Module::addPow(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool a_signed, bool b_signed)
 | 
					RTLIL::Cell* RTLIL::Module::addPow(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool a_signed, bool b_signed)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	RTLIL::Cell *cell = new RTLIL::Cell;
 | 
						RTLIL::Cell *cell = new RTLIL::Cell;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -351,6 +351,12 @@ struct RTLIL::Module {
 | 
				
			||||||
	RTLIL::Cell* addAdff (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_arst, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q,
 | 
						RTLIL::Cell* addAdff (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_arst, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q,
 | 
				
			||||||
			RTLIL::Const arst_value, bool clk_polarity = true, bool arst_polarity = true);
 | 
								RTLIL::Const arst_value, bool clk_polarity = true, bool arst_polarity = true);
 | 
				
			||||||
	RTLIL::Cell* addDlatch (RTLIL::IdString name, RTLIL::SigSpec sig_en, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool en_polarity = true);
 | 
						RTLIL::Cell* addDlatch (RTLIL::IdString name, RTLIL::SigSpec sig_en, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool en_polarity = true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						RTLIL::Cell* addInvGate  (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y);
 | 
				
			||||||
 | 
						RTLIL::Cell* addAndGate  (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y);
 | 
				
			||||||
 | 
						RTLIL::Cell* addOrGate   (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y);
 | 
				
			||||||
 | 
						RTLIL::Cell* addXorGate  (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y);
 | 
				
			||||||
 | 
						RTLIL::Cell* addMuxGate  (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_s, RTLIL::SigSpec sig_y);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct RTLIL::Wire {
 | 
					struct RTLIL::Wire {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue