46 char pName[100];
int i, iObj, iFanin;
50 sprintf( pName,
"ABCCTo%d", nOuts );
51 assert( 0 == Vec_IntSize(vFanins) );
56 char * pPref[2] = {
"ABCBUF",
"ABCINV" };
58 assert( nInA == Vec_IntSize(vFanins) );
60 iObj = Bac_BoxAlloc(
p, Type, Vec_IntSize(vFanins), nOuts,
Abc_NamStrFindOrAdd(
p->pDesign->pMods, pName, NULL) );
64 char * pPref[6] = {
"ABCAND",
"ABCNAND",
"ABCOR",
"ABCNOR",
"ABCXOR",
"ABCXNOR" };
65 assert( nInA == nOuts && nInB == nOuts );
66 assert( nInA + nInB == Vec_IntSize(vFanins) );
68 iObj = Bac_BoxAlloc(
p, Type, Vec_IntSize(vFanins), nOuts,
Abc_NamStrFindOrAdd(
p->pDesign->pMods, pName, NULL) );
72 char * pPref[1] = {
"ABCMUX" };
73 assert( nInA == nOuts && nInB == nOuts );
74 assert( 1 + nInA + nInB == Vec_IntSize(vFanins) );
76 iObj = Bac_BoxAlloc(
p, Type, Vec_IntSize(vFanins), nOuts,
Abc_NamStrFindOrAdd(
p->pDesign->pMods, pName, NULL) );
80 char * pPref[1] = {
"ABCMAJ" };
81 assert( nInA == 1 && nInB == 1 && nOuts == 1 );
82 assert( 3 == Vec_IntSize(vFanins) );
84 iObj = Bac_BoxAlloc(
p, Type, Vec_IntSize(vFanins), nOuts,
Abc_NamStrFindOrAdd(
p->pDesign->pMods, pName, NULL) );
88 char * pPref[6] = {
"ABCRAND",
"ABCRNAND",
"ABCROR",
"ABCRNOR",
"ABCRXOR",
"ABCRXNOR" };
89 assert( nInA == nInB && 1 == nOuts );
90 assert( nInA + nInB == Vec_IntSize(vFanins) );
92 iObj = Bac_BoxAlloc(
p, Type, Vec_IntSize(vFanins), nOuts,
Abc_NamStrFindOrAdd(
p->pDesign->pMods, pName, NULL) );
96 char * pPref[1] = {
"ABCSEL" };
97 assert( nInA * nOuts == nInB );
98 assert( nInA + nInB == Vec_IntSize(vFanins) );
100 iObj = Bac_BoxAlloc(
p, Type, Vec_IntSize(vFanins), nOuts,
Abc_NamStrFindOrAdd(
p->pDesign->pMods, pName, NULL) );
104 char * pPref[1] = {
"ABCPSEL" };
105 assert( nInA * nOuts == nInB );
106 assert( 1 + nInA + nInB == Vec_IntSize(vFanins) );
108 iObj = Bac_BoxAlloc(
p, Type, Vec_IntSize(vFanins), nOuts,
Abc_NamStrFindOrAdd(
p->pDesign->pMods, pName, NULL) );
112 Bac_ObjSetFanin(
p, Bac_BoxBi(
p, iObj, i), iFanin );
130 int nBis = Bac_BoxBiNum(
p, iBox);
131 int nBos = Bac_BoxBoNum(
p, iBox);
134 Vec_IntClear( &
p->vArray );
137 for ( i = 0; i < nBos; i++ )
139 Vec_IntFill( &
p->vArray2, 1, Bac_BoxFanin(
p, iBox, i) );
141 Vec_IntPush( &
p->vArray, Bac_BoxBo(
p, iObj, 0) );
146 assert( nBis == 2 * nBos );
147 for ( i = 0; i < nBos; i++ )
149 Vec_IntFillTwo( &
p->vArray2, 2, Bac_BoxFanin(
p, iBox, i), Bac_BoxFanin(
p, iBox, nBos+i) );
151 Vec_IntPush( &
p->vArray, Bac_BoxBo(
p, iObj, 0) );
156 assert( nBis - 1 == 2 * nBos );
157 for ( i = 0; i < nBos; i++ )
159 Vec_IntFill( &
p->vArray2, 1, Bac_BoxFanin(
p, iBox, 0) );
160 Vec_IntPushTwo( &
p->vArray2, Bac_BoxFanin(
p, iBox, 1+i), Bac_BoxFanin(
p, iBox, 1+nBos+i) );
162 Vec_IntPush( &
p->vArray, Bac_BoxBo(
p, iObj, 0) );
167 int n, nIns = nBis / nBos;
168 assert( nBis % nBos == 0 );
169 for ( n = 1; n < 32; n++ )
170 if ( n + (1 << n) == nIns )
172 assert( n > 1 && n < 32 );
173 for ( i = 0; i < nBos; i++ )
175 Vec_IntClear( &
p->vArray2 );
176 for ( k = 0; k < n; k++ )
177 Vec_IntPush( &
p->vArray2, Bac_BoxFanin(
p, iBox, k) );
178 for ( k = 0; k < (1 << n); k++ )
179 Vec_IntPush( &
p->vArray2, Bac_BoxFanin(
p, iBox, n + (1 << n) * i + k) );
181 Vec_IntPush( &
p->vArray, Bac_BoxBo(
p, iObj, 0) );
197 Bac_BoxReplace(
p, iBox, Vec_IntArray(&
p->vArray), Vec_IntSize(&
p->vArray) );
217 assert( nBis == Bac_BoxBiNum(
p, iBox) );
220 int Carry = Bac_BoxFanin(
p, iBox, 0);
221 int nBits = Vec_IntEntry(&
p->vArray, 1);
222 assert( Vec_IntSize(&
p->vArray) == 3 );
223 assert( Vec_IntEntry(&
p->vArray, 0) == 1 );
224 assert( Vec_IntEntry(&
p->vArray, 2) == nBits );
225 Vec_IntClear( &
p->vArray );
226 for ( i = 0; i < nBits; i++ )
228 Vec_IntFill( &
p->vArray2, 1, Carry );
229 Vec_IntPushTwo( &
p->vArray2, Bac_BoxFanin(
p, iBox, 1+i), Bac_BoxFanin(
p, iBox, 1+nBits+i) );
231 Carry = Bac_BoxBo(
p, iObj, 1);
232 Vec_IntPush( &
p->vArray, Bac_BoxBo(
p, iObj, 0) );
234 Vec_IntPush( &
p->vArray, Carry );
238 int iConst, nBits = Vec_IntEntry(&
p->vArray, 0);
239 assert( Vec_IntSize(&
p->vArray) == 2 );
240 assert( Vec_IntEntry(&
p->vArray, 1) == nBits );
242 Vec_IntClear( &
p->vArray2 );
243 for ( i = 0; i < nBits; i++ )
244 Vec_IntPush( &
p->vArray2, Bac_BoxFanin(
p, iBox, nBits+i) );
247 Vec_IntClear( &
p->vArray2 );
250 Vec_IntFill( &
p->vArray2, 1, iConst+1 );
251 for ( i = 0; i < nBits; i++ )
252 Vec_IntPush( &
p->vArray2, Bac_BoxFanin(
p, iBox, i) );
253 for ( i = 0; i < nBits; i++ )
254 Vec_IntPush( &
p->vArray2, Bac_BoxBo(
p, iObj, i) );
258 Vec_IntClear( &
p->vArray );
259 for ( i = 0; i < nBits; i++ )
260 Vec_IntPush( &
p->vArray, Bac_BoxBo(
p, iObj, i) );
315 Bac_BoxReplace(
p, iBox, Vec_IntArray(&
p->vArray), Vec_IntSize(&
p->vArray) );
ABC_NAMESPACE_IMPL_START int Bac_BoxCreate(Bac_Ntk_t *p, Bac_ObjType_t Type, Vec_Int_t *vFanins, int nInA, int nInB, int nOuts)
DECLARATIONS ///.