ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcAttach.c File Reference
#include "base/abc/abc.h"
#include "base/main/main.h"
#include "map/mio/mio.h"
Include dependency graph for abcAttach.c:

Go to the source code of this file.

Macros

#define ATTACH_FULL   (~((unsigned)0))
 DECLARATIONS ///.
 
#define ATTACH_MASK(n)
 

Functions

int Abc_NtkAttach (Abc_Ntk_t *pNtk)
 FUNCTION DEFINITIONS ///.
 

Macro Definition Documentation

◆ ATTACH_FULL

#define ATTACH_FULL   (~((unsigned)0))

DECLARATIONS ///.

CFile****************************************************************

FileName [abcAttach.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Attaches the library gates to the current network.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
abcAttach.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 32 of file abcAttach.c.

◆ ATTACH_MASK

#define ATTACH_MASK ( n)
Value:
((~((unsigned)0)) >> (32-(n)))

Definition at line 33 of file abcAttach.c.

Function Documentation

◆ Abc_NtkAttach()

int Abc_NtkAttach ( Abc_Ntk_t * pNtk)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Attaches gates from the current library to the internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 60 of file abcAttach.c.

61{
62 Mio_Library_t * pGenlib;
63 unsigned ** puTruthGates;
64 unsigned uTruths[6][2];
65 Abc_Obj_t * pNode;
66 Mio_Gate_t ** ppGates;
67 int nGates, nFanins, i;
68
69 assert( Abc_NtkIsSopLogic(pNtk) );
70
71 // check that the library is available
73 if ( pGenlib == NULL )
74 {
75 printf( "The current library is not available.\n" );
76 return 0;
77 }
78
79 // start the truth tables
80 Abc_AttachSetupTruthTables( uTruths );
81
82 // collect all the gates
83 ppGates = Mio_CollectRoots( pGenlib, 6, (float)1.0e+20, 1, &nGates, 0 );
84
85 // derive the gate truth tables
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++ )
91 Mio_DeriveTruthTable( ppGates[i], uTruths, Mio_GateReadPinNum(ppGates[i]), 6, puTruthGates[i] );
92
93 // assign the gates to pNode->pCopy
94 Abc_NtkCleanCopy( pNtk );
95 Abc_NtkForEachNode( pNtk, pNode, i )
96 {
97 nFanins = Abc_ObjFaninNum(pNode);
98 if ( nFanins == 0 )
99 {
100 if ( Abc_SopIsConst1((char *)pNode->pData) )
101 pNode->pCopy = (Abc_Obj_t *)Mio_LibraryReadConst1(pGenlib);
102 else
103 pNode->pCopy = (Abc_Obj_t *)Mio_LibraryReadConst0(pGenlib);
104 }
105 else if ( nFanins == 1 )
106 {
107 if ( Abc_SopIsBuf((char *)pNode->pData) )
108 pNode->pCopy = (Abc_Obj_t *)Mio_LibraryReadBuf(pGenlib);
109 else
110 pNode->pCopy = (Abc_Obj_t *)Mio_LibraryReadInv(pGenlib);
111 }
112 else if ( nFanins > 6 )
113 {
114 printf( "Cannot attach gate with more than 6 inputs to node %s.\n", Abc_ObjName(pNode) );
115 ABC_FREE( puTruthGates[0] );
116 ABC_FREE( puTruthGates );
117 ABC_FREE( ppGates );
118 return 0;
119 }
120 else if ( !Abc_NodeAttach( pNode, ppGates, puTruthGates, nGates, uTruths ) )
121 {
122 printf( "Could not attach the library gate to node %s.\n", Abc_ObjName(pNode) );
123 ABC_FREE( puTruthGates[0] );
124 ABC_FREE( puTruthGates );
125 ABC_FREE( ppGates );
126 return 0;
127 }
128 }
129 ABC_FREE( puTruthGates[0] );
130 ABC_FREE( puTruthGates );
131 ABC_FREE( ppGates );
132 ABC_FREE( s_pPerms );
133
134 // perform the final transformation
135 Abc_NtkForEachNode( pNtk, pNode, i )
136 {
137 if ( pNode->pCopy == NULL )
138 {
139 printf( "Some elementary gates (constant, buffer, or inverter) are missing in the library.\n" );
140 return 0;
141 }
142 }
143
144 // replace SOP representation by the gate representation
145 Abc_NtkForEachNode( pNtk, pNode, i )
146 pNode->pData = pNode->pCopy, pNode->pCopy = NULL;
147 pNtk->ntkFunc = ABC_FUNC_MAP;
149 pNtk->pManFunc = pGenlib;
150
151 printf( "Library gates are successfully attached to the nodes.\n" );
152
153 // make sure that everything is okay
154 if ( !Abc_NtkCheck( pNtk ) )
155 {
156 printf( "Abc_NtkAttach: The network check has failed.\n" );
157 return 0;
158 }
159 return 1;
160}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:540
@ ABC_FUNC_MAP
Definition abc.h:68
ABC_DLL int Abc_SopIsBuf(char *pSop)
Definition abcSop.c:756
ABC_DLL int Abc_SopIsConst1(char *pSop)
Definition abcSop.c:740
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
ABC_DLL void * Abc_FrameReadLibGen()
Definition mainFrame.c:59
void Extra_MmFlexStop(Extra_MmFlex_t *p)
struct Extra_MmFlex_t_ Extra_MmFlex_t
Definition extra.h:148
Mio_Gate_t * Mio_LibraryReadConst0(Mio_Library_t *pLib)
Definition mioApi.c:51
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
Definition mioApi.c:177
Mio_Gate_t ** Mio_CollectRoots(Mio_Library_t *pLib, int nInputs, float tDelay, int fSkipInv, int *pnGates, int fVerbose)
Definition mioUtils.c:515
void Mio_DeriveTruthTable(Mio_Gate_t *pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[])
Definition mioUtils.c:1036
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
Mio_Gate_t * Mio_LibraryReadConst1(Mio_Library_t *pLib)
Definition mioApi.c:52
Mio_Gate_t * Mio_LibraryReadInv(Mio_Library_t *pLib)
Definition mioApi.c:50
struct Mio_GateStruct_t_ Mio_Gate_t
Definition mio.h:43
Mio_Gate_t * Mio_LibraryReadBuf(Mio_Library_t *pLib)
Definition mioApi.c:49
void * pManFunc
Definition abc.h:191
Abc_NtkFunc_t ntkFunc
Definition abc.h:157
void * pData
Definition abc.h:145
Abc_Obj_t * pCopy
Definition abc.h:148
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function: