ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
acbAbc.c
Go to the documentation of this file.
1
20
21#include "acb.h"
22#include "base/abc/abc.h"
23#include "aig/miniaig/ndr.h"
24#include "acbPar.h"
25
27
31
35
48{
49 Acb_Man_t * pMan = Acb_ManAlloc( Abc_NtkSpec(p), 1, NULL, NULL, NULL, NULL );
50 int i, k, NameId = Abc_NamStrFindOrAdd( pMan->pStrs, Abc_NtkName(p), NULL );
51 Acb_Ntk_t * pNtk = Acb_NtkAlloc( pMan, NameId, Abc_NtkCiNum(p), Abc_NtkCoNum(p), Abc_NtkObjNum(p) );
52 Abc_Obj_t * pObj, * pFanin;
53 assert( Abc_NtkIsSopLogic(p) );
54 pNtk->nFaninMax = 6;
55 Abc_NtkForEachCi( p, pObj, i )
56 pObj->iTemp = Acb_ObjAlloc( pNtk, ABC_OPER_CI, 0, 0 );
57 Abc_NtkForEachNode( p, pObj, i )
58 pObj->iTemp = Acb_ObjAlloc( pNtk, ABC_OPER_LUT, Abc_ObjFaninNum(pObj), 0 );
59 Abc_NtkForEachCo( p, pObj, i )
60 pObj->iTemp = Acb_ObjAlloc( pNtk, ABC_OPER_CO, 1, 0 );
61 Abc_NtkForEachNode( p, pObj, i )
62 Abc_ObjForEachFanin( pObj, pFanin, k )
63 Acb_ObjAddFanin( pNtk, pObj->iTemp, pFanin->iTemp );
64 Abc_NtkForEachCo( p, pObj, i )
65 Acb_ObjAddFanin( pNtk, pObj->iTemp, Abc_ObjFanin(pObj, 0)->iTemp );
66 Acb_NtkCleanObjTruths( pNtk );
67 Abc_NtkForEachNode( p, pObj, i )
68 Acb_ObjSetTruth( pNtk, pObj->iTemp, Abc_SopToTruth((char *)pObj->pData, Abc_ObjFaninNum(pObj)) );
69 Acb_NtkSetRegNum( pNtk, Abc_NtkLatchNum(p) );
70 Acb_NtkAdd( pMan, pNtk );
71 return pNtk;
72}
74{
75 Acb_Man_t * pMan = Acb_ManAlloc( Abc_NtkSpec(p), 1, NULL, NULL, NULL, NULL );
76 int i, k, NameId = Abc_NamStrFindOrAdd( pMan->pStrs, Abc_NtkName(p), NULL );
77 Acb_Ntk_t * pNtk = Acb_NtkAlloc( pMan, NameId, Abc_NtkCiNum(p), Abc_NtkCoNum(p), Abc_NtkObjNumMax(p)-1 );
78 Abc_Obj_t * pObj, * pFanin;
79 assert( Abc_NtkIsSopLogic(p) );
80 pNtk->nFaninMax = 6;
81 for ( i = 1; i < Abc_NtkObjNumMax(p); i++ )
82 {
83 pObj = Abc_NtkObj( p, i );
84 if ( pObj == NULL )
85 Acb_ObjAlloc( pNtk, ABC_OPER_NONE, 0, 0 );
86 else if ( Abc_ObjIsCi(pObj) )
87 pObj->iTemp = Acb_ObjAlloc( pNtk, ABC_OPER_CI, 0, 0 );
88 else if ( Abc_ObjIsCo(pObj) )
89 pObj->iTemp = Acb_ObjAlloc( pNtk, ABC_OPER_CO, 1, 0 );
90 else if ( Abc_ObjIsNode(pObj) )
91 pObj->iTemp = Acb_ObjAlloc( pNtk, ABC_OPER_LUT, Abc_ObjFaninNum(pObj), 0 );
92 else assert( 0 );
93 assert( pObj == NULL || pObj->iTemp == (int)Abc_ObjId(pObj) );
94 }
95 Abc_NtkForEachNode( p, pObj, i )
96 Abc_ObjForEachFanin( pObj, pFanin, k )
97 Acb_ObjAddFanin( pNtk, pObj->iTemp, pFanin->iTemp );
98 Abc_NtkForEachCo( p, pObj, i )
99 Acb_ObjAddFanin( pNtk, pObj->iTemp, Abc_ObjFanin(pObj, 0)->iTemp );
100 Acb_NtkCleanObjTruths( pNtk );
101 Abc_NtkForEachNode( p, pObj, i )
102 Acb_ObjSetTruth( pNtk, pObj->iTemp, Abc_SopToTruth((char *)pObj->pData, Abc_ObjFaninNum(pObj)) );
103 Acb_NtkSetRegNum( pNtk, Abc_NtkLatchNum(p) );
104 Acb_NtkAdd( pMan, pNtk );
105 return pNtk;
106}
107
120{
121 int i, k, iObj, iFanin;
123 Mem_Flex_t * pMan = (Mem_Flex_t *)pNtkNew->pManFunc;
124 Vec_Int_t * vCover = Vec_IntAlloc( 1000 );
125 Acb_NtkCleanObjCopies( p );
126 Acb_NtkForEachCi( p, iObj, i )
127 Acb_ObjSetCopy( p, iObj, Abc_ObjId(Abc_NtkCi(pNtkNew, i)) );
128 Acb_NtkForEachNode( p, iObj )
129 {
130 Abc_Obj_t * pObjNew = Abc_NtkCreateNode( pNtkNew );
131 pObjNew->pData = Abc_SopCreateFromTruthIsop( pMan, Acb_ObjFaninNum(p, iObj), Acb_ObjTruthP(p, iObj), vCover );
132 Acb_ObjSetCopy( p, iObj, Abc_ObjId(pObjNew) );
133 }
134 Vec_IntFree( vCover );
135 Acb_NtkForEachNode( p, iObj )
136 {
137 Abc_Obj_t * pObjNew = Abc_NtkObj(pNtkNew, Acb_ObjCopy(p, iObj));
138 Acb_ObjForEachFanin( p, iObj, iFanin, k )
139 Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Acb_ObjCopy(p, iFanin)) );
140 assert( Abc_SopGetVarNum((char *)pObjNew->pData) == Abc_ObjFaninNum(pObjNew) );
141 }
142 Acb_NtkForEachCoDriver( p, iFanin, i )
143 Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), Abc_NtkObj(pNtkNew, Acb_ObjCopy(p, iFanin)) );
144 if ( !Abc_NtkCheck( pNtkNew ) )
145 {
146 printf( "Acb_NtkToAbc: The network check has failed.\n" );
147 Abc_NtkDelete( pNtkNew );
148 return NULL;
149 }
150 return pNtkNew;
151}
152
164Acb_Ntk_t * Acb_NtkFromNdr( char * pFileName, void * pModule, Abc_Nam_t * pNames, Vec_Int_t * vWeights, int nNameIdMax )
165{
166 Ndr_Data_t * p = (Ndr_Data_t *)pModule;
167 Acb_Man_t * pMan = Acb_ManAlloc( pFileName, 1, Abc_NamRef(pNames), NULL, NULL, NULL );
168 int k, NameId = Abc_NamStrFindOrAdd( pMan->pStrs, pMan->pName, NULL );
169 int Mod = 2, Obj, Type, nArray, * pArray, ObjId;
170 int Token0 = Abc_NamStrFind( pMan->pStrs, "1\'b0" );
171 Acb_Ntk_t * pNtk = Acb_NtkAlloc( pMan, NameId, Ndr_DataCiNum(p, Mod), Ndr_DataCoNum(p, Mod), Ndr_DataObjNum(p, Mod) );
172 Vec_Int_t * vMap = Vec_IntStart( nNameIdMax );
173 Acb_NtkCleanObjWeights( pNtk );
174 Acb_NtkCleanObjNames( pNtk );
175 Ndr_ModForEachPi( p, Mod, Obj )
176 {
177 NameId = Ndr_ObjReadBody( p, Obj, NDR_OUTPUT );
178 ObjId = Acb_ObjAlloc( pNtk, ABC_OPER_CI, 0, 0 );
179 Vec_IntWriteEntry( vMap, NameId, ObjId );
180 Acb_ObjSetName( pNtk, ObjId, NameId );
181 Acb_ObjSetWeight( pNtk, ObjId, vWeights ? Vec_IntEntry(vWeights, NameId) : 1 );
182 }
183 Ndr_ModForEachTarget( p, Mod, Obj )
184 {
185 NameId = Ndr_DataEntry( p, Obj );
186 ObjId = Acb_ObjAlloc( pNtk, ABC_OPER_CONST_F, 0, 0 );
187 Vec_IntWriteEntry( vMap, NameId, ObjId );
188 Acb_ObjSetName( pNtk, ObjId, NameId );
189 Vec_IntPush( &pNtk->vTargets, ObjId );
190 }
191 Ndr_ModForEachNode( p, Mod, Obj )
192 {
193 NameId = Ndr_ObjReadBody( p, Obj, NDR_OUTPUT );
194 nArray = Ndr_ObjReadArray( p, Obj, NDR_INPUT, &pArray );
195 Type = Ndr_ObjReadBody( p, Obj, NDR_OPERTYPE );
196 ObjId = Acb_ObjAlloc( pNtk, (Acb_ObjType_t) Type, nArray, 0 );
197 Vec_IntWriteEntry( vMap, NameId, ObjId );
198 Acb_ObjSetName( pNtk, ObjId, NameId );
199 }
200 Ndr_ModForEachNode( p, Mod, Obj )
201 {
202 int NameId = Ndr_ObjReadBody( p, Obj, NDR_OUTPUT );
203 char * pName = Abc_NamStr( pMan->pStrs, NameId );
204 ObjId = Vec_IntEntry( vMap, NameId );
205 nArray = Ndr_ObjReadArray( p, Obj, NDR_INPUT, &pArray );
206 for ( k = 0; k < nArray; k++ )
207 {
208 if ( Vec_IntEntry(vMap, pArray[k]) == 0 )
209 printf( "Cannot find fanin %d of node \"%s\".\n", k, pName );
210 Acb_ObjAddFanin( pNtk, ObjId, Vec_IntEntry(vMap, pArray[k]) );
211 }
212 Acb_ObjSetWeight( pNtk, ObjId, vWeights ? Vec_IntEntry(vWeights, NameId) : 1 );
213 }
214 Ndr_ModForEachPo( p, Mod, Obj )
215 {
216 int NameId = Ndr_ObjReadBody( p, Obj, NDR_OUTPUT );
217 char * pName = Abc_NamStr( pMan->pStrs, NameId );
218 nArray = Ndr_ObjReadArray( p, Obj, NDR_INPUT, &pArray );
219 assert( nArray == 1 );
220 ObjId = Acb_ObjAlloc( pNtk, ABC_OPER_CO, 1, 0 );
221 if ( Vec_IntEntry(vMap, pArray[0]) == 0 )
222 {
223 printf( "Adding constant 0 driver to non-driven PO \"%s\".\n", pName );
224 Vec_IntWriteEntry( vMap, pArray[0], Token0 );
225 }
226 Acb_ObjAddFanin( pNtk, ObjId, Vec_IntEntry(vMap, pArray[0]) );
227 Acb_ObjSetName( pNtk, ObjId, pArray[0] );
228 }
229 Vec_IntFree( vMap );
230 Acb_NtkSetRegNum( pNtk, 0 );
231 Acb_NtkAdd( pMan, pNtk );
232 return pNtk;
233}
234
247{
248 memset( pPars, 0, sizeof(Acb_Par_t) );
249 pPars->nLutSize = 4; // LUT size
250 pPars->nTfoLevMax = 2; // the maximum fanout levels
251 pPars->nTfiLevMax = 3; // the maximum fanin levels
252 pPars->nFanoutMax = 20; // the maximum number of fanouts
253 pPars->nWinNodeMax = 100; // the maximum number of nodes in the window
254 pPars->nGrowthLevel = 0; // the maximum allowed growth in level
255 pPars->nBTLimit = 0; // the maximum number of conflicts in one SAT run
256 pPars->nNodesMax = 0; // the maximum number of nodes to try
257 pPars->iNodeOne = 0; // one particular node to try
258 pPars->fArea = 1; // performs optimization for area
259 pPars->fUseAshen = 0; // use Ashenhurst decomposition
260 pPars->fMoreEffort = 0; // enables using more effort
261 pPars->fVerbose = 0; // enable basic stats
262 pPars->fVeryVerbose = 0; // enable detailed stats
263}
264
277{
278 extern void Acb_NtkOpt( Acb_Ntk_t * p, Acb_Par_t * pPars );
279 Abc_Ntk_t * pNtkNew;
280 Acb_Ntk_t * p = Acb_NtkFromAbc( pNtk );
281 Acb_NtkOpt( p, pPars );
282 pNtkNew = Acb_NtkToAbc( pNtk, p );
283 Acb_ManFree( p->pDesign );
284 return pNtkNew;
285}
286
298Abc_Ntk_t * Abc_NtkOptPush( Abc_Ntk_t * pNtk, int nLutSize, int fVerbose )
299{
300 extern void Acb_NtkPushLogic( Acb_Ntk_t * p, int nLutSize, int fVerbose );
301 Abc_Ntk_t * pNtkNew;
302 Acb_Ntk_t * p = Acb_NtkFromAbc( pNtk );
303 Acb_NtkPushLogic( p, nLutSize, fVerbose );
304 pNtkNew = Acb_NtkToAbc( pNtk, p );
305 Acb_ManFree( p->pDesign );
306 return pNtkNew;
307}
308
312
313
315
Acb_ObjType_t
INCLUDES ///.
Definition abcOper.h:41
@ ABC_OPER_LUT
Definition abcOper.h:127
@ ABC_OPER_CI
Definition abcOper.h:45
@ ABC_OPER_CONST_F
Definition abcOper.h:50
@ ABC_OPER_NONE
Definition abcOper.h:42
@ ABC_OPER_CO
Definition abcOper.h:46
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
ABC_DLL char * Abc_SopCreateFromTruthIsop(Mem_Flex_t *pMan, int nVars, word *pTruth, Vec_Int_t *vCover)
Definition abcSop.c:462
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
@ ABC_NTK_LOGIC
Definition abc.h:57
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
ABC_DLL word Abc_SopToTruth(char *pSop, int nInputs)
Definition abcSop.c:1314
@ ABC_FUNC_SOP
Definition abc.h:65
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition abcNtk.c:157
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Acb_ParSetDefault(Acb_Par_t *pPars)
Definition acbAbc.c:246
Abc_Ntk_t * Abc_NtkOptMfse(Abc_Ntk_t *pNtk, Acb_Par_t *pPars)
Definition acbAbc.c:276
Acb_Ntk_t * Acb_NtkFromNdr(char *pFileName, void *pModule, Abc_Nam_t *pNames, Vec_Int_t *vWeights, int nNameIdMax)
Definition acbAbc.c:164
Acb_Ntk_t * Acb_NtkFromAbc(Abc_Ntk_t *p)
Definition acbAbc.c:73
Abc_Ntk_t * Acb_NtkToAbc(Abc_Ntk_t *pNtk, Acb_Ntk_t *p)
Definition acbAbc.c:119
ABC_NAMESPACE_IMPL_START Acb_Ntk_t * Acb_NtkFromAbc2(Abc_Ntk_t *p)
DECLARATIONS ///.
Definition acbAbc.c:47
Abc_Ntk_t * Abc_NtkOptPush(Abc_Ntk_t *pNtk, int nLutSize, int fVerbose)
Definition acbAbc.c:298
void Acb_NtkOpt(Acb_Ntk_t *pNtk, Acb_Par_t *pPars)
Definition acbMfs.c:1576
typedefABC_NAMESPACE_HEADER_START struct Acb_Par_t_ Acb_Par_t
INCLUDES ///.
Definition acbPar.h:38
void Acb_NtkPushLogic(Acb_Ntk_t *p, int nLutSize, int fVerbose)
Definition acbPush.c:325
#define Acb_NtkForEachCoDriver(p, iObj, i)
Definition acb.h:340
#define Acb_NtkForEachCi(p, iObj, i)
Definition acb.h:336
struct Acb_Ntk_t_ Acb_Ntk_t
Definition acb.h:47
struct Acb_Man_t_ Acb_Man_t
Definition acb.h:48
#define Acb_ObjForEachFanin(p, iObj, iFanin, k)
Definition acb.h:373
#define Acb_NtkForEachNode(p, i)
Definition acb.h:362
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
@ NDR_INPUT
Definition ndr.h:103
@ NDR_OPERTYPE
Definition ndr.h:105
@ NDR_OUTPUT
Definition ndr.h:104
struct Ndr_Data_t_ Ndr_Data_t
BASIC TYPES ///.
Definition ndr.h:119
#define Ndr_ModForEachPo(p, Mod, Obj)
Definition ndr.h:159
#define Ndr_ModForEachTarget(p, Mod, Obj)
Definition ndr.h:167
#define Ndr_ModForEachPi(p, Mod, Obj)
Definition ndr.h:155
#define Ndr_ModForEachNode(p, Mod, Obj)
Definition ndr.h:163
void * pManFunc
Definition abc.h:191
void * pData
Definition abc.h:145
int iTemp
Definition abc.h:149
char * pName
Definition acb.h:107
Abc_Nam_t * pStrs
Definition acb.h:109
Vec_Int_t vTargets
Definition acb.h:86
int nFaninMax
Definition acb.h:66
int Abc_NamStrFind(Abc_Nam_t *p, char *pStr)
Definition utilNam.c:433
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
Definition utilNam.c:453
Abc_Nam_t * Abc_NamRef(Abc_Nam_t *p)
Definition utilNam.c:195
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
Definition utilNam.c:555
typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
INCLUDES ///.
Definition utilNam.h:39
#define assert(ex)
Definition util_old.h:213
char * memset()