ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcHieNew.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "misc/vec/vec.h"
#include "misc/util/utilNam.h"
#include "misc/extra/extra.h"
#include "abc.h"
#include "aig/gia/gia.h"
Include dependency graph for abcHieNew.c:

Go to the source code of this file.

Classes

struct  Au_Obj_t_
 
struct  Au_Ntk_t_
 
struct  Au_Man_t_
 

Macros

#define AU_MAX_FANINS   0x1FFFFFFF
 DECLARATIONS ///.
 
#define Au_ManForEachNtk(p, pNtk, i)
 
#define Au_ManForEachNtkReverse(p, pNtk, i)
 
#define Au_ObjForEachFaninId(pObj, hFanin, i)
 
#define Au_BoxForEachFanoutId(pObj, hFanout, i)
 
#define Au_ObjForEachFanin(pObj, pFanin, i)
 
#define Au_BoxForEachFanout(pObj, pFanout, i)
 
#define Au_NtkForEachPi(p, pObj, i)
 
#define Au_NtkForEachPo(p, pObj, i)
 
#define Au_NtkForEachObj(p, pObj, i)
 
#define Au_NtkForEachNode(p, pObj, i)
 
#define Au_NtkForEachBox(p, pObj, i)
 
#define AU_VAL0   1
 
#define AU_VAL1   2
 
#define AU_VALX   3
 

Typedefs

typedef struct Au_Man_t_ Au_Man_t
 
typedef struct Au_Ntk_t_ Au_Ntk_t
 
typedef struct Au_Obj_t_ Au_Obj_t
 

Enumerations

enum  Au_Type_t {
  AU_OBJ_NONE , AU_OBJ_CONST0 , AU_OBJ_PI , AU_OBJ_PO ,
  AU_OBJ_FAN , AU_OBJ_FLOP , AU_OBJ_BOX , AU_OBJ_NODE ,
  AU_OBJ_VOID
}
 

Functions

void Au_ManAddNtk (Au_Man_t *pMan, Au_Ntk_t *p)
 
void Au_ManFree (Au_Man_t *p)
 
Au_Ntk_tAu_NtkAlloc (Au_Man_t *pMan, char *pName)
 FUNCTION DEFINITIONS ///.
 
void Au_NtkFree (Au_Ntk_t *p)
 
int Au_NtkMemUsage (Au_Ntk_t *p)
 
void Au_NtkPrintStats (Au_Ntk_t *p)
 
void Au_NtkCleanCopy (Au_Ntk_t *p)
 
int Au_NtkNodeNumFunc (Au_Ntk_t *p, int Func)
 
Au_Man_tAu_ManAlloc (char *pName)
 
void Au_ManDelete (Au_Man_t *p)
 
int Au_ManFindNtk (Au_Man_t *p, char *pName)
 
Au_Ntk_tAu_ManFindNtkP (Au_Man_t *p, char *pName)
 
int Au_ManMemUsage (Au_Man_t *p)
 
int Au_ManMemUsageUseful (Au_Man_t *p)
 
void Au_ManPrintStats (Au_Man_t *p)
 
void Au_ManReorderModels_rec (Au_Ntk_t *pNtk, Vec_Int_t *vOrder)
 
void Au_ManReorderModels (Au_Man_t *p, Au_Ntk_t *pRoot)
 
void Au_ManCountThings (Au_Man_t *p)
 
int Au_NtkCompareNames (Au_Ntk_t **p1, Au_Ntk_t **p2)
 
void Au_ManPrintBoxInfo (Au_Ntk_t *pNtk)
 
int Au_NtkCompareSign (Au_Ntk_t **p1, Au_Ntk_t **p2)
 
void Au_ManPrintBoxInfoSorted (Au_Ntk_t *pNtk)
 
int Au_NtkCheckRecursive (Au_Ntk_t *pNtk)
 
int Au_ObjSuppSize_rec (Au_Ntk_t *p, int Id)
 
int Au_ObjSuppSize (Au_Obj_t *pObj)
 
int Au_NtkSuppSizeTest (Au_Ntk_t *p)
 
int Au_NtkAllocObj (Au_Ntk_t *p, int nFanins, int Type)
 
int Au_NtkCreateConst0 (Au_Ntk_t *pNtk)
 
int Au_NtkCreatePi (Au_Ntk_t *pNtk)
 
int Au_NtkCreatePo (Au_Ntk_t *pNtk, int iFanin)
 
int Au_NtkCreateFan (Au_Ntk_t *pNtk, int iFanin, int iFanout, int iModel)
 
int Au_NtkCreateNode (Au_Ntk_t *pNtk, Vec_Int_t *vFanins, int iFunc)
 
int Au_NtkCreateBox (Au_Ntk_t *pNtk, Vec_Int_t *vFanins, int nFanouts, int iModel)
 
Au_Ntk_tAu_NtkParseCBlif (char *pFileName)
 
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START Vec_Ptr_tAbc_NtkDfsBoxes (Abc_Ntk_t *pNtk)
 
int Abc_NtkDeriveFlatGiaSop (Gia_Man_t *pGia, int *gFanins, char *pSop)
 
int Abc_NtkCheckRecursive (Abc_Ntk_t *pNtk)
 
void Au_NtkDeriveFlatGia_rec (Gia_Man_t *pGia, Au_Ntk_t *p)
 
Gia_Man_tAu_NtkDeriveFlatGia (Au_Ntk_t *p)
 
void Au_NtkTerSimulate_rec (Au_Ntk_t *p)
 
void Au_NtkTerSimulate (Au_Ntk_t *p)
 
Au_Ntk_tAu_NtkDerive (Au_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vOrder)
 
Gia_Man_tAu_ManDeriveTest (Abc_Ntk_t *pRoot)
 
Gia_Man_tAbc_NtkHieCecTest2 (char *pFileName, char *pModelName, int fVerbose)
 

Macro Definition Documentation

◆ Au_BoxForEachFanout

#define Au_BoxForEachFanout ( pObj,
pFanout,
i )
Value:
for ( i = 0; (i < Au_BoxFanoutNum(pObj)) && (((pFanout) = Au_BoxFanout(pObj, i)), 1); i++ )

Definition at line 211 of file abcHieNew.c.

211#define Au_BoxForEachFanout( pObj, pFanout, i) \
212 for ( i = 0; (i < Au_BoxFanoutNum(pObj)) && (((pFanout) = Au_BoxFanout(pObj, i)), 1); i++ )

◆ Au_BoxForEachFanoutId

#define Au_BoxForEachFanoutId ( pObj,
hFanout,
i )
Value:
for ( i = 0; (i < Au_BoxFanoutNum(pObj)) && (((hFanout) = Au_BoxFanoutId(pObj, i)), 1); i++ )

Definition at line 206 of file abcHieNew.c.

206#define Au_BoxForEachFanoutId( pObj, hFanout, i) \
207 for ( i = 0; (i < Au_BoxFanoutNum(pObj)) && (((hFanout) = Au_BoxFanoutId(pObj, i)), 1); i++ )

◆ Au_ManForEachNtk

#define Au_ManForEachNtk ( p,
pNtk,
i )
Value:
for ( i = 1; (i < Vec_PtrSize(&p->vNtks)) && (((pNtk) = Au_ManNtk(p, i)), 1); i++ )
Cube * p
Definition exorList.c:222

Definition at line 199 of file abcHieNew.c.

199#define Au_ManForEachNtk( p, pNtk, i ) \
200 for ( i = 1; (i < Vec_PtrSize(&p->vNtks)) && (((pNtk) = Au_ManNtk(p, i)), 1); i++ )

◆ Au_ManForEachNtkReverse

#define Au_ManForEachNtkReverse ( p,
pNtk,
i )
Value:
for ( i = Vec_PtrSize(&p->vNtks) - 1;(i>=1) && (((pNtk) = Au_ManNtk(p, i)), 1); i-- )

Definition at line 201 of file abcHieNew.c.

201#define Au_ManForEachNtkReverse( p, pNtk, i ) \
202 for ( i = Vec_PtrSize(&p->vNtks) - 1;(i>=1) && (((pNtk) = Au_ManNtk(p, i)), 1); i-- )

◆ AU_MAX_FANINS

#define AU_MAX_FANINS   0x1FFFFFFF

DECLARATIONS ///.

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

FileName [abcHieNew.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [New hierarchy manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 36 of file abcHieNew.c.

◆ Au_NtkForEachBox

#define Au_NtkForEachBox ( p,
pObj,
i )
Value:
for ( i = 0; (i < Vec_IntSize(&p->vObjs)) && (((pObj) = Au_NtkObjI(p, i)), 1); i++ ) if ( !Au_ObjIsBox(pObj) ) {} else

Definition at line 222 of file abcHieNew.c.

222#define Au_NtkForEachBox( p, pObj, i ) \
223 for ( i = 0; (i < Vec_IntSize(&p->vObjs)) && (((pObj) = Au_NtkObjI(p, i)), 1); i++ ) if ( !Au_ObjIsBox(pObj) ) {} else

◆ Au_NtkForEachNode

#define Au_NtkForEachNode ( p,
pObj,
i )
Value:
for ( i = 0; (i < Vec_IntSize(&p->vObjs)) && (((pObj) = Au_NtkObjI(p, i)), 1); i++ ) if ( !Au_ObjIsNode(pObj) ) {} else

Definition at line 220 of file abcHieNew.c.

220#define Au_NtkForEachNode( p, pObj, i ) \
221 for ( i = 0; (i < Vec_IntSize(&p->vObjs)) && (((pObj) = Au_NtkObjI(p, i)), 1); i++ ) if ( !Au_ObjIsNode(pObj) ) {} else

◆ Au_NtkForEachObj

#define Au_NtkForEachObj ( p,
pObj,
i )
Value:
for ( i = 0; (i < Vec_IntSize(&p->vObjs)) && (((pObj) = Au_NtkObjI(p, i)), 1); i++ )

Definition at line 218 of file abcHieNew.c.

218#define Au_NtkForEachObj( p, pObj, i ) \
219 for ( i = 0; (i < Vec_IntSize(&p->vObjs)) && (((pObj) = Au_NtkObjI(p, i)), 1); i++ )

◆ Au_NtkForEachPi

#define Au_NtkForEachPi ( p,
pObj,
i )
Value:
for ( i = 0; (i < Vec_IntSize(&p->vPis)) && (((pObj) = Au_NtkPi(p, i)), 1); i++ )

Definition at line 214 of file abcHieNew.c.

214#define Au_NtkForEachPi( p, pObj, i ) \
215 for ( i = 0; (i < Vec_IntSize(&p->vPis)) && (((pObj) = Au_NtkPi(p, i)), 1); i++ )

◆ Au_NtkForEachPo

#define Au_NtkForEachPo ( p,
pObj,
i )
Value:
for ( i = 0; (i < Vec_IntSize(&p->vPos)) && (((pObj) = Au_NtkPo(p, i)), 1); i++ )

Definition at line 216 of file abcHieNew.c.

216#define Au_NtkForEachPo( p, pObj, i ) \
217 for ( i = 0; (i < Vec_IntSize(&p->vPos)) && (((pObj) = Au_NtkPo(p, i)), 1); i++ )

◆ Au_ObjForEachFanin

#define Au_ObjForEachFanin ( pObj,
pFanin,
i )
Value:
for ( i = 0; (i < Au_ObjFaninNum(pObj)) && (((pFanin) = Au_ObjFanin(pObj, i)), 1); i++ )

Definition at line 209 of file abcHieNew.c.

209#define Au_ObjForEachFanin( pObj, pFanin, i ) \
210 for ( i = 0; (i < Au_ObjFaninNum(pObj)) && (((pFanin) = Au_ObjFanin(pObj, i)), 1); i++ )

◆ Au_ObjForEachFaninId

#define Au_ObjForEachFaninId ( pObj,
hFanin,
i )
Value:
for ( i = 0; (i < Au_ObjFaninNum(pObj)) && (((hFanin) = Au_ObjFaninId(pObj, i)), 1); i++ )

Definition at line 204 of file abcHieNew.c.

204#define Au_ObjForEachFaninId( pObj, hFanin, i ) \
205 for ( i = 0; (i < Au_ObjFaninNum(pObj)) && (((hFanin) = Au_ObjFaninId(pObj, i)), 1); i++ )

◆ AU_VAL0

#define AU_VAL0   1

Definition at line 1254 of file abcHieNew.c.

◆ AU_VAL1

#define AU_VAL1   2

Definition at line 1255 of file abcHieNew.c.

◆ AU_VALX

#define AU_VALX   3

Definition at line 1256 of file abcHieNew.c.

Typedef Documentation

◆ Au_Man_t

typedef struct Au_Man_t_ Au_Man_t

Definition at line 51 of file abcHieNew.c.

◆ Au_Ntk_t

typedef struct Au_Ntk_t_ Au_Ntk_t

Definition at line 52 of file abcHieNew.c.

◆ Au_Obj_t

typedef struct Au_Obj_t_ Au_Obj_t

Definition at line 53 of file abcHieNew.c.

Enumeration Type Documentation

◆ Au_Type_t

enum Au_Type_t
Enumerator
AU_OBJ_NONE 
AU_OBJ_CONST0 
AU_OBJ_PI 
AU_OBJ_PO 
AU_OBJ_FAN 
AU_OBJ_FLOP 
AU_OBJ_BOX 
AU_OBJ_NODE 
AU_OBJ_VOID 

Definition at line 38 of file abcHieNew.c.

38 {
39 AU_OBJ_NONE, // 0: non-existent object
40 AU_OBJ_CONST0, // 1: constant node
41 AU_OBJ_PI, // 2: primary input
42 AU_OBJ_PO, // 3: primary output
43 AU_OBJ_FAN, // 4: box output
44 AU_OBJ_FLOP, // 5: flip-flop
45 AU_OBJ_BOX, // 6: box
46 AU_OBJ_NODE, // 7: logic node
47 AU_OBJ_VOID // 8: placeholder
48} Au_Type_t;
Au_Type_t
Definition abcHieNew.c:38
@ AU_OBJ_NONE
Definition abcHieNew.c:39
@ AU_OBJ_VOID
Definition abcHieNew.c:47
@ AU_OBJ_PI
Definition abcHieNew.c:41
@ AU_OBJ_PO
Definition abcHieNew.c:42
@ AU_OBJ_FLOP
Definition abcHieNew.c:44
@ AU_OBJ_NODE
Definition abcHieNew.c:46
@ AU_OBJ_CONST0
Definition abcHieNew.c:40
@ AU_OBJ_BOX
Definition abcHieNew.c:45
@ AU_OBJ_FAN
Definition abcHieNew.c:43

Function Documentation

◆ Abc_NtkCheckRecursive()

int Abc_NtkCheckRecursive ( Abc_Ntk_t * pNtk)
extern

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

Synopsis [Checks if there is a recursive definition.]

Description []

SideEffects []

SeeAlso []

Definition at line 626 of file abcHieCec.c.

627{
628 Vec_Ptr_t * vMods;
629 Abc_Ntk_t * pModel;
630 Abc_Obj_t * pObj;
631 int i, k, RetValue = 0;
632
633 assert( Abc_NtkIsNetlist(pNtk) );
634 assert( !Abc_NtkLatchNum(pNtk) );
635
636 if ( pNtk->pDesign == NULL )
637 return RetValue;
638
639 vMods = pNtk->pDesign->vModules;
640 Vec_PtrForEachEntry( Abc_Ntk_t *, vMods, pModel, i )
641 {
642 Abc_NtkForEachObj( pModel, pObj, k )
643 if ( Abc_ObjIsBox(pObj) && pObj->pData == (void *)pModel )
644 {
645 printf( "WARNING: Model \"%s\" contains a recursive definition.\n", Abc_NtkName(pModel) );
646 RetValue = 1;
647 break;
648 }
649 }
650 return RetValue;
651}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
Vec_Ptr_t * vModules
Definition abc.h:225
Abc_Des_t * pDesign
Definition abc.h:180
void * pData
Definition abc.h:145
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the caller graph for this function:

◆ Abc_NtkDeriveFlatGiaSop()

int Abc_NtkDeriveFlatGiaSop ( Gia_Man_t * pGia,
int * gFanins,
char * pSop )
extern

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

Synopsis [Strashes one logic node using its SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file abcHieCec.c.

132{
133 char * pCube;
134 int gAnd, gSum;
135 int i, Value, nFanins;
136 // get the number of variables
137 nFanins = Abc_SopGetVarNum(pSop);
138 if ( Abc_SopIsExorType(pSop) )
139 {
140 gSum = 0;
141 for ( i = 0; i < nFanins; i++ )
142 gSum = Gia_ManHashXor( pGia, gSum, gFanins[i] );
143 }
144 else
145 {
146 // go through the cubes of the node's SOP
147 gSum = 0;
148 Abc_SopForEachCube( pSop, nFanins, pCube )
149 {
150 // create the AND of literals
151 gAnd = 1;
152 Abc_CubeForEachVar( pCube, Value, i )
153 {
154 if ( Value == '1' )
155 gAnd = Gia_ManHashAnd( pGia, gAnd, gFanins[i] );
156 else if ( Value == '0' )
157 gAnd = Gia_ManHashAnd( pGia, gAnd, Abc_LitNot(gFanins[i]) );
158 }
159 // add to the sum of cubes
160 gSum = Gia_ManHashAnd( pGia, Abc_LitNot(gSum), Abc_LitNot(gAnd) );
161 gSum = Abc_LitNot( gSum );
162 }
163 }
164 // decide whether to complement the result
165 if ( Abc_SopIsComplement(pSop) )
166 gSum = Abc_LitNot(gSum);
167 return gSum;
168}
#define Abc_CubeForEachVar(pCube, Value, i)
Definition abc.h:536
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition abc.h:538
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
ABC_DLL int Abc_SopIsExorType(char *pSop)
Definition abcSop.c:850
ABC_DLL int Abc_SopIsComplement(char *pSop)
Definition abcSop.c:703
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:668
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkDfsBoxes()

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

Synopsis [Returns the array of node and boxes reachable from POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 104 of file abcHieCec.c.

105{
106 Vec_Ptr_t * vNodes;
107 Abc_Obj_t * pObj;
108 int i;
109 assert( Abc_NtkIsNetlist(pNtk) );
110 // set the traversal ID
111 Abc_NtkIncrementTravId( pNtk );
112 // start the array of nodes
113 vNodes = Vec_PtrAlloc( 100 );
114 Abc_NtkForEachPo( pNtk, pObj, i )
115 Abc_NtkDfsBoxes_rec( Abc_ObjFaninReal(pObj, 0), vNodes );
116 return vNodes;
117}
void Abc_NtkDfsBoxes_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition abcHieCec.c:75
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkHieCecTest2()

Gia_Man_t * Abc_NtkHieCecTest2 ( char * pFileName,
char * pModelName,
int fVerbose )

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

Synopsis [Performs hierarchical equivalence checking.]

Description []

SideEffects []

SeeAlso []

Definition at line 1571 of file abcHieNew.c.

1572{
1573 int fSimulation = 0;
1574 Gia_Man_t * pGia = NULL;
1575 Au_Ntk_t * pNtk, * pNtkClp = NULL;
1576 abctime clk1 = 0, clk = Abc_Clock();
1577
1578 // read hierarchical netlist
1579 pNtk = Au_NtkParseCBlif( pFileName );
1580 if ( pNtk == NULL )
1581 {
1582 printf( "Reading CBLIF file has failed.\n" );
1583 return NULL;
1584 }
1585 if ( pNtk->pMan == NULL || pNtk->pMan->vNtks.pArray == NULL )
1586 {
1587 printf( "There is no hierarchy information.\n" );
1588 Au_NtkFree( pNtk );
1589 return NULL;
1590 }
1591 Abc_PrintTime( 1, "Reading file", Abc_Clock() - clk );
1592
1593 if ( fVerbose )
1594 {
1595 Au_ManPrintBoxInfo( pNtk );
1596// Au_ManPrintBoxInfoSorted( pNtk );
1597 Au_ManPrintStats( pNtk->pMan );
1598 }
1599 Au_ManCountThings( pNtk->pMan );
1600
1601 // select network
1602 if ( pModelName )
1603 pNtkClp = Au_ManFindNtkP( pNtk->pMan, pModelName );
1604 if ( pNtkClp == NULL )
1605 pNtkClp = pNtk;
1606
1607 // check if the model is recursive
1608 Au_NtkCheckRecursive( pNtkClp );
1609
1610 // collapse
1611 clk1 = Abc_Clock();
1612 if ( fSimulation )
1613 {
1614 Au_NtkTerSimulate( pNtkClp );
1615 Abc_PrintTime( 1, "Time sim ", Abc_Clock() - clk1 );
1616 }
1617 else
1618 {
1619 pGia = Au_NtkDeriveFlatGia( pNtkClp );
1620 Abc_PrintTime( 1, "Time GIA ", Abc_Clock() - clk1 );
1621 }
1622
1623 // delete
1624 Au_ManDelete( pNtk->pMan );
1625 Abc_PrintTime( 1, "Time all ", Abc_Clock() - clk );
1626 return pGia;
1627}
int Au_NtkCheckRecursive(Au_Ntk_t *pNtk)
Definition abcHieNew.c:660
void Au_ManPrintStats(Au_Man_t *p)
Definition abcHieNew.c:393
void Au_ManCountThings(Au_Man_t *p)
Definition abcHieNew.c:492
Gia_Man_t * Au_NtkDeriveFlatGia(Au_Ntk_t *p)
Definition abcHieNew.c:1222
void Au_ManDelete(Au_Man_t *p)
Definition abcHieNew.c:347
Au_Ntk_t * Au_NtkParseCBlif(char *pFileName)
Definition abcHieNew.c:959
struct Au_Ntk_t_ Au_Ntk_t
Definition abcHieNew.c:52
void Au_NtkTerSimulate(Au_Ntk_t *p)
Definition abcHieNew.c:1402
Au_Ntk_t * Au_ManFindNtkP(Au_Man_t *p, char *pName)
Definition abcHieNew.c:363
void Au_ManPrintBoxInfo(Au_Ntk_t *pNtk)
Definition abcHieNew.c:543
void Au_NtkFree(Au_Ntk_t *p)
Definition abcHieNew.c:258
ABC_INT64_T abctime
Definition abc_global.h:332
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Vec_Ptr_t vNtks
Definition abcHieNew.c:101
Au_Man_t * pMan
Definition abcHieNew.c:67
Here is the call graph for this function:

◆ Au_ManAddNtk()

void Au_ManAddNtk ( Au_Man_t * pMan,
Au_Ntk_t * p )
extern

Definition at line 370 of file abcHieNew.c.

371{
372 assert( Au_ManFindNtk(pMan, Au_NtkName(p)) == -1 );
373 p->pMan = pMan; pMan->nRefs++;
374 p->Id = Vec_PtrSize( &pMan->vNtks );
375 Vec_PtrPush( &pMan->vNtks, p );
376}
int Au_ManFindNtk(Au_Man_t *p, char *pName)
Definition abcHieNew.c:354
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_ManAlloc()

Au_Man_t * Au_ManAlloc ( char * pName)

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

Synopsis [Working with manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 327 of file abcHieNew.c.

328{
329 Au_Man_t * p;
330 p = ABC_CALLOC( Au_Man_t, 1 );
331 p->pName = Au_UtilStrsav( pName );
332 Vec_PtrGrow( &p->vNtks, 111 );
333 Vec_PtrPush( &p->vNtks, NULL );
334 return p;
335}
struct Au_Man_t_ Au_Man_t
Definition abcHieNew.c:51
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Here is the caller graph for this function:

◆ Au_ManCountThings()

void Au_ManCountThings ( Au_Man_t * p)

Definition at line 492 of file abcHieNew.c.

493{
494 Au_Ntk_t * pNtk, * pBoxModel;
495 Au_Obj_t * pBox;
496 int i, k;//, clk = Abc_Clock();
497 Au_ManForEachNtkReverse( p, pNtk, i )
498 {
499 pNtk->nBoxes = Au_NtkBoxNum(pNtk);
500 pNtk->nNodes = Au_NtkNodeNum(pNtk);
501 pNtk->nPorts = Au_NtkPiNum(pNtk) + Au_NtkPoNum(pNtk);
502 pNtk->nNodeAnds = Au_NtkNodeNumFunc( pNtk, 1 );
503 pNtk->nNodeXors = Au_NtkNodeNumFunc( pNtk, 2 );
504 pNtk->nNodeMuxs = Au_NtkNodeNumFunc( pNtk, 3 );
505// assert( pNtk->nNodes == pNtk->nNodeAnds + pNtk->nNodeXors + pNtk->nNodeMuxs );
506// printf( "adding %.0f nodes of model %s\n", pNtk->nNodes, Au_NtkName(pNtk) );
507 Au_NtkForEachBox( pNtk, pBox, k )
508 {
509 pBoxModel = Au_ObjModel(pBox);
510 if ( pBoxModel == NULL || pBoxModel == pNtk )
511 continue;
512 assert( Au_ObjFaninNum(pBox) == Au_NtkPiNum(pBoxModel) );
513 assert( Au_BoxFanoutNum(pBox) == Au_NtkPoNum(pBoxModel) );
514 assert( pBoxModel->Id > pNtk->Id );
515 assert( pBoxModel->nPorts > 0 );
516 pNtk->nBoxes += pBoxModel->nBoxes;
517 pNtk->nNodes += pBoxModel->nNodes;
518 pNtk->nPorts += pBoxModel->nPorts;
519 pNtk->nNodeAnds += pBoxModel->nNodeAnds;
520 pNtk->nNodeXors += pBoxModel->nNodeXors;
521 pNtk->nNodeMuxs += pBoxModel->nNodeMuxs;
522// printf( " adding %.0f nodes of model %s\n", pBoxModel->nNodes, Au_NtkName(pBoxModel) );
523 }
524// printf( "total %.0f nodes in model %s\n", pNtk->nNodes, Au_NtkName(pNtk) );
525 }
526 pNtk = Au_ManNtkRoot(p);
527 printf( "Total nodes = %15.0f. Total instances = %15.0f. Total ports = %15.0f.\n",
528// printf( "Total nodes = %.2e. Total instances = %.2e. Total ports = %.2e.\n",
529 pNtk->nNodes, pNtk->nBoxes, pNtk->nPorts );
530// printf( "Total ANDs = %15.0f. Total XORs = %15.0f. Total MUXes = %15.0f.\n",
531// printf( "Total ANDs = %.2e. Total XORs = %.2e. Total MUXes = %.2e. ",
532// pNtk->nNodeAnds, pNtk->nNodeXors, pNtk->nNodeMuxs );
533 printf( "Total ANDs = %15.0f.\n", pNtk->nNodeAnds );
534 printf( "Total XORs = %15.0f.\n", pNtk->nNodeXors );
535 printf( "Total MUXes = %15.0f.\n", pNtk->nNodeMuxs );
536// Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
537}
#define Au_ManForEachNtkReverse(p, pNtk, i)
Definition abcHieNew.c:201
#define Au_NtkForEachBox(p, pObj, i)
Definition abcHieNew.c:222
struct Au_Obj_t_ Au_Obj_t
Definition abcHieNew.c:53
int Au_NtkNodeNumFunc(Au_Ntk_t *p, int Func)
Definition abcHieNew.c:301
double nNodeMuxs
Definition abcHieNew.c:95
double nNodeAnds
Definition abcHieNew.c:93
double nNodes
Definition abcHieNew.c:91
double nNodeXors
Definition abcHieNew.c:94
double nPorts
Definition abcHieNew.c:92
double nBoxes
Definition abcHieNew.c:90
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_ManDelete()

void Au_ManDelete ( Au_Man_t * p)

Definition at line 347 of file abcHieNew.c.

348{
349 Au_Ntk_t * pNtk;
350 int i;
351 Au_ManForEachNtk( p, pNtk, i )
352 Au_NtkFree( pNtk );
353}
#define Au_ManForEachNtk(p, pNtk, i)
Definition abcHieNew.c:199
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_ManDeriveTest()

Gia_Man_t * Au_ManDeriveTest ( Abc_Ntk_t * pRoot)

Definition at line 1486 of file abcHieNew.c.

1487{
1488 extern Vec_Ptr_t * Abc_NtkCollectHie( Abc_Ntk_t * pNtk );
1489
1490// char * pModelName = NULL;
1491 char * pModelName = "path_0_r_x_lhs";
1492 Gia_Man_t * pGia = NULL;
1493 Vec_Ptr_t * vOrder, * vModels;
1494 Abc_Ntk_t * pMod;
1495 Au_Man_t * pMan;
1496 Au_Ntk_t * pNtk = NULL;
1497 abctime clk1, clk2 = 0, clk3 = 0, clk = Abc_Clock();
1498 int i;
1499
1500 clk1 = Abc_Clock();
1501 pMan = Au_ManAlloc( pRoot->pDesign ? pRoot->pDesign->pName : pRoot->pName );
1502 pMan->pFuncs = Abc_NamStart( 100, 16 );
1503 clk2 += Abc_Clock() - clk1;
1504
1505 vModels = Abc_NtkCollectHie( pRoot );
1506 Vec_PtrForEachEntry( Abc_Ntk_t *, vModels, pMod, i )
1507 {
1508 vOrder = Abc_NtkDfsBoxes( pMod );
1509
1510 clk1 = Abc_Clock();
1511 pNtk = Au_NtkDerive( pMan, pMod, vOrder );
1512 pMod->iStep = pNtk->Id;
1513 pMod->pData = pNtk;
1514 clk2 += Abc_Clock() - clk1;
1515
1516 Vec_PtrFree( vOrder );
1517 }
1518 Vec_PtrFree( vModels );
1519 // order models in topological order
1520 Au_ManReorderModels( pMan, pNtk );
1521
1522 // print statistics
1523 Au_ManPrintStats( pMan );
1524 Au_ManCountThings( pNtk->pMan );
1525
1526 // select network
1527 if ( pModelName )
1528 {
1529 pNtk = Au_ManFindNtkP( pMan, pModelName );
1530 if ( pNtk == NULL )
1531 printf( "Could not find module \"%s\".\n", pModelName );
1532 }
1533 if ( pNtk == NULL )
1534 pNtk = (Au_Ntk_t *)pRoot->pData;
1535
1536
1537// if ( !Abc_NtkCheckRecursive(pRoot) )
1538 {
1539 clk1 = Abc_Clock();
1540 pGia = Au_NtkDeriveFlatGia( pNtk );
1541 clk3 = Abc_Clock() - clk1;
1542// printf( "GIA objects max = %d.\n", pMan->nGiaObjMax );
1543 }
1544
1545// clk1 = Abc_Clock();
1546// Au_NtkSuppSizeTest( (Au_Ntk_t *)pRoot->pData );
1547// clk4 = Abc_Clock() - clk1;
1548
1549 clk1 = Abc_Clock();
1550 Au_ManDelete( pMan );
1551 clk2 += Abc_Clock() - clk1;
1552
1553 Abc_PrintTime( 1, "Time all ", Abc_Clock() - clk );
1554 Abc_PrintTime( 1, "Time new ", clk2 );
1555 Abc_PrintTime( 1, "Time GIA ", clk3 );
1556// Abc_PrintTime( 1, "Time supp", clk4 );
1557 return pGia;
1558}
Vec_Ptr_t * Abc_NtkCollectHie(Abc_Ntk_t *pNtk)
Definition abcHieCec.c:499
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START Vec_Ptr_t * Abc_NtkDfsBoxes(Abc_Ntk_t *pNtk)
Definition abcHieCec.c:104
Au_Ntk_t * Au_NtkDerive(Au_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vOrder)
Definition abcHieNew.c:1441
Au_Man_t * Au_ManAlloc(char *pName)
Definition abcHieNew.c:327
void Au_ManReorderModels(Au_Man_t *p, Au_Ntk_t *pRoot)
Definition abcHieNew.c:426
char * pName
Definition abc.h:222
char * pName
Definition abc.h:158
void * pData
Definition abc.h:203
int iStep
Definition abc.h:178
Abc_Nam_t * pFuncs
Definition abcHieNew.c:102
Abc_Nam_t * Abc_NamStart(int nObjs, int nAveSize)
FUNCTION DEFINITIONS ///.
Definition utilNam.c:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_ManFindNtk()

int Au_ManFindNtk ( Au_Man_t * p,
char * pName )

Definition at line 354 of file abcHieNew.c.

355{
356 Au_Ntk_t * pNtk;
357 int i;
358 Au_ManForEachNtk( p, pNtk, i )
359 if ( !strcmp(Au_NtkName(pNtk), pName) )
360 return i;
361 return -1;
362}
int strcmp()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_ManFindNtkP()

Au_Ntk_t * Au_ManFindNtkP ( Au_Man_t * p,
char * pName )

Definition at line 363 of file abcHieNew.c.

364{
365 int iNtk = Au_ManFindNtk( p, pName );
366 if ( iNtk == -1 )
367 return NULL;
368 return Au_ManNtk( p, iNtk );
369}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_ManFree()

void Au_ManFree ( Au_Man_t * p)
extern

Definition at line 336 of file abcHieNew.c.

337{
338 assert( p->nRefs > 0 );
339 if ( --p->nRefs > 0 )
340 return;
341 if ( p->pFuncs )
342 Abc_NamStop( p->pFuncs );
343 ABC_FREE( p->vNtks.pArray );
344 ABC_FREE( p->pName );
345 ABC_FREE( p );
346}
#define ABC_FREE(obj)
Definition abc_global.h:267
void Abc_NamStop(Abc_Nam_t *p)
Definition utilNam.c:112
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_ManMemUsage()

int Au_ManMemUsage ( Au_Man_t * p)

Definition at line 377 of file abcHieNew.c.

378{
379 Au_Ntk_t * pNtk;
380 int i, Mem = 0;
381 Au_ManForEachNtk( p, pNtk, i )
382 Mem += 16 * pNtk->nObjsAlloc;
383 return Mem;
384}
int nObjsAlloc
Definition abcHieNew.c:78
Here is the caller graph for this function:

◆ Au_ManMemUsageUseful()

int Au_ManMemUsageUseful ( Au_Man_t * p)

Definition at line 385 of file abcHieNew.c.

386{
387 Au_Ntk_t * pNtk;
388 int i, Mem = 0;
389 Au_ManForEachNtk( p, pNtk, i )
390 Mem += 16 * pNtk->nObjsUsed;
391 return Mem;
392}
int nObjsUsed
Definition abcHieNew.c:79
Here is the caller graph for this function:

◆ Au_ManPrintBoxInfo()

void Au_ManPrintBoxInfo ( Au_Ntk_t * pNtk)

Definition at line 543 of file abcHieNew.c.

544{
545 Vec_Ptr_t * vMods;
546 Au_Ntk_t * pModel, * pBoxModel;
547 Au_Obj_t * pObj;
548 Vec_Int_t * vCounts;
549 int i, k, Num;
550 if ( pNtk->pMan == NULL )
551 {
552 printf( "There is no hierarchy information.\n" );
553 return;
554 }
555 vMods = &pNtk->pMan->vNtks;
556
557/*
558 vMods->nSize--;
559 vMods->pArray++;
560 // sort models by name
561 Vec_PtrSort( vMods, (int(*)(const void *, const void *))Au_NtkCompareNames );
562 // swap the first model
563 Num = Vec_PtrFind( vMods, pNtk );
564 assert( Num >= 0 && Num < Vec_PtrSize(vMods) );
565 pBoxModel = (Au_Ntk_t *)Vec_PtrEntry(vMods, 0);
566 Vec_PtrWriteEntry(vMods, 0, (Au_Ntk_t *)Vec_PtrEntry(vMods, Num) );
567 Vec_PtrWriteEntry(vMods, Num, pBoxModel );
568 vMods->pArray--;
569 vMods->nSize++;
570*/
571
572// Vec_PtrForEachEntry( Au_Ntk_t *, vMods, pModel, i )
573// printf( "%s\n", Au_NtkName(pModel) );
574
575 // print models
576 vCounts = Vec_IntStart( Vec_PtrSize(vMods) );
577 Vec_PtrForEachEntryStart( Au_Ntk_t *, vMods, pModel, i, 1 )
578 {
579 if ( Au_NtkBoxNum(pModel) == 0 )
580 continue;
581 Vec_IntFill( vCounts, Vec_IntSize(vCounts), 0 );
582 Au_NtkForEachBox( pModel, pObj, k )
583 {
584 pBoxModel = Au_ObjModel(pObj);
585 if ( pBoxModel == NULL || pBoxModel == pModel )
586 continue;
587 Num = Vec_PtrFind( vMods, pBoxModel );
588 assert( Num >= 0 && Num < Vec_PtrSize(vMods) );
589 Vec_IntAddToEntry( vCounts, Num, 1 );
590 }
591
592// Au_NtkPrintStats( pModel, 0, 0, 0, 0, 0, 0, 0 );
593 printf( "MODULE " );
594 printf( "%-30s : ", Au_NtkName(pModel) );
595 printf( "PI=%6d ", Au_NtkPiNum(pModel) );
596 printf( "PO=%6d ", Au_NtkPoNum(pModel) );
597 printf( "BB=%6d ", Au_NtkBoxNum(pModel) );
598 printf( "ND=%6d ", Au_NtkNodeNum(pModel) ); // sans constants
599// printf( "Lev=%5d ", Au_NtkLevel(pModel) );
600 printf( "\n" );
601
602 Vec_IntForEachEntry( vCounts, Num, k )
603 if ( Num )
604 printf( "%15d : %s\n", Num, Au_NtkName((Au_Ntk_t *)Vec_PtrEntry(vMods, k)) );
605 }
606 Vec_IntFree( vCounts );
607 Vec_PtrForEachEntryStart( Au_Ntk_t *, vMods, pModel, i, 1 )
608 {
609 if ( Au_NtkBoxNum(pModel) != 0 )
610 continue;
611 printf( "MODULE " );
612 printf( "%-30s : ", Au_NtkName(pModel) );
613 printf( "PI=%6d ", Au_NtkPiNum(pModel) );
614 printf( "PO=%6d ", Au_NtkPoNum(pModel) );
615 printf( "BB=%6d ", Au_NtkBoxNum(pModel) );
616 printf( "ND=%6d ", Au_NtkNodeNum(pModel) );
617// printf( "Lev=%5d ", Au_NtkLevel(pModel) );
618 printf( "\n" );
619 }
620}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
Here is the caller graph for this function:

◆ Au_ManPrintBoxInfoSorted()

void Au_ManPrintBoxInfoSorted ( Au_Ntk_t * pNtk)

Definition at line 628 of file abcHieNew.c.

629{
630 Vec_Ptr_t * vMods, * vModsNew;
631 Au_Ntk_t * pModel;
632 int i;
633 if ( pNtk->pMan == NULL )
634 {
635 printf( "There is no hierarchy information.\n" );
636 return;
637 }
638 vMods = &pNtk->pMan->vNtks;
639
640 vMods->nSize--;
641 vMods->pArray++;
642 vModsNew = Vec_PtrDup( vMods );
643 vMods->pArray--;
644 vMods->nSize++;
645
646 Vec_PtrSort( vModsNew, (int(*)(const void *, const void *))Au_NtkCompareSign );
647 Vec_PtrForEachEntryStart( Au_Ntk_t *, vModsNew, pModel, i, 1 )
648 {
649 printf( "MODULE " );
650 printf( "%-30s : ", Au_NtkName(pModel) );
651 printf( "PI=%6d ", Au_NtkPiNum(pModel) );
652 printf( "PO=%6d ", Au_NtkPoNum(pModel) );
653 printf( "BB=%6d ", Au_NtkBoxNum(pModel) );
654 printf( "ND=%6d ", Au_NtkNodeNum(pModel) );
655 printf( "\n" );
656 }
657 Vec_PtrFree( vModsNew );
658}
int Au_NtkCompareSign(Au_Ntk_t **p1, Au_Ntk_t **p2)
Definition abcHieNew.c:621
Here is the call graph for this function:

◆ Au_ManPrintStats()

void Au_ManPrintStats ( Au_Man_t * p)

Definition at line 393 of file abcHieNew.c.

394{
395 Au_Ntk_t * pNtk;
396 int i;
397 if ( Vec_PtrSize(&p->vNtks) > 2 )
398 printf( "Design %-13s\n", Au_ManName(p) );
399 Au_ManForEachNtk( p, pNtk, i )
400 Au_NtkPrintStats( pNtk );
401 printf( "Different functions = %d. ", p->pFuncs ? Abc_NamObjNumMax(p->pFuncs) : 0 );
402 printf( "Memory = %.1f MB", 1.0 * Au_ManMemUsage(p) / (1 << 20) );
403 printf( " %5.1f %%", 100.0 * (Au_ManMemUsage(p) - Au_ManMemUsageUseful(p)) / Au_ManMemUsage(p) );
404 printf( "\n" );
405// if ( p->pFuncs )
406// Abc_NamPrint( p->pFuncs );
407}
int Au_ManMemUsage(Au_Man_t *p)
Definition abcHieNew.c:377
void Au_NtkPrintStats(Au_Ntk_t *p)
Definition abcHieNew.c:280
int Au_ManMemUsageUseful(Au_Man_t *p)
Definition abcHieNew.c:385
int Abc_NamObjNumMax(Abc_Nam_t *p)
Definition utilNam.c:231
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_ManReorderModels()

void Au_ManReorderModels ( Au_Man_t * p,
Au_Ntk_t * pRoot )

Definition at line 426 of file abcHieNew.c.

427{
428 Vec_Ptr_t * vNtksNew;
429 Vec_Int_t * vOrder, * vTemp;
430 Au_Ntk_t * pNtk, * pBoxModel;
431 Au_Obj_t * pBox, * pFan;
432 int i, k, j, Entry;
433 Au_ManForEachNtk( p, pNtk, i )
434 pNtk->fMark = 0;
435 // collect networks in the DFS order
436 vOrder = Vec_IntAlloc( Au_ManNtkNum(p)+1 );
437 Vec_IntPush( vOrder, 0 );
438 Au_ManReorderModels_rec( pRoot, vOrder );
439 assert( Vec_IntEntryLast(vOrder) == pRoot->Id );
440 // add unconnected ones
441 Vec_IntPop( vOrder );
442 Au_ManForEachNtk( p, pNtk, i )
443 if ( pNtk->fMark == 0 )
444 Vec_IntPush( vOrder, pNtk->Id );
445 Vec_IntPush( vOrder, pRoot->Id );
446 assert( Vec_IntSize(vOrder) == Au_ManNtkNum(p)+1 );
447 // reverse order
448 vOrder->nSize--;
449 vOrder->pArray++;
450 Vec_IntReverseOrder( vOrder );
451 vOrder->pArray--;
452 vOrder->nSize++;
453 // compute new order
454 vNtksNew = Vec_PtrAlloc( Au_ManNtkNum(p)+1 );
455 Vec_IntForEachEntry( vOrder, Entry, i )
456 Vec_PtrPush( vNtksNew, Au_ManNtk(p, Entry) );
457 // invert order
458 assert( Vec_IntEntry(vOrder, 1) == pRoot->Id );
459 vOrder = Vec_IntInvert( vTemp = vOrder, 0 );
460 Vec_IntFree( vTemp );
461 assert( Vec_IntEntry(vOrder, 1) == pRoot->Id );
462 // update model numbers
463 Au_ManForEachNtk( p, pNtk, i )
464 {
465 pNtk->Id = Vec_IntEntry( vOrder, pNtk->Id );
466 Au_NtkForEachBox( pNtk, pBox, k )
467 {
468 pBox->Func = Vec_IntEntry( vOrder, pBox->Func );
469 assert( pBox->Func > 0 );
470 Au_BoxForEachFanout( pBox, pFan, j )
471 pFan->Func = pBox->Func;
472 }
473 }
474 // update
475 ABC_FREE( p->vNtks.pArray );
476 p->vNtks.pArray = vNtksNew->pArray;
477 vNtksNew->pArray = NULL;
478 Vec_PtrFree( vNtksNew );
479 // verify
480 Au_ManForEachNtk( p, pNtk, i )
481 Au_NtkForEachBox( pNtk, pBox, k )
482 {
483 pBoxModel = Au_ObjModel(pBox);
484 if ( pBoxModel == NULL || pBoxModel == pNtk )
485 continue;
486 assert( !pBox->Func || pBox->Func >= (unsigned)pNtk->Id );
487 assert( Au_ObjFaninNum(pBox) == Au_NtkPiNum(pBoxModel) );
488 assert( Au_BoxFanoutNum(pBox) == Au_NtkPoNum(pBoxModel) );
489 }
490 Vec_IntFree( vOrder );
491}
#define Au_BoxForEachFanout(pObj, pFanout, i)
Definition abcHieNew.c:211
void Au_ManReorderModels_rec(Au_Ntk_t *pNtk, Vec_Int_t *vOrder)
Definition abcHieNew.c:409
int fMark
Definition abcHieNew.c:89
unsigned Func
Definition abcHieNew.c:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_ManReorderModels_rec()

void Au_ManReorderModels_rec ( Au_Ntk_t * pNtk,
Vec_Int_t * vOrder )

Definition at line 409 of file abcHieNew.c.

410{
411 Au_Ntk_t * pBoxModel;
412 Au_Obj_t * pObj;
413 int k;
414 if ( pNtk->fMark )
415 return;
416 pNtk->fMark = 1;
417 Au_NtkForEachBox( pNtk, pObj, k )
418 {
419 pBoxModel = Au_ObjModel(pObj);
420 if ( pBoxModel == NULL || pBoxModel == pNtk )
421 continue;
422 Au_ManReorderModels_rec( pBoxModel, vOrder );
423 }
424 Vec_IntPush( vOrder, pNtk->Id );
425}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkAlloc()

Au_Ntk_t * Au_NtkAlloc ( Au_Man_t * pMan,
char * pName )

FUNCTION DEFINITIONS ///.

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

Synopsis [Working with models.]

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file abcHieNew.c.

246{
247 Au_Ntk_t * p;
248 p = ABC_CALLOC( Au_Ntk_t, 1 );
249 p->pName = Au_UtilStrsav( pName );
250 p->vChunks = Vec_PtrAlloc( 111 );
251 Vec_IntGrow( &p->vPis, 111 );
252 Vec_IntGrow( &p->vPos, 111 );
253 Vec_IntGrow( &p->vObjs, 1111 );
254 Vec_PtrGrow( &p->vPages, 11 );
255 Au_ManAddNtk( pMan, p );
256 return p;
257}
void Au_ManAddNtk(Au_Man_t *pMan, Au_Ntk_t *p)
Definition abcHieNew.c:370
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkAllocObj()

int Au_NtkAllocObj ( Au_Ntk_t * p,
int nFanins,
int Type )

Definition at line 761 of file abcHieNew.c.

762{
763 Au_Obj_t * pMem, * pObj, * pTemp;
764 int nObjInt = ((2+nFanins) >> 2) + (((2+nFanins) & 3) > 0);
765 int Id, nObjIntReal = nObjInt;
766 if ( nObjInt > 63 )
767 nObjInt = 63 + 64 * (((nObjInt-63) >> 6) + (((nObjInt-63) & 63) > 0));
768 if ( Vec_PtrSize(&p->vPages) == 0 || p->iHandle + nObjInt > (1 << 12) )
769 {
770 if ( nObjInt + 64 > (1 << 12) )
771 pMem = ABC_CALLOC( Au_Obj_t, nObjInt + 64 ), p->nObjsAlloc += nObjInt + 64;
772 else
773 pMem = ABC_CALLOC( Au_Obj_t, (1 << 12) + 64 ), p->nObjsAlloc += (1 << 12) + 64;
774 Vec_PtrPush( p->vChunks, pMem );
775 if ( ((ABC_PTRINT_T)pMem & 0xF) )
776 pMem = (Au_Obj_t *)((char *)pMem + 16 - ((ABC_PTRINT_T)pMem & 0xF));
777 assert( ((ABC_PTRINT_T)pMem & 0xF) == 0 );
778 p->iHandle = (((ABC_PTRINT_T)pMem & 0x3FF) >> 4);
779 if ( p->iHandle )
780 {
781 pMem += 64 - (p->iHandle & 63);
782 p->iHandle = 0;
783 }
784 Vec_PtrPush( &p->vPages, pMem );
785 Au_NtkInsertHeader( p );
786 }
787 else
788 {
789 pMem = (Au_Obj_t *)Vec_PtrEntryLast( &p->vPages );
790 if ( (p->iHandle & 63) == 0 || nObjInt > (64 - (p->iHandle & 63)) )
791 {
792 if ( p->iHandle & 63 )
793 p->iHandle += 64 - (p->iHandle & 63);
794 Au_NtkInsertHeader( p );
795 }
796 if ( p->iHandle + nObjInt > (1 << 12) )
797 return Au_NtkAllocObj( p, nFanins, Type );
798 }
799 pObj = pMem + p->iHandle;
800 assert( *((int *)pObj) == 0 );
801 pObj->nFanins = nFanins;
802 p->nObjs[pObj->Type = Type]++;
803 if ( Type == AU_OBJ_PI )
804 {
805 Au_ObjSetFaninLit( pObj, 0, Vec_IntSize(&p->vPis) );
806 Vec_IntPush( &p->vPis, Au_ObjId(pObj) );
807 }
808 else if ( Type == AU_OBJ_PO )
809 {
810 Au_ObjSetFaninLit( pObj, 1, Vec_IntSize(&p->vPos) );
811 Vec_IntPush( &p->vPos, Au_ObjId(pObj) );
812 }
813 p->iHandle += nObjInt;
814 p->nObjsUsed += nObjIntReal;
815
816 Id = Au_ObjId(pObj);
817 Vec_IntPush( &p->vObjs, Id );
818 pTemp = Au_NtkObj( p, Id );
819 assert( pTemp == pObj );
820 return Id;
821}
int Au_NtkAllocObj(Au_Ntk_t *p, int nFanins, int Type)
Definition abcHieNew.c:761
unsigned Type
Definition abcHieNew.c:59
unsigned nFanins
Definition abcHieNew.c:60
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkCheckRecursive()

int Au_NtkCheckRecursive ( Au_Ntk_t * pNtk)

Definition at line 660 of file abcHieNew.c.

661{
662 Vec_Ptr_t * vMods;
663 Au_Ntk_t * pModel;
664 Au_Obj_t * pObj;
665 int i, k, RetValue = 0;
666
667 if ( pNtk->pMan == NULL )
668 {
669 printf( "There is no hierarchy information.\n" );
670 return RetValue;
671 }
672
673 vMods = &pNtk->pMan->vNtks;
674 Vec_PtrForEachEntryStart( Au_Ntk_t *, vMods, pModel, i, 1 )
675 {
676 Au_NtkForEachObj( pModel, pObj, k )
677 if ( Au_ObjIsBox(pObj) && Au_ObjModel(pObj) == pModel )
678 {
679 printf( "WARNING: Model \"%s\" contains a recursive definition.\n", Au_NtkName(pModel) );
680 RetValue = 1;
681 break;
682 }
683 }
684 return RetValue;
685}
#define Au_NtkForEachObj(p, pObj, i)
Definition abcHieNew.c:218
Here is the caller graph for this function:

◆ Au_NtkCleanCopy()

void Au_NtkCleanCopy ( Au_Ntk_t * p)

Definition at line 297 of file abcHieNew.c.

298{
299 Vec_IntFill( &p->vCopies, Au_NtkObjNumMax(p), -1 );
300}
Here is the caller graph for this function:

◆ Au_NtkCompareNames()

int Au_NtkCompareNames ( Au_Ntk_t ** p1,
Au_Ntk_t ** p2 )

Definition at line 539 of file abcHieNew.c.

540{
541 return strcmp( Au_NtkName(*p1), Au_NtkName(*p2) );
542}
Here is the call graph for this function:

◆ Au_NtkCompareSign()

int Au_NtkCompareSign ( Au_Ntk_t ** p1,
Au_Ntk_t ** p2 )

Definition at line 621 of file abcHieNew.c.

622{
623 if ( Au_NtkPiNum(*p1) - Au_NtkPiNum(*p2) != 0 )
624 return Au_NtkPiNum(*p1) - Au_NtkPiNum(*p2);
625 else
626 return Au_NtkPoNum(*p1) - Au_NtkPoNum(*p2);
627}
Here is the caller graph for this function:

◆ Au_NtkCreateBox()

int Au_NtkCreateBox ( Au_Ntk_t * pNtk,
Vec_Int_t * vFanins,
int nFanouts,
int iModel )

Definition at line 857 of file abcHieNew.c.

858{
859 int i, iFanin, nFanins = Vec_IntSize(vFanins);
860 int Id = Au_NtkAllocObj( pNtk, nFanins + 1 + nFanouts, AU_OBJ_BOX );
861 Au_Obj_t * p = Au_NtkObj( pNtk, Id );
862 Vec_IntForEachEntry( vFanins, iFanin, i )
863 Au_ObjSetFaninLit( p, i, iFanin );
864 Au_ObjSetFaninLit( p, nFanins, nFanouts );
865 for ( i = 0; i < nFanouts; i++ )
866 Au_ObjSetFaninLit( p, nFanins + 1 + i, Au_NtkCreateFan(pNtk, Au_Var2Lit(Id,0), i, iModel) );
867 p->nFanins = nFanins;
868 p->Func = iModel;
869 assert( iModel > 0 );
870 return Id;
871}
int Au_NtkCreateFan(Au_Ntk_t *pNtk, int iFanin, int iFanout, int iModel)
Definition abcHieNew.c:837
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkCreateConst0()

int Au_NtkCreateConst0 ( Au_Ntk_t * pNtk)

Definition at line 822 of file abcHieNew.c.

823{
824 return Au_NtkAllocObj( pNtk, 0, AU_OBJ_CONST0 );
825}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkCreateFan()

int Au_NtkCreateFan ( Au_Ntk_t * pNtk,
int iFanin,
int iFanout,
int iModel )

Definition at line 837 of file abcHieNew.c.

838{
839 int Id = Au_NtkAllocObj( pNtk, 1, AU_OBJ_FAN );
840 Au_Obj_t * p = Au_NtkObj( pNtk, Id );
841 if ( iFanin )
842 Au_ObjSetFaninLit( p, 0, iFanin );
843 Au_ObjSetFaninLit( p, 1, iFanout );
844 p->Func = iModel;
845 return Id;
846}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkCreateNode()

int Au_NtkCreateNode ( Au_Ntk_t * pNtk,
Vec_Int_t * vFanins,
int iFunc )

Definition at line 847 of file abcHieNew.c.

848{
849 int i, iFanin;
850 int Id = Au_NtkAllocObj( pNtk, Vec_IntSize(vFanins), AU_OBJ_NODE );
851 Au_Obj_t * p = Au_NtkObj( pNtk, Id );
852 Vec_IntForEachEntry( vFanins, iFanin, i )
853 Au_ObjSetFaninLit( p, i, iFanin );
854 p->Func = iFunc;
855 return Id;
856}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkCreatePi()

int Au_NtkCreatePi ( Au_Ntk_t * pNtk)

Definition at line 826 of file abcHieNew.c.

827{
828 return Au_NtkAllocObj( pNtk, 0, AU_OBJ_PI );
829}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkCreatePo()

int Au_NtkCreatePo ( Au_Ntk_t * pNtk,
int iFanin )

Definition at line 830 of file abcHieNew.c.

831{
832 int Id = Au_NtkAllocObj( pNtk, 1, AU_OBJ_PO );
833 if ( iFanin )
834 Au_ObjSetFaninLit( Au_NtkObj(pNtk, Id), 0, iFanin );
835 return Id;
836}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkDerive()

Au_Ntk_t * Au_NtkDerive ( Au_Man_t * pMan,
Abc_Ntk_t * pNtk,
Vec_Ptr_t * vOrder )

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

Synopsis [Duplicates ABC network.]

Description []

SideEffects []

SeeAlso []

Definition at line 1441 of file abcHieNew.c.

1442{
1443 Au_Ntk_t * p;
1444 Au_Obj_t * pAuObj;
1445 Abc_Obj_t * pObj, * pTerm;
1446// Vec_Ptr_t * vOrder;
1447 Vec_Int_t * vFanins;
1448 int i, k, iFunc;
1449 assert( Abc_NtkIsNetlist(pNtk) );
1450 Abc_NtkCleanCopy( pNtk );
1451 p = Au_NtkAlloc( pMan, Abc_NtkName(pNtk) );
1452 // copy PIs
1453 Abc_NtkForEachPi( pNtk, pTerm, i )
1454 Abc_ObjFanout0(pTerm)->iTemp = Au_NtkCreatePi(p);
1455 // copy nodes and boxes
1456 vFanins = Vec_IntAlloc( 100 );
1457// vOrder = Abc_NtkDfsBoxes( pNtk );
1458 Vec_PtrForEachEntry( Abc_Obj_t *, vOrder, pObj, i )
1459 {
1460 Vec_IntClear( vFanins );
1461 if ( Abc_ObjIsNode(pObj) )
1462 {
1463 Abc_ObjForEachFanin( pObj, pTerm, k )
1464 Vec_IntPush( vFanins, Au_Var2Lit(pTerm->iTemp, 0) );
1465 iFunc = Abc_NamStrFindOrAdd( pMan->pFuncs, (char *)pObj->pData, NULL );
1466 Abc_ObjFanout0(pObj)->iTemp = Au_NtkCreateNode(p, vFanins, iFunc);
1467 continue;
1468 }
1469 assert( Abc_ObjIsBox(pObj) );
1470 Abc_ObjForEachFanin( pObj, pTerm, k )
1471 Vec_IntPush( vFanins, Au_Var2Lit(Abc_ObjFanin0(pTerm)->iTemp, 0) );
1472 pObj->iTemp = Au_NtkCreateBox(p, vFanins, Abc_ObjFanoutNum(pObj), ((Abc_Ntk_t *)pObj->pData)->iStep );
1473 pAuObj = Au_NtkObj(p, pObj->iTemp);
1474 Abc_ObjForEachFanout( pObj, pTerm, k )
1475 Abc_ObjFanout0(pTerm)->iTemp = Au_ObjFanout(pAuObj, k);
1476 }
1477// Vec_PtrFree( vOrder );
1478 Vec_IntFree( vFanins );
1479 // copy POs
1480 Abc_NtkForEachPo( pNtk, pTerm, i )
1481 Au_NtkCreatePo( p, Au_Var2Lit(Abc_ObjFanin0(pTerm)->iTemp, 0) );
1482// Au_NtkPrintStats( p );
1483 return p;
1484}
int Au_NtkCreatePi(Au_Ntk_t *pNtk)
Definition abcHieNew.c:826
int Au_NtkCreatePo(Au_Ntk_t *pNtk, int iFanin)
Definition abcHieNew.c:830
int Au_NtkCreateBox(Au_Ntk_t *pNtk, Vec_Int_t *vFanins, int nFanouts, int iModel)
Definition abcHieNew.c:857
Au_Ntk_t * Au_NtkAlloc(Au_Man_t *pMan, char *pName)
FUNCTION DEFINITIONS ///.
Definition abcHieNew.c:245
int Au_NtkCreateNode(Au_Ntk_t *pNtk, Vec_Int_t *vFanins, int iFunc)
Definition abcHieNew.c:847
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:540
int iTemp
Definition abc.h:149
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
Definition utilNam.c:453
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkDeriveFlatGia()

Gia_Man_t * Au_NtkDeriveFlatGia ( Au_Ntk_t * p)

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

Synopsis [Flattens the logic hierarchy of the netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 1222 of file abcHieNew.c.

1223{
1224 Gia_Man_t * pTemp, * pGia = NULL;
1225 Au_Obj_t * pTerm;
1226 int i;
1227 printf( "Collapsing model \"%s\"...\n", Au_NtkName(p) );
1228 Au_NtkCleanCopy( p );
1229 // start the network
1230 pGia = Gia_ManStart( (1<<16) );
1231 pGia->pName = Abc_UtilStrsav( Au_NtkName(p) );
1232// pGia->pSpec = Abc_UtilStrsav( Au_NtkSpec(p) );
1233 Gia_ManHashAlloc( pGia );
1234 Gia_ManFlipVerbose( pGia );
1235 // create PIs
1236 Au_NtkForEachPi( p, pTerm, i )
1237 Au_ObjSetCopy( pTerm, Gia_ManAppendCi(pGia) );
1238 // recursively flatten hierarchy
1239 Au_NtkDeriveFlatGia_rec( pGia, p );
1240 // create POs
1241 Au_NtkForEachPo( p, pTerm, i )
1242 Gia_ManAppendCo( pGia, Au_ObjCopy(pTerm) );
1243 // prepare return value
1244// Gia_ManHashProfile( pGia );
1245 Gia_ManHashStop( pGia );
1246 Gia_ManSetRegNum( pGia, 0 );
1247 pGia = Gia_ManCleanup( pTemp = pGia );
1248 Gia_ManStop( pTemp );
1249 return pGia;
1250}
#define Au_NtkForEachPo(p, pObj, i)
Definition abcHieNew.c:216
void Au_NtkCleanCopy(Au_Ntk_t *p)
Definition abcHieNew.c:297
#define Au_NtkForEachPi(p, pObj, i)
Definition abcHieNew.c:214
void Au_NtkDeriveFlatGia_rec(Gia_Man_t *pGia, Au_Ntk_t *p)
Definition abcHieNew.c:1131
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition giaMan.c:764
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
char * pName
Definition gia.h:99
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkDeriveFlatGia_rec()

void Au_NtkDeriveFlatGia_rec ( Gia_Man_t * pGia,
Au_Ntk_t * p )

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

Synopsis [Flattens the logic hierarchy of the netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 1131 of file abcHieNew.c.

1132{
1133 Au_Obj_t * pObj, * pTerm;
1134 int i, k, Lit = 0;
1135 Au_NtkForEachPi( p, pTerm, i )
1136 assert( Au_ObjCopy(pTerm) >= 0 );
1137 if ( strcmp(Au_NtkName(p), "ref_egcd") == 0 )
1138 {
1139 printf( "Replacing one instance of recursive model \"%s\" by a black box.\n", "ref_egcd" );
1140 Au_NtkForEachPo( p, pTerm, i )
1141 Au_ObjSetCopy( pTerm, Gia_ManAppendCi(pGia) );
1142 return;
1143 }
1144 Au_NtkForEachObj( p, pObj, i )
1145 {
1146 if ( Au_ObjIsNode(pObj) )
1147 {
1148 if ( p->pMan->pFuncs )
1149 {
1150 int gFanins[16];
1151 char * pSop = Abc_NamStr( p->pMan->pFuncs, pObj->Func );
1152 assert( Au_ObjFaninNum(pObj) <= 16 );
1153 assert( Au_ObjFaninNum(pObj) == Abc_SopGetVarNum(pSop) );
1154 Au_ObjForEachFanin( pObj, pTerm, k )
1155 {
1156 gFanins[k] = Au_ObjCopy(pTerm);
1157 assert( gFanins[k] >= 0 );
1158 }
1159 Lit = Abc_NtkDeriveFlatGiaSop( pGia, gFanins, pSop );
1160 }
1161 else
1162 {
1163 int Lit0, Lit1, Lit2;
1164 assert( pObj->Func >= 1 && pObj->Func <= 3 );
1165 Lit0 = Abc_LitNotCond( Au_ObjCopy(Au_ObjFanin0(pObj)), Au_ObjFaninC0(pObj) );
1166 Lit1 = Abc_LitNotCond( Au_ObjCopy(Au_ObjFanin1(pObj)), Au_ObjFaninC1(pObj) );
1167 if ( pObj->Func == 1 )
1168 Lit = Gia_ManHashAnd( pGia, Lit0, Lit1 );
1169 else if ( pObj->Func == 2 )
1170 Lit = Gia_ManHashXor( pGia, Lit0, Lit1 );
1171 else if ( pObj->Func == 3 )
1172 {
1173 Lit2 = Abc_LitNotCond( Au_ObjCopy(Au_ObjFanin2(pObj)), Au_ObjFaninC2(pObj) );
1174 Lit = Gia_ManHashMux( pGia, Lit0, Lit1, Lit2 );
1175 }
1176 else assert( 0 );
1177 }
1178 assert( Lit >= 0 );
1179 Au_ObjSetCopy( pObj, Lit );
1180 }
1181 else if ( Au_ObjIsBox(pObj) )
1182 {
1183 Au_Ntk_t * pModel = Au_ObjModel(pObj);
1184 Au_NtkCleanCopy( pModel );
1185 // check the match between the number of actual and formal parameters
1186 assert( Au_ObjFaninNum(pObj) == Au_NtkPiNum(pModel) );
1187 assert( Au_BoxFanoutNum(pObj) == Au_NtkPoNum(pModel) );
1188 // assign PIs
1189 Au_ObjForEachFanin( pObj, pTerm, k )
1190 Au_ObjSetCopy( Au_NtkPi(pModel, k), Au_ObjCopy(pTerm) );
1191 // call recursively
1192 Au_NtkDeriveFlatGia_rec( pGia, pModel );
1193 // assign POs
1194 Au_BoxForEachFanout( pObj, pTerm, k )
1195 Au_ObjSetCopy( pTerm, Au_ObjCopy(Au_NtkPo(pModel, k)) );
1196 }
1197 else if ( Au_ObjIsConst0(pObj) )
1198 Au_ObjSetCopy( pObj, 0 );
1199
1200 }
1201 Au_NtkForEachPo( p, pTerm, i )
1202 {
1203 Lit = Abc_LitNotCond( Au_ObjCopy(Au_ObjFanin0(pTerm)), Au_ObjFaninC0(pTerm) );
1204 Au_ObjSetCopy( pTerm, Lit );
1205 }
1206 Au_NtkForEachPo( p, pTerm, i )
1207 assert( Au_ObjCopy(pTerm) >= 0 );
1208// p->pMan->nGiaObjMax = Abc_MaxInt( p->pMan->nGiaObjMax, Gia_ManObjNum(pGia) );
1209}
int Abc_NtkDeriveFlatGiaSop(Gia_Man_t *pGia, int *gFanins, char *pSop)
Definition abcHieCec.c:131
#define Au_ObjForEachFanin(pObj, pFanin, i)
Definition abcHieNew.c:209
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition giaHash.c:692
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
Definition utilNam.c:555
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkFree()

void Au_NtkFree ( Au_Ntk_t * p)

Definition at line 258 of file abcHieNew.c.

259{
260 Au_ManFree( p->pMan );
261 Vec_PtrFreeFree( p->vChunks );
262 ABC_FREE( p->vCopies.pArray );
263 ABC_FREE( p->vPages.pArray );
264 ABC_FREE( p->vObjs.pArray );
265 ABC_FREE( p->vPis.pArray );
266 ABC_FREE( p->vPos.pArray );
267 ABC_FREE( p->pHTable );
268 ABC_FREE( p->pName );
269 ABC_FREE( p );
270}
void Au_ManFree(Au_Man_t *p)
Definition abcHieNew.c:336
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkMemUsage()

int Au_NtkMemUsage ( Au_Ntk_t * p)

Definition at line 271 of file abcHieNew.c.

272{
273 int Mem = sizeof(Au_Ntk_t);
274 Mem += 4 * p->vPis.nCap;
275 Mem += 4 * p->vPos.nCap;
276 Mem += 4 * p->vObjs.nCap;
277 Mem += 16 * p->nObjsAlloc;
278 return Mem;
279}
Here is the caller graph for this function:

◆ Au_NtkNodeNumFunc()

int Au_NtkNodeNumFunc ( Au_Ntk_t * p,
int Func )

Definition at line 301 of file abcHieNew.c.

302{
303 Au_Obj_t * pObj;
304 int i, Counter = 0;
305 if ( p->pMan && p->pMan->pFuncs )
306 return 0;
307 Au_NtkForEachNode( p, pObj, i )
308 {
309 Counter += (pObj->Func == (unsigned)Func);
310// printf( "%d ", pObj->Func );
311 }
312// printf( "\n" );
313 return Counter;
314}
#define Au_NtkForEachNode(p, pObj, i)
Definition abcHieNew.c:220
Here is the caller graph for this function:

◆ Au_NtkParseCBlif()

Au_Ntk_t * Au_NtkParseCBlif ( char * pFileName)

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

Synopsis [Parses CBLIF file.]

Description []

SideEffects []

SeeAlso []

Definition at line 959 of file abcHieNew.c.

960{
961 FILE * pFile;
962 Au_Man_t * pMan;
963 Au_Ntk_t * pRoot = NULL;
964 Au_Obj_t * pBox, * pFan;
965 char * pBuffer, * pCur;
966 Vec_Int_t * vLines, * vNum2Obj, * vFanins;
967 int i, k, j, Id, nInputs, nOutputs;
968 int Line, Num, Func;
969 // read the file
970 pFile = fopen( pFileName, "rb" );
971 if ( pFile == NULL )
972 {
973 printf( "Cannot open file \"%s\".\n", pFileName );
974 return NULL;
975 }
976 pBuffer = Extra_FileRead( pFile );
977 fclose( pFile );
978 // split into lines
979 vLines = Vec_IntAlloc( 1000 );
980 Vec_IntPush( vLines, 0 );
981 for ( pCur = pBuffer; *pCur; pCur++ )
982 if ( *pCur == '\n' )
983 {
984 *pCur = 0;
985 Vec_IntPush( vLines, pCur - pBuffer + 1 );
986 }
987 // start the manager
988 pMan = Au_ManAlloc( pFileName );
989 // parse the lines
990 vNum2Obj = Vec_IntAlloc( 1000 );
991 vFanins = Vec_IntAlloc( 1000 );
992 Vec_IntForEachEntry( vLines, Line, i )
993 {
994 pCur = strtok( pBuffer + Line, " \t\r" );
995 if ( pCur == NULL || *pCur == '#' )
996 continue;
997 if ( *pCur != '.' )
998 {
999 printf( "Cannot read directive in line %d: \"%s\".\n", i, pBuffer + Line );
1000 continue;
1001 }
1002 Vec_IntClear( vFanins );
1003 if ( !strcmp(pCur, ".and") )
1004 {
1005 for ( k = 0; k < 2; k++ )
1006 {
1007 pCur = strtok( NULL, " \t\r" );
1008 Num = atoi( pCur );
1009 Vec_IntPush( vFanins, Au_NtkRemapNum(vNum2Obj, Num) );
1010 }
1011 Id = Au_NtkCreateNode( pRoot, vFanins, 1 );
1012 Vec_IntPush( vNum2Obj, Id );
1013 }
1014 else if ( !strcmp(pCur, ".xor") )
1015 {
1016 for ( k = 0; k < 2; k++ )
1017 {
1018 pCur = strtok( NULL, " \t\r" );
1019 Num = atoi( pCur );
1020 Vec_IntPush( vFanins, Au_NtkRemapNum(vNum2Obj, Num) );
1021 }
1022 Id = Au_NtkCreateNode( pRoot, vFanins, 2 );
1023 Vec_IntPush( vNum2Obj, Id );
1024 }
1025 else if ( !strcmp(pCur, ".mux") )
1026 {
1027 for ( k = 0; k < 3; k++ )
1028 {
1029 pCur = strtok( NULL, " \t\r" );
1030 Num = atoi( pCur );
1031 Vec_IntPush( vFanins, Au_NtkRemapNum(vNum2Obj, Num) );
1032 }
1033 Id = Au_NtkCreateNode( pRoot, vFanins, 3 );
1034 Vec_IntPush( vNum2Obj, Id );
1035 }
1036 else if ( !strcmp(pCur, ".subckt") )
1037 {
1038 pCur = strtok( NULL, " \t\r" );
1039 Func = pCur - pBuffer;
1040 pCur = strtok( NULL, " \t\r" );
1041 nInputs = atoi( pCur );
1042 pCur = strtok( NULL, " \t\r" );
1043 nOutputs = atoi( pCur );
1044 while ( 1 )
1045 {
1046 pCur = strtok( NULL, " \t\r" );
1047 if ( pCur == NULL || *pCur == '#' )
1048 break;
1049 Au_NtkParseCBlifNum( vFanins, pCur, vNum2Obj );
1050 }
1051 assert( Vec_IntSize(vFanins) == nInputs );
1052 Id = Au_NtkCreateBox( pRoot, vFanins, nOutputs, Func );
1053 pBox = Au_NtkObj( pRoot, Id );
1054 Au_BoxForEachFanoutId( pBox, Num, k )
1055 Vec_IntPush( vNum2Obj, Num );
1056 }
1057 else if ( !strcmp(pCur, ".model") )
1058 {
1059 pCur = strtok( NULL, " \t\r" );
1060 pRoot = Au_NtkAlloc( pMan, pCur );
1061 Id = Au_NtkCreateConst0( pRoot );
1062 Vec_IntClear( vNum2Obj );
1063 Vec_IntPush( vNum2Obj, Id );
1064 }
1065 else if ( !strcmp(pCur, ".inputs") )
1066 {
1067 pCur = strtok( NULL, " \t\r" );
1068 Num = atoi( pCur );
1069 for ( k = 0; k < Num; k++ )
1070 Vec_IntPush( vNum2Obj, Au_NtkCreatePi(pRoot) );
1071 }
1072 else if ( !strcmp(pCur, ".outputs") )
1073 {
1074 pCur = strtok( NULL, " \t\r" );
1075 nOutputs = atoi( pCur );
1076 while ( 1 )
1077 {
1078 pCur = strtok( NULL, " \t\r" );
1079 if ( pCur == NULL || *pCur == '#' )
1080 break;
1081 Au_NtkParseCBlifNum( vFanins, pCur, vNum2Obj );
1082 }
1083 assert( Vec_IntSize(vFanins) == nOutputs );
1084 Vec_IntForEachEntry( vFanins, Num, k )
1085 Au_NtkCreatePo( pRoot, Num );
1086 }
1087 else if ( strcmp(pCur, ".end") )
1088 printf( "Unknown directive in line %d: \"%s\".\n", i, pBuffer + Line );
1089 }
1090 Vec_IntFree( vFanins );
1091 Vec_IntFree( vNum2Obj );
1092 Vec_IntFree( vLines );
1093 // set pointers to models
1094 Au_ManForEachNtk( pMan, pRoot, i )
1095 Au_NtkForEachBox( pRoot, pBox, k )
1096 {
1097 pBox->Func = Au_ManFindNtk( pMan, pBuffer + pBox->Func );
1098 assert( pBox->Func > 0 );
1099 Au_BoxForEachFanout( pBox, pFan, j )
1100 pFan->Func = pBox->Func;
1101 }
1102 ABC_FREE( pBuffer );
1103 // order models in topological order
1104 pRoot = Au_ManNtkRoot( pMan );
1105 Au_ManReorderModels( pMan, pRoot );
1106 return pRoot;
1107}
int Au_NtkCreateConst0(Au_Ntk_t *pNtk)
Definition abcHieNew.c:822
#define Au_BoxForEachFanoutId(pObj, hFanout, i)
Definition abcHieNew.c:206
char * Extra_FileRead(FILE *pFile)
char * strtok()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkPrintStats()

void Au_NtkPrintStats ( Au_Ntk_t * p)

Definition at line 280 of file abcHieNew.c.

281{
282 printf( "%-30s:", Au_NtkName(p) );
283 printf( " i/o =%6d/%6d", Au_NtkPiNum(p), Au_NtkPoNum(p) );
284 if ( Au_NtkFlopNum(p) )
285 printf( " lat =%5d", Au_NtkFlopNum(p) );
286 printf( " nd =%6d", Au_NtkNodeNum(p) );
287// if ( Au_NtkBoxNum(p) )
288 printf( " box =%5d", Au_NtkBoxNum(p) );
289 printf( " obj =%7d", Au_NtkObjNum(p) );
290// printf( " max =%7d", Au_NtkObjNumMax(p) );
291// printf( " use =%7d", p->nObjsUsed );
292 printf( " %5.1f %%", 100.0 * (Au_NtkObjNumMax(p) - Au_NtkObjNum(p)) / Au_NtkObjNumMax(p) );
293 printf( " %6.1f MB", 1.0 * Au_NtkMemUsage(p) / (1 << 20) );
294 printf( " %5.1f %%", 100.0 * (p->nObjsAlloc - p->nObjsUsed) / p->nObjsAlloc );
295 printf( "\n" );
296}
int Au_NtkMemUsage(Au_Ntk_t *p)
Definition abcHieNew.c:271
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkSuppSizeTest()

int Au_NtkSuppSizeTest ( Au_Ntk_t * p)

Definition at line 731 of file abcHieNew.c.

732{
733 Au_Obj_t * pObj;
734 int i, Counter = 0;
735 Au_NtkForEachObj( p, pObj, i )
736 if ( Au_ObjIsNode(pObj) )
737 Counter += (Au_ObjSuppSize(pObj) <= 16);
738 printf( "Nodes with small support %d (out of %d)\n", Counter, Au_NtkNodeNum(p) );
739 return Counter;
740}
int Au_ObjSuppSize(Au_Obj_t *pObj)
Definition abcHieNew.c:703
Here is the call graph for this function:

◆ Au_NtkTerSimulate()

void Au_NtkTerSimulate ( Au_Ntk_t * p)

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

Synopsis [Flattens the logic hierarchy of the netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 1402 of file abcHieNew.c.

1403{
1404 Au_Obj_t * pTerm;
1405 int i, Counter[2] = {0};
1406 assert( p->pMan->pFuncs == NULL );
1407 printf( "Collapsing model \"%s\"...\n", Au_NtkName(p) );
1408 // create PIs
1409 Au_NtkForEachPi( p, pTerm, i )
1410 Au_ObjSetXsim( pTerm, AU_VALX );
1411 // recursively flatten hierarchy
1412 p->pMan->nPortsC0 = 0;
1413 p->pMan->nPortsC1 = 0;
1414 p->pMan->nPortsNC = 0;
1416 // analyze outputs
1417 Au_NtkForEachPo( p, pTerm, i )
1418 if ( Au_ObjGetXsim(pTerm) == AU_VAL0 )
1419 Counter[0]++;
1420 else if ( Au_ObjGetXsim(pTerm) == AU_VAL1 )
1421 Counter[1]++;
1422 // print results
1423 printf( "Const0 outputs =%15d. Const1 outputs =%15d. Total outputs =%15d.\n",
1424 Counter[0], Counter[1], Au_NtkPoNum(p) );
1425 printf( "Const0 ports = %.0f. Const1 ports = %.0f. Non-const ports= %.0f. Total ports = %.0f.\n",
1426 p->pMan->nPortsC0, p->pMan->nPortsC1, p->pMan->nPortsNC, p->pMan->nPortsC0 + p->pMan->nPortsC1 + p->pMan->nPortsNC );
1427}
#define AU_VAL0
Definition abcHieNew.c:1254
#define AU_VAL1
Definition abcHieNew.c:1255
void Au_NtkTerSimulate_rec(Au_Ntk_t *p)
Definition abcHieNew.c:1325
#define AU_VALX
Definition abcHieNew.c:1256
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_NtkTerSimulate_rec()

void Au_NtkTerSimulate_rec ( Au_Ntk_t * p)

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

Synopsis [Flattens the logic hierarchy of the netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 1325 of file abcHieNew.c.

1326{
1327 Au_Obj_t * pObj = NULL, * pTerm;
1328 int i, k;
1329 Au_NtkForEachPi( p, pTerm, i )
1330 {
1331 assert( Au_ObjGetXsim(pTerm) > 0 );
1332 if ( Au_ObjGetXsim(pTerm) == AU_VALX )
1333 p->pMan->nPortsNC++;
1334 else if ( Au_ObjGetXsim(pTerm) == AU_VAL0 )
1335 p->pMan->nPortsC0++;
1336 else
1337 p->pMan->nPortsC1++;
1338 }
1339 if ( strcmp(Au_NtkName(p), "ref_egcd") == 0 )
1340 {
1341 printf( "Replacing one instance of recursive model \"%s\" by a black box.\n", "ref_egcd" );
1342 Au_NtkForEachPo( p, pTerm, i )
1343 Au_ObjSetXsim( pTerm, AU_VALX );
1344 return;
1345 }
1346 Au_NtkForEachObj( p, pObj, i )
1347 {
1348 if ( Au_ObjIsNode(pObj) )
1349 {
1350 if ( pObj->Func == 1 )
1351 Au_ObjSetXsim( pObj, Au_XsimAnd(Au_ObjGetXsimFan0(pObj), Au_ObjGetXsimFan1(pObj)) );
1352 else if ( pObj->Func == 2 )
1353 Au_ObjSetXsim( pObj, Au_XsimXor(Au_ObjGetXsimFan0(pObj), Au_ObjGetXsimFan1(pObj)) );
1354 else if ( pObj->Func == 3 )
1355 Au_ObjSetXsim( pObj, Au_XsimMux(Au_ObjGetXsimFan0(pObj), Au_ObjGetXsimFan1(pObj), Au_ObjGetXsimFan2(pObj)) );
1356 else assert( 0 );
1357 }
1358 else if ( Au_ObjIsBox(pObj) )
1359 {
1360 Au_Ntk_t * pModel = Au_ObjModel(pObj);
1361 // check the match between the number of actual and formal parameters
1362 assert( Au_ObjFaninNum(pObj) == Au_NtkPiNum(pModel) );
1363 assert( Au_BoxFanoutNum(pObj) == Au_NtkPoNum(pModel) );
1364 // assign PIs
1365 Au_ObjForEachFanin( pObj, pTerm, k )
1366 Au_ObjSetXsim( Au_NtkPi(pModel, k), Au_ObjGetXsim(pTerm) );
1367 // call recursively
1368 Au_NtkTerSimulate_rec( pModel );
1369 // assign POs
1370 Au_BoxForEachFanout( pObj, pTerm, k )
1371 Au_ObjSetXsim( pTerm, Au_ObjGetXsim(Au_NtkPo(pModel, k)) );
1372 }
1373 else if ( Au_ObjIsConst0(pObj) )
1374 Au_ObjSetXsim( pObj, AU_VAL0 );
1375
1376 }
1377 Au_NtkForEachPo( p, pTerm, i )
1378 Au_ObjSetXsim( pTerm, Au_ObjGetXsimFan0(pObj) );
1379 Au_NtkForEachPo( p, pTerm, i )
1380 {
1381 assert( Au_ObjGetXsim(pTerm) > 0 );
1382 if ( Au_ObjGetXsim(pTerm) == AU_VALX )
1383 p->pMan->nPortsNC++;
1384 else if ( Au_ObjGetXsim(pTerm) == AU_VAL0 )
1385 p->pMan->nPortsC0++;
1386 else
1387 p->pMan->nPortsC1++;
1388 }
1389}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_ObjSuppSize()

int Au_ObjSuppSize ( Au_Obj_t * pObj)

Definition at line 703 of file abcHieNew.c.

704{
705 Au_Ntk_t * p = Au_ObjNtk(pObj);
706 Au_NtkIncrementTravId( p );
707 return Au_ObjSuppSize_rec( p, Au_ObjId(pObj) );
708}
int Au_ObjSuppSize_rec(Au_Ntk_t *p, int Id)
Definition abcHieNew.c:688
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Au_ObjSuppSize_rec()

int Au_ObjSuppSize_rec ( Au_Ntk_t * p,
int Id )

Definition at line 688 of file abcHieNew.c.

689{
690 Au_Obj_t * pObj;
691 int i, iFanin, Counter = 0;
692 if ( Au_ObjIsTravIdCurrentId(p, Id) )
693 return 0;
694 Au_ObjSetTravIdCurrentId(p, Id);
695 pObj = Au_NtkObj( p, Id );
696 if ( Au_ObjIsPi(pObj) )
697 return 1;
698 assert( Au_ObjIsNode(pObj) || Au_ObjIsBox(pObj) || Au_ObjIsFan(pObj) );
699 Au_ObjForEachFaninId( pObj, iFanin, i )
700 Counter += Au_ObjSuppSize_rec( p, iFanin );
701 return Counter;
702}
#define Au_ObjForEachFaninId(pObj, hFanin, i)
Definition abcHieNew.c:204
Here is the call graph for this function:
Here is the caller graph for this function: