1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
|
/**CFile****************************************************************
FileName [cbaPtrAbc.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Hierarchical word-level netlist.]
Synopsis [Simple interface with external tools.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - November 29, 2014.]
Revision [$Id: cbaPtrAbc.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
***********************************************************************/
#include "cba.h"
#include "base/abc/abc.h"
#include "map/mio/mio.h"
#include "base/main/mainInt.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Node type conversions.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
char * Ptr_HopToType( Abc_Obj_t * pObj )
{
static word uTruth, uTruths6[3] = {
ABC_CONST(0xAAAAAAAAAAAAAAAA),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
};
assert( Abc_ObjIsNode(pObj) );
uTruth = Hop_ManComputeTruth6( (Hop_Man_t *)Abc_ObjNtk(pObj)->pManFunc, (Hop_Obj_t *)pObj->pData, Abc_ObjFaninNum(pObj) );
/*
if ( uTruth == 0 ) return "CBA_BOX_C0";
if ( uTruth == ~(word)0 ) return "CBA_BOX_C1";
if ( uTruth == uTruths6[0] ) return "CBA_BOX_BUF";
if ( uTruth == ~uTruths6[0] ) return "CBA_BOX_INV";
if ( uTruth == (uTruths6[0] & uTruths6[1]) ) return "CBA_BOX_AND";
if ( uTruth ==~(uTruths6[0] & uTruths6[1]) ) return "CBA_BOX_NAND";
if ( uTruth == (uTruths6[0] | uTruths6[1]) ) return "CBA_BOX_OR";
if ( uTruth ==~(uTruths6[0] | uTruths6[1]) ) return "CBA_BOX_NOR";
if ( uTruth == (uTruths6[0] ^ uTruths6[1]) ) return "CBA_BOX_XOR";
if ( uTruth ==~(uTruths6[0] ^ uTruths6[1]) ) return "CBA_BOX_XNOR";
*/
if ( uTruth == 0 ) return "Const0T";
if ( uTruth == ~(word)0 ) return "Const1T";
if ( uTruth == uTruths6[0] ) return "BufT";
if ( uTruth == ~uTruths6[0] ) return "InvT";
if ( uTruth == (uTruths6[0] & uTruths6[1]) ) return "AndT";
if ( uTruth ==~(uTruths6[0] & uTruths6[1]) ) return "NandT";
if ( uTruth == (uTruths6[0] | uTruths6[1]) ) return "OrT";
if ( uTruth ==~(uTruths6[0] | uTruths6[1]) ) return "NorT";
if ( uTruth == (uTruths6[0] ^ uTruths6[1]) ) return "XorT";
if ( uTruth ==~(uTruths6[0] ^ uTruths6[1]) ) return "XnorT";
assert( 0 );
return NULL;
}
/**Function*************************************************************
Synopsis [Create Ptr from Abc_Ntk_t.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
char * Ptr_AbcObjName( Abc_Obj_t * pObj )
{
if ( Abc_ObjIsNet(pObj) || Abc_ObjIsBox(pObj) )
return Abc_ObjName(pObj);
if ( Abc_ObjIsCi(pObj) || Abc_ObjIsNode(pObj) )
return Ptr_AbcObjName(Abc_ObjFanout0(pObj));
if ( Abc_ObjIsCo(pObj) )
return Ptr_AbcObjName(Abc_ObjFanin0(pObj));
assert( 0 );
return NULL;
}
static int Ptr_CheckArray( Vec_Ptr_t * vArray )
{
assert( Vec_PtrSize(vArray) == Vec_PtrCap(vArray) );
return 1;
}
Vec_Ptr_t * Ptr_AbcDeriveNode( Abc_Obj_t * pObj )
{
Abc_Obj_t * pFanin; int i;
Vec_Ptr_t * vNode = Vec_PtrAllocExact( 2 + 2 * (1 + Abc_ObjFaninNum(pObj)) );
assert( Abc_ObjIsNode(pObj) );
if ( Abc_NtkHasAig(pObj->pNtk) )
Vec_PtrPush( vNode, Ptr_HopToType(pObj) );
else if ( Abc_NtkHasSop(pObj->pNtk) )
Vec_PtrPush( vNode, Ptr_SopToTypeName((char *)pObj->pData) );
else assert( 0 );
Vec_PtrPush( vNode, Ptr_AbcObjName(pObj) );
assert( Abc_ObjFaninNum(pObj) <= 2 );
Abc_ObjForEachFanin( pObj, pFanin, i )
{
Vec_PtrPush( vNode, i ? "r" : "l" );
Vec_PtrPush( vNode, Ptr_AbcObjName(pFanin) );
}
Vec_PtrPush( vNode, "o" );
Vec_PtrPush( vNode, Ptr_AbcObjName(pObj) );
assert( Ptr_CheckArray(vNode) );
return vNode;
}
Vec_Ptr_t * Ptr_AbcDeriveBox( Abc_Obj_t * pObj )
{
Abc_Obj_t * pNext; int i;
Abc_Ntk_t * pNtk = Abc_ObjModel(pObj);
Vec_Ptr_t * vBox = Vec_PtrAllocExact( 2 + 2 * Abc_ObjFaninNum(pObj) + 2 * Abc_ObjFanoutNum(pObj) );
assert( Abc_ObjIsBox(pObj) );
Vec_PtrPush( vBox, Abc_NtkName(pNtk) );
Vec_PtrPush( vBox, Ptr_AbcObjName(pObj) );
Abc_ObjForEachFanin( pObj, pNext, i )
{
Vec_PtrPush( vBox, Ptr_AbcObjName(Abc_NtkPi(pNtk, i)) );
Vec_PtrPush( vBox, Ptr_AbcObjName(pNext) );
}
Abc_ObjForEachFanout( pObj, pNext, i )
{
Vec_PtrPush( vBox, Ptr_AbcObjName(Abc_NtkPo(pNtk, i)) );
Vec_PtrPush( vBox, Ptr_AbcObjName(pNext) );
}
assert( Ptr_CheckArray(vBox) );
return vBox;
}
Vec_Ptr_t * Ptr_AbcDeriveBoxes( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj; int i;
Vec_Ptr_t * vBoxes = Vec_PtrAllocExact( Abc_NtkBoxNum(pNtk) + Abc_NtkNodeNum(pNtk) );
Abc_NtkForEachBox( pNtk, pObj, i )
Vec_PtrPush( vBoxes, Ptr_AbcDeriveBox(pObj) );
Abc_NtkForEachNode( pNtk, pObj, i )
Vec_PtrPush( vBoxes, Ptr_AbcDeriveNode(pObj) );
assert( Ptr_CheckArray(vBoxes) );
return vBoxes;
}
Vec_Ptr_t * Ptr_AbcDeriveInputs( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj; int i;
Vec_Ptr_t * vSigs = Vec_PtrAllocExact( Abc_NtkPiNum(pNtk) );
Abc_NtkForEachPi( pNtk, pObj, i )
Vec_PtrPush( vSigs, Ptr_AbcObjName(pObj) );
assert( Ptr_CheckArray(vSigs) );
return vSigs;
}
Vec_Ptr_t * Ptr_AbcDeriveOutputs( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj; int i;
Vec_Ptr_t * vSigs = Vec_PtrAllocExact( Abc_NtkPoNum(pNtk) );
Abc_NtkForEachPo( pNtk, pObj, i )
Vec_PtrPush( vSigs, Ptr_AbcObjName(pObj) );
assert( Ptr_CheckArray(vSigs) );
return vSigs;
}
Vec_Ptr_t * Ptr_AbcDeriveNtk( Abc_Ntk_t * pNtk )
{
Vec_Ptr_t * vNtk = Vec_PtrAllocExact( 5 );
Vec_PtrPush( vNtk, Abc_NtkName(pNtk) );
Vec_PtrPush( vNtk, Ptr_AbcDeriveInputs(pNtk) );
Vec_PtrPush( vNtk, Ptr_AbcDeriveOutputs(pNtk) );
Vec_PtrPush( vNtk, Vec_PtrAllocExact(0) );
Vec_PtrPush( vNtk, Ptr_AbcDeriveBoxes(pNtk) );
assert( Ptr_CheckArray(vNtk) );
return vNtk;
}
Vec_Ptr_t * Ptr_AbcDeriveDes( Abc_Ntk_t * pNtk )
{
Vec_Ptr_t * vDes;
Abc_Ntk_t * pTemp; int i;
vDes = Vec_PtrAllocExact( 1 + Vec_PtrSize(pNtk->pDesign->vModules) );
Vec_PtrPush( vDes, pNtk->pDesign->pName );
Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pTemp, i )
Vec_PtrPush( vDes, Ptr_AbcDeriveNtk(pTemp) );
assert( Ptr_CheckArray(vDes) );
return vDes;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ptr_ManExperiment( Abc_Ntk_t * pNtk )
{
abctime clk = Abc_Clock();
char * pFileName = Extra_FileNameGenericAppend(pNtk->pDesign->pName, "_out.blif");
Vec_Ptr_t * vDes = Ptr_AbcDeriveDes( pNtk );
printf( "Converting to Ptr: Memory = %6.3f MB ", 1.0*Cba_PtrMemory(vDes)/(1<<20) );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
Cba_PtrDumpBlif( pFileName, vDes );
printf( "Finished writing output file \"%s\". ", pFileName );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
Cba_PtrFree( vDes );
}
/**Function*************************************************************
Synopsis [Create Cba_Man_t from tech-ind Ptr.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Ptr_NameToType( char * pSop )
{
if ( !strcmp(pSop, "Const0T") ) return CBA_BOX_CF;
if ( !strcmp(pSop, "Const1T") ) return CBA_BOX_CT;
if ( !strcmp(pSop, "BufT") ) return CBA_BOX_BUF;
if ( !strcmp(pSop, "InvT") ) return CBA_BOX_INV;
if ( !strcmp(pSop, "AndT") ) return CBA_BOX_AND;
if ( !strcmp(pSop, "NandT") ) return CBA_BOX_NAND;
if ( !strcmp(pSop, "OrT") ) return CBA_BOX_OR;
if ( !strcmp(pSop, "NorT") ) return CBA_BOX_NOR;
if ( !strcmp(pSop, "XorT") ) return CBA_BOX_XOR;
if ( !strcmp(pSop, "XnorT") ) return CBA_BOX_XNOR;
return CBA_OBJ_BOX;
}
int Ptr_ManCountNtk( Vec_Ptr_t * vNtk )
{
Vec_Ptr_t * vInputs = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1);
Vec_Ptr_t * vOutputs = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2);
Vec_Ptr_t * vNodes = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 3);
Vec_Ptr_t * vBoxes = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 4);
Vec_Ptr_t * vBox; int i, Counter = 0;
assert( Vec_PtrSize(vNodes) == 0 );
Counter += Vec_PtrSize(vInputs);
Counter += Vec_PtrSize(vOutputs);
Vec_PtrForEachEntry( Vec_Ptr_t *, vBoxes, vBox, i )
Counter += Vec_PtrSize(vBox)/2;
return Counter;
}
int Cba_BoxCountOutputs( Cba_Ntk_t * pNtk, char * pBoxNtk )
{
int ModuleId = Cba_ManNtkFindId( pNtk->pDesign, pBoxNtk );
if ( ModuleId == 0 )
return 1;
return Cba_NtkPoNumAlloc( Cba_ManNtk(pNtk->pDesign, ModuleId) );
}
int Cba_NtkDeriveFromPtr( Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_Int_t * vMap, Vec_Int_t * vBox2Id )
{
char * pName, * pModuleName = (char *)Vec_PtrEntry(vNtk, 0);
Vec_Ptr_t * vInputs = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1);
Vec_Ptr_t * vOutputs = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2);
Vec_Ptr_t * vBoxes = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 4), * vBox;
int i, k, iObj, iTerm, NameId;
// start network with the given name
NameId = Abc_NamStrFindOrAdd( pNtk->pDesign->pStrs, pModuleName, NULL );
assert( Cba_NtkNameId(pNtk) == NameId );
// map driven NameIds into their ObjIds for PIs
Vec_PtrForEachEntry( char *, vInputs, pName, i )
{
NameId = Abc_NamStrFindOrAdd( pNtk->pDesign->pStrs, pName, NULL );
if ( Vec_IntGetEntryFull(vMap, NameId) != -1 )
{ printf( "PI with name \"%s\" is not unique module \"%s\".\n", pName, pModuleName ); return 0; }
iObj = Cba_ObjAlloc( pNtk, CBA_OBJ_PI, -1 );
Cba_ObjSetName( pNtk, iObj, Abc_Var2Lit2(NameId, CBA_NAME_BIN) );
Vec_IntSetEntryFull( vMap, NameId, iObj );
Cba_NtkAddInfo( pNtk, Abc_Var2Lit2(NameId, 1), -1, -1 );
}
// map driven NameIds into their ObjIds for BOs
Vec_IntClear( vBox2Id );
Vec_PtrForEachEntry( Vec_Ptr_t *, vBoxes, vBox, i )
{
char * pBoxNtk = (char *)Vec_PtrEntry(vBox, 0);
char * pBoxName = (char *)Vec_PtrEntry(vBox, 1);
int nOutputs = Cba_BoxCountOutputs( pNtk, pBoxNtk );
int nInputs = Vec_PtrSize(vBox)/2 - nOutputs - 1;
int NtkId = Cba_ManNtkFindId( pNtk->pDesign, pBoxNtk );
assert( Vec_PtrSize(vBox) % 2 == 0 );
assert( nOutputs > 0 && 2*(nOutputs + 1) <= Vec_PtrSize(vBox) );
iObj = Cba_BoxAlloc( pNtk, Ptr_NameToType(pBoxNtk), nInputs, nOutputs, NtkId );
if ( NtkId > 0 )
Cba_NtkSetHost( Cba_ManNtk(pNtk->pDesign, NtkId), Cba_NtkId(pNtk), iObj );
Cba_ObjSetName( pNtk, iObj, Abc_Var2Lit2(Abc_NamStrFindOrAdd(pNtk->pDesign->pStrs, pBoxName, NULL), CBA_NAME_BIN) );
Cba_BoxForEachBo( pNtk, iObj, iTerm, k )
{
pName = (char *)Vec_PtrEntry( vBox, Vec_PtrSize(vBox) - 2*(nOutputs - k) + 1 );
NameId = Abc_NamStrFindOrAdd( pNtk->pDesign->pStrs, pName, NULL );
if ( Vec_IntGetEntryFull(vMap, NameId) != -1 )
{ printf( "Signal \"%s\" has multiple drivers in module \"%s\".\n", pName, pModuleName ); return 0; }
Cba_ObjSetName( pNtk, iTerm, Abc_Var2Lit2(NameId, CBA_NAME_BIN) );
Vec_IntSetEntryFull( vMap, NameId, iTerm );
}
Vec_IntPush( vBox2Id, iObj );
}
assert( Vec_IntSize(vBox2Id) == Vec_PtrSize(vBoxes) );
// connect BIs
Vec_PtrForEachEntry( Vec_Ptr_t *, vBoxes, vBox, i )
{
iObj = Vec_IntEntry( vBox2Id, i );
Cba_BoxForEachBi( pNtk, iObj, iTerm, k )
{
pName = (char *)Vec_PtrEntry( vBox, 2*(k + 1) + 1 );
NameId = Abc_NamStrFindOrAdd( pNtk->pDesign->pStrs, pName, NULL );
if ( Vec_IntGetEntryFull(vMap, NameId) == -1 )
printf( "Signal \"%s\" in not driven in module \"%s\".\n", pName, pModuleName );
Cba_ObjSetFanin( pNtk, iTerm, Vec_IntGetEntryFull(vMap, NameId) );
}
}
// connect POs
Vec_PtrForEachEntry( char *, vOutputs, pName, i )
{
NameId = Abc_NamStrFindOrAdd( pNtk->pDesign->pStrs, pName, NULL );
if ( Vec_IntGetEntryFull(vMap, NameId) == -1 )
printf( "PO with name \"%s\" in not driven in module \"%s\".\n", pName, pModuleName );
iObj = Cba_ObjAlloc( pNtk, CBA_OBJ_PO, Vec_IntGetEntryFull(vMap, NameId) );
Cba_NtkAddInfo( pNtk, Abc_Var2Lit2(NameId, 2), -1, -1 );
}
// update map
Cba_NtkForEachCi( pNtk, iObj )
Vec_IntSetEntryFull( vMap, Cba_ObjNameId(pNtk, iObj), -1 );
// double check
Vec_IntForEachEntry( vMap, iObj, i )
assert( iObj == -1 );
assert( Cba_NtkObjNum(pNtk) == Vec_StrCap(&pNtk->vType) );
return 1;
}
Cba_Man_t * Cba_PtrTransformToCba( Vec_Ptr_t * vDes )
{
char * pName = (char *)Vec_PtrEntry(vDes, 0);
Cba_Man_t * pNew = Cba_ManAlloc( pName, Vec_PtrSize(vDes) - 1 );
Vec_Int_t * vMap = Vec_IntStartFull( 1000 );
Vec_Int_t * vBox2Id = Vec_IntAlloc( 1000 );
// create interfaces
Cba_Ntk_t * pNtk; int i;
Cba_ManForEachNtk( pNew, pNtk, i )
{
Vec_Ptr_t * vNtk = (Vec_Ptr_t *)Vec_PtrEntry(vDes, i);
Vec_Ptr_t * vInputs = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1);
Vec_Ptr_t * vOutputs = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2);
int NameId = Abc_NamStrFindOrAdd( pNew->pStrs, (char *)Vec_PtrEntry(vNtk, 0), NULL );
Cba_NtkAlloc( pNtk, NameId, Vec_PtrSize(vInputs), Vec_PtrSize(vOutputs), Ptr_ManCountNtk(vNtk) );
Cba_NtkStartNames( pNtk );
}
// parse the networks
Cba_ManForEachNtk( pNew, pNtk, i )
{
Vec_Ptr_t * vNtk = (Vec_Ptr_t *)Vec_PtrEntry(vDes, i);
if ( !Cba_NtkDeriveFromPtr( pNtk, vNtk, vMap, vBox2Id ) )
break;
}
if ( i <= Cba_ManNtkNum(pNew) )
Cba_ManFree(pNew), pNew = NULL;
Vec_IntFree( vBox2Id );
Vec_IntFree( vMap );
return pNew;
}
/**Function*************************************************************
Synopsis [Create Ptr from mapped Cba_Man_t.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Cba_NtkTransformToPtrBox( Cba_Ntk_t * p, int iBox )
{
int i, iTerm, fUser = Cba_ObjIsBoxUser( p, iBox );
Cba_Ntk_t * pBoxNtk = Cba_BoxNtk( p, iBox );
Mio_Library_t * pLib = (Mio_Library_t *)p->pDesign->pMioLib;
Mio_Gate_t * pGate = pLib ? Mio_LibraryReadGateByName( pLib, Cba_BoxNtkName(p, iBox), NULL ) : NULL;
Vec_Ptr_t * vBox = Vec_PtrAllocExact( 2*Cba_BoxSize(p, iBox) );
Vec_PtrPush( vBox, Cba_BoxNtkName(p, iBox) );
Vec_PtrPush( vBox, Cba_ObjNameStr(p, iBox) );
Cba_BoxForEachBi( p, iBox, iTerm, i )
{
Vec_PtrPush( vBox, fUser ? Cba_ObjNameStr(pBoxNtk, Cba_NtkPi(pBoxNtk, i)) : Mio_GateReadPinName(pGate, i) );
Vec_PtrPush( vBox, Cba_ObjNameStr(p, iTerm) );
}
Cba_BoxForEachBo( p, iBox, iTerm, i )
{
Vec_PtrPush( vBox, fUser ? Cba_ObjNameStr(pBoxNtk, Cba_NtkPo(pBoxNtk, i)) : Mio_GateReadOutName(pGate) );
Vec_PtrPush( vBox, Cba_ObjNameStr(p, iTerm) );
}
assert( Ptr_CheckArray(vBox) );
return vBox;
}
Vec_Ptr_t * Cba_NtkTransformToPtrBoxes( Cba_Ntk_t * p )
{
int iBox;
Vec_Ptr_t * vBoxes = Vec_PtrAllocExact( Cba_NtkBoxNum(p) );
Cba_NtkForEachBox( p, iBox )
Vec_PtrPush( vBoxes, Cba_NtkTransformToPtrBox(p, iBox) );
assert( Ptr_CheckArray(vBoxes) );
return vBoxes;
}
Vec_Ptr_t * Cba_NtkTransformToPtrInputs( Cba_Ntk_t * p )
{
int i, iTerm;
Vec_Ptr_t * vSigs = Vec_PtrAllocExact( Cba_NtkPiNum(p) );
Cba_NtkForEachPi( p, iTerm, i )
Vec_PtrPush( vSigs, Cba_ObjNameStr(p, iTerm) );
assert( Ptr_CheckArray(vSigs) );
return vSigs;
}
Vec_Ptr_t * Cba_NtkTransformToPtrOutputs( Cba_Ntk_t * p )
{
int i, iTerm;
Vec_Ptr_t * vSigs = Vec_PtrAllocExact( Cba_NtkPoNum(p) );
Cba_NtkForEachPo( p, iTerm, i )
Vec_PtrPush( vSigs, Cba_ObjNameStr(p, iTerm) );
assert( Ptr_CheckArray(vSigs) );
return vSigs;
}
Vec_Ptr_t * Cba_NtkTransformToPtr( Cba_Ntk_t * p )
{
Vec_Ptr_t * vNtk = Vec_PtrAllocExact(5);
Vec_PtrPush( vNtk, Cba_NtkName(p) );
Vec_PtrPush( vNtk, Cba_NtkTransformToPtrInputs(p) );
Vec_PtrPush( vNtk, Cba_NtkTransformToPtrOutputs(p) );
Vec_PtrPush( vNtk, Vec_PtrAllocExact(0) );
Vec_PtrPush( vNtk, Cba_NtkTransformToPtrBoxes(p) );
assert( Ptr_CheckArray(vNtk) );
return vNtk;
}
Vec_Ptr_t * Cba_PtrDeriveFromCba( Cba_Man_t * p )
{
Vec_Ptr_t * vDes;
Cba_Ntk_t * pTemp; int i;
if ( p == NULL )
return NULL;
if ( p->pMioLib == NULL )
{
printf( "Cannot transform CBA network into Ptr because it is not mapped.\n" );
return NULL;
}
Cba_ManAssignInternWordNames( p );
vDes = Vec_PtrAllocExact( 1 + Cba_ManNtkNum(p) );
Vec_PtrPush( vDes, p->pName );
Cba_ManForEachNtk( p, pTemp, i )
Vec_PtrPush( vDes, Cba_NtkTransformToPtr(pTemp) );
assert( Ptr_CheckArray(vDes) );
return vDes;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
|