ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
wlnObj.c
Go to the documentation of this file.
1
20
21#include "wln.h"
22
24
25
29
33
45char * Wln_ObjName( Wln_Ntk_t * p, int iObj )
46{
47 static char Buffer[100];
48 if ( Wln_NtkHasNameId(p) && Wln_ObjNameId(p, iObj) )
49 return Abc_NamStr( p->pManName, Wln_ObjNameId(p, iObj) );
50 sprintf( Buffer, "n%d", iObj );
51 return Buffer;
52}
53char * Wln_ObjConstString( Wln_Ntk_t * p, int iObj )
54{
55 assert( Wln_ObjIsConst(p, iObj) );
56 return Abc_NamStr( p->pManName, Wln_ObjFanin0(p, iObj) );
57}
58void Wln_ObjUpdateType( Wln_Ntk_t * p, int iObj, int Type )
59{
60 assert( Wln_ObjIsNone(p, iObj) );
61 p->nObjs[Wln_ObjType(p, iObj)]--;
62 Vec_IntWriteEntry( &p->vTypes, iObj, Type );
63 p->nObjs[Wln_ObjType(p, iObj)]++;
64}
65void Wln_ObjSetConst( Wln_Ntk_t * p, int iObj, int NameId )
66{
67 assert( Wln_ObjIsConst(p, iObj) );
68 Wln_ObjSetFanin( p, iObj, 0, NameId );
69}
70void Wln_ObjSetSlice( Wln_Ntk_t * p, int iObj, int SliceId )
71{
72 assert( Wln_ObjIsSlice(p, iObj) );
73 Wln_ObjSetFanin( p, iObj, 1, SliceId );
74}
75void Wln_ObjAddFanin( Wln_Ntk_t * p, int iObj, int i )
76{
77 Wln_Vec_t * pVec = p->vFanins + iObj;
78 if ( Wln_ObjFaninNum(p, iObj) < 2 )
79 pVec->Array[pVec->nSize++] = i;
80 else if ( Wln_ObjFaninNum(p, iObj) == 2 )
81 {
82 int * pArray = ABC_ALLOC( int, 4 );
83 pArray[0] = pVec->Array[0];
84 pArray[1] = pVec->Array[1];
85 pArray[2] = i;
86 pVec->pArray[0] = pArray;
87 pVec->nSize = 3;
88 pVec->nCap = 4;
89 }
90 else
91 {
92 if ( pVec->nSize == pVec->nCap )
93 pVec->pArray[0] = ABC_REALLOC( int, pVec->pArray[0], (pVec->nCap = 2*pVec->nSize) );
94 assert( pVec->nSize < pVec->nCap );
95 pVec->pArray[0][pVec->nSize++] = i;
96 }
97}
98int Wln_ObjAddFanins( Wln_Ntk_t * p, int iObj, Vec_Int_t * vFanins )
99{
100 int i, iFanin;
101 Vec_IntForEachEntry( vFanins, iFanin, i )
102 Wln_ObjAddFanin( p, iObj, iFanin );
103 return iObj;
104}
105int Wln_ObjAlloc( Wln_Ntk_t * p, int Type, int Signed, int End, int Beg )
106{
107 int iObj = Vec_IntSize(&p->vTypes);
108 if ( iObj == Vec_IntCap(&p->vTypes) )
109 {
110 p->vFanins = ABC_REALLOC( Wln_Vec_t, p->vFanins, 2 * iObj );
111 memset( p->vFanins + iObj, 0, sizeof(Wln_Vec_t) * iObj );
112 Vec_IntGrow( &p->vTypes, 2 * iObj );
113 }
114 assert( iObj == Vec_StrSize(&p->vSigns) );
115 assert( iObj == Vec_IntSize(&p->vRanges) );
116 Vec_IntPush( &p->vTypes, Type );
117 Vec_StrPush( &p->vSigns, (char)Signed );
118 Vec_IntPush( &p->vRanges, Hash_Int2ManInsert(p->pRanges, End, Beg, 0) );
119 if ( Wln_ObjIsCi(p, iObj) ) Wln_ObjSetFanin( p, iObj, 1, Vec_IntSize(&p->vCis) ), Vec_IntPush( &p->vCis, iObj );
120 if ( Wln_ObjIsCo(p, iObj) ) Wln_ObjSetFanin( p, iObj, 1, Vec_IntSize(&p->vCos) ), Vec_IntPush( &p->vCos, iObj );
121 if ( Wln_ObjIsFf(p, iObj) ) Vec_IntPush( &p->vFfs, iObj );
122 p->nObjs[Type]++;
123 return iObj;
124}
125int Wln_ObjClone( Wln_Ntk_t * pNew, Wln_Ntk_t * p, int iObj )
126{
127 return Wln_ObjAlloc( pNew, Wln_ObjType(p, iObj), Wln_ObjIsSigned(p, iObj), Wln_ObjRangeEnd(p, iObj), Wln_ObjRangeBeg(p, iObj) );
128}
129int Wln_ObjCreateCo( Wln_Ntk_t * p, int iFanin )
130{
131 int iCo = Wln_ObjClone( p, p, iFanin );
133 Wln_ObjAddFanin( p, iCo, iFanin );
134 return iCo;
135}
136void Wln_ObjPrint( Wln_Ntk_t * p, int iObj )
137{
138 int k, iFanin, Type = Wln_ObjType(p, iObj);
139 printf( "Obj %6d : Type = %6s Fanins = %d : ", iObj, Abc_OperName(Type), Wln_ObjFaninNum(p, iObj) );
140 Wln_ObjForEachFanin( p, iObj, iFanin, k )
141 printf( "%5d ", iFanin );
142 printf( "\n" );
143}
144
148
149
151
@ ABC_OPER_CO
Definition abcOper.h:46
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
Definition utilNam.c:555
#define assert(ex)
Definition util_old.h:213
char * memset()
char * sprintf()
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
void Wln_ObjPrint(Wln_Ntk_t *p, int iObj)
Definition wlnObj.c:136
void Wln_ObjSetSlice(Wln_Ntk_t *p, int iObj, int SliceId)
Definition wlnObj.c:70
void Wln_ObjUpdateType(Wln_Ntk_t *p, int iObj, int Type)
Definition wlnObj.c:58
void Wln_ObjAddFanin(Wln_Ntk_t *p, int iObj, int i)
Definition wlnObj.c:75
int Wln_ObjCreateCo(Wln_Ntk_t *p, int iFanin)
Definition wlnObj.c:129
char * Wln_ObjConstString(Wln_Ntk_t *p, int iObj)
Definition wlnObj.c:53
int Wln_ObjAlloc(Wln_Ntk_t *p, int Type, int Signed, int End, int Beg)
Definition wlnObj.c:105
int Wln_ObjClone(Wln_Ntk_t *pNew, Wln_Ntk_t *p, int iObj)
Definition wlnObj.c:125
void Wln_ObjSetConst(Wln_Ntk_t *p, int iObj, int NameId)
Definition wlnObj.c:65
ABC_NAMESPACE_IMPL_START char * Wln_ObjName(Wln_Ntk_t *p, int iObj)
DECLARATIONS ///.
Definition wlnObj.c:45
int Wln_ObjAddFanins(Wln_Ntk_t *p, int iObj, Vec_Int_t *vFanins)
Definition wlnObj.c:98
typedefABC_NAMESPACE_HEADER_START struct Wln_Vec_t_ Wln_Vec_t
INCLUDES ///.
Definition wln.h:46
#define Wln_ObjForEachFanin(p, iObj, iFanin, i)
Definition wln.h:205
struct Wln_Ntk_t_ Wln_Ntk_t
Definition wln.h:55