32 #define ATTACH_FULL (~((unsigned)0))
33 #define ATTACH_MASK(n) ((~((unsigned)0)) >> (32-(n)))
38 static int Abc_AttachCompare(
unsigned ** puTruthGates,
int nGates,
unsigned * uTruthNode );
40 static void Abc_TruthPermute(
char *
pPerm,
int nVars,
unsigned * uTruthNode,
unsigned * uTruthPerm );
63 unsigned ** puTruthGates;
64 unsigned uTruths[6][2];
67 int nGates, nFanins, i;
73 if ( pGenlib == NULL )
75 printf(
"The current library is not available.\n" );
86 puTruthGates =
ABC_ALLOC(
unsigned *, nGates );
87 puTruthGates[0] =
ABC_ALLOC(
unsigned, 2 * nGates );
88 for ( i = 1; i < nGates; i++ )
89 puTruthGates[i] = puTruthGates[i-1] + 2;
90 for ( i = 0; i < nGates; i++ )
105 else if ( nFanins == 1 )
112 else if ( nFanins > 6 )
114 printf(
"Cannot attach gate with more than 6 inputs to node %s.\n",
Abc_ObjName(pNode) );
120 else if ( !
Abc_NodeAttach( pNode, ppGates, puTruthGates, nGates, uTruths ) )
122 printf(
"Could not attach the library gate to node %s.\n",
Abc_ObjName(pNode) );
137 if ( pNode->
pCopy == NULL )
139 printf(
"Some elementary gates (constant, buffer, or inverter) are missing in the library.\n" );
151 printf(
"Library gates are successfully attached to the nodes.\n" );
156 printf(
"Abc_NtkAttach: The network check has failed.\n" );
177 unsigned uTruthNode[2];
185 pGate =
Abc_AttachFind( ppGates, puTruthGates, nGates, uTruthNode, Perm );
191 pTempInts[i] = pFanin->
Id;
192 for ( i = 0; i < nFanins; i++ )
193 pNode->
vFanins.pArray[Perm[i]] = pTempInts[i];
213 for ( v = 0; v < 5; v++ )
216 for ( m = 0; m < 32; m++ )
217 for ( v = 0; v < 5; v++ )
219 uTruths[v][0] |= (1 << m);
221 for ( v = 0; v < 5; v++ )
222 uTruths[v][1] = uTruths[v][0];
241 unsigned uSignCube[2];
266 uSignCube[0] &= ~uTruthsIn[k][0];
267 else if ( Value ==
'1' )
268 uSignCube[0] &= uTruthsIn[k][0];
270 uTruthRes[0] |= uSignCube[0];
273 uTruthRes[0] = ~uTruthRes[0];
290 uSignCube[0] &= ~uTruthsIn[k][0];
291 uSignCube[1] &= ~uTruthsIn[k][1];
293 else if ( Value ==
'1' )
295 uSignCube[0] &= uTruthsIn[k][0];
296 uSignCube[1] &= uTruthsIn[k][1];
299 uTruthRes[0] |= uSignCube[0];
300 uTruthRes[1] |= uSignCube[1];
306 uTruthRes[0] = ~uTruthRes[0];
307 uTruthRes[1] = ~uTruthRes[1];
325 unsigned uTruthPerm[2];
331 for ( v = 0; v < 6; v++ )
333 return ppGates[iNum];
347 for ( v = 0; v < 6; v++ )
349 return ppGates[iNum];
369 for ( i = 0; i < nGates; i++ )
370 if ( puTruthGates[i][0] == uTruthNode[0] && puTruthGates[i][1] == uTruthNode[1] )
388 int nMints, iMintPerm, iMint, v;
389 uTruthPerm[0] = uTruthPerm[1] = 0;
390 nMints = (1 << nVars);
391 for ( iMint = 0; iMint < nMints; iMint++ )
393 if ( (uTruthNode[iMint>>5] & (1 << (iMint&31))) == 0 )
396 for ( v = 0; v < nVars; v++ )
397 if ( iMint & (1 << v) )
398 iMintPerm |= (1 << pPerm[v]);
399 uTruthPerm[iMintPerm>>5] |= (1 << (iMintPerm&31));
Mio_Gate_t * Mio_LibraryReadBuf(Mio_Library_t *pLib)
ABC_DLL void * Abc_FrameReadLibGen()
#define Abc_SopForEachCube(pSop, nFanins, pCube)
static int Abc_AttachCompare(unsigned **puTruthGates, int nGates, unsigned *uTruthNode)
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
#define ABC_ALLOC(type, num)
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
static int Abc_NtkIsSopLogic(Abc_Ntk_t *pNtk)
#define Abc_CubeForEachVar(pCube, Value, i)
ABC_DLL int Abc_SopIsBuf(char *pSop)
Mio_Gate_t * Mio_LibraryReadConst1(Mio_Library_t *pLib)
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
#define ABC_NAMESPACE_IMPL_END
STRUCTURE DEFINITIONS ///.
ABC_DLL int Abc_SopIsConst1(char *pSop)
static Mio_Gate_t * Abc_AttachFind(Mio_Gate_t **ppGates, unsigned **puTruthGates, int nGates, unsigned *uTruthNode, int *Perm)
static void Abc_AttachComputeTruth(char *pSop, unsigned uTruthsIn[][2], unsigned *uTruthNode)
void Mio_DeriveTruthTable(Mio_Gate_t *pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[])
static void Abc_AttachSetupTruthTables(unsigned uTruths[][2])
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_NAMESPACE_IMPL_START
#define Abc_ObjForEachFanin(pObj, pFanin, i)
#define ATTACH_FULL
DECLARATIONS ///.
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Mio_Gate_t ** Mio_CollectRoots(Mio_Library_t *pLib, int nInputs, float tDelay, int fSkipInv, int *pnGates, int fVerbose)
static int Abc_NodeAttach(Abc_Obj_t *pNode, Mio_Gate_t **ppGates, unsigned **puTruthGates, int nGates, unsigned uTruths[][2])
ABC_DLL int Abc_SopGetVarNum(char *pSop)
int Abc_NtkAttach(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
static void Abc_TruthPermute(char *pPerm, int nVars, unsigned *uTruthNode, unsigned *uTruthPerm)
Mio_Gate_t * Mio_LibraryReadConst0(Mio_Library_t *pLib)
Mio_Gate_t * Mio_LibraryReadInv(Mio_Library_t *pLib)
ABC_DLL int Abc_SopGetPhase(char *pSop)