ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
lpkAbcUtil.c
Go to the documentation of this file.
1
20
21#include "lpkInt.h"
22
24
25
29
33
45Lpk_Fun_t * Lpk_FunAlloc( int nVars )
46{
47 Lpk_Fun_t * p;
48 p = (Lpk_Fun_t *)ABC_ALLOC( char, sizeof(Lpk_Fun_t) + sizeof(unsigned) * Kit_TruthWordNum(nVars) * 3 );
49 memset( p, 0, sizeof(Lpk_Fun_t) );
50 return p;
51}
52
65{
66 ABC_FREE( p );
67}
68
80Lpk_Fun_t * Lpk_FunCreate( Abc_Ntk_t * pNtk, Vec_Ptr_t * vLeaves, unsigned * pTruth, int nLutK, int AreaLim, int DelayLim )
81{
82 Lpk_Fun_t * p;
83 Abc_Obj_t * pNode;
84 int i;
85 p = Lpk_FunAlloc( Vec_PtrSize(vLeaves) );
86 p->Id = Vec_PtrSize(vLeaves);
87 p->vNodes = vLeaves;
88 p->nVars = Vec_PtrSize(vLeaves);
89 p->nLutK = nLutK;
90 p->nAreaLim = AreaLim;
91 p->nDelayLim = DelayLim;
92 p->uSupp = Kit_TruthSupport( pTruth, p->nVars );
93 Kit_TruthCopy( Lpk_FunTruth(p,0), pTruth, p->nVars );
94 Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pNode, i )
95 {
96 p->pFanins[i] = i;
97 p->pDelays[i] = pNode->Level;
98 }
99 Vec_PtrPush( p->vNodes, p );
100 return p;
101}
102
114Lpk_Fun_t * Lpk_FunDup( Lpk_Fun_t * p, unsigned * pTruth )
115{
116 Lpk_Fun_t * pNew;
117 pNew = Lpk_FunAlloc( p->nVars );
118 pNew->Id = Vec_PtrSize(p->vNodes);
119 pNew->vNodes = p->vNodes;
120 pNew->nVars = p->nVars;
121 pNew->nLutK = p->nLutK;
122 pNew->nAreaLim = p->nAreaLim;
123 pNew->nDelayLim = p->nDelayLim;
124 pNew->uSupp = Kit_TruthSupport( pTruth, p->nVars );
125 Kit_TruthCopy( Lpk_FunTruth(pNew,0), pTruth, p->nVars );
126 memcpy( pNew->pFanins, p->pFanins, 16 );
127 memcpy( pNew->pDelays, p->pDelays, sizeof(int)*16 );
128 Vec_PtrPush( p->vNodes, pNew );
129 return pNew;
130}
131
144{
145 int i, k, nVarsNew;
146 // compress the truth table
147 if ( p->uSupp == Kit_BitMask(p->nVars) )
148 return 0;
149 // invalidate support info
150 p->fSupports = 0;
151//Extra_PrintBinary( stdout, &p->uSupp, p->nVars ); printf( "\n" );
152 // minimize support
153 nVarsNew = Kit_WordCountOnes(p->uSupp);
154 Kit_TruthShrink( Lpk_FunTruth(p, 1), Lpk_FunTruth(p, 0), nVarsNew, p->nVars, p->uSupp, 1 );
155 k = 0;
156 Lpk_SuppForEachVar( p->uSupp, i )
157 {
158 p->pFanins[k] = p->pFanins[i];
159 p->pDelays[k] = p->pDelays[i];
160/*
161 if ( p->fSupports )
162 {
163 p->puSupps[2*k+0] = p->puSupps[2*i+0];
164 p->puSupps[2*k+1] = p->puSupps[2*i+1];
165 }
166*/
167 k++;
168 }
169 assert( k == nVarsNew );
170 p->nVars = k;
171 p->uSupp = Kit_BitMask(p->nVars);
172 return 1;
173}
174
187{
188 unsigned * pTruth = Lpk_FunTruth( p, 0 );
189 unsigned * pTruth0 = Lpk_FunTruth( p, 1 );
190 unsigned * pTruth1 = Lpk_FunTruth( p, 2 );
191 int Var;
192 assert( p->fSupports == 0 );
193// Lpk_SuppForEachVar( p->uSupp, Var )
194 for ( Var = 0; Var < (int)p->nVars; Var++ )
195 {
196 Kit_TruthCofactor0New( pTruth0, pTruth, p->nVars, Var );
197 Kit_TruthCofactor1New( pTruth1, pTruth, p->nVars, Var );
198 p->puSupps[2*Var+0] = Kit_TruthSupport( pTruth0, p->nVars );
199 p->puSupps[2*Var+1] = Kit_TruthSupport( pTruth1, p->nVars );
200 }
201 p->fSupports = 1;
202}
203
215int Lpk_SuppDelay( unsigned uSupp, int * pDelays )
216{
217 int Delay, Var;
218 Delay = 0;
219 Lpk_SuppForEachVar( uSupp, Var )
220 Delay = Abc_MaxInt( Delay, pDelays[Var] );
221 return Delay + 1;
222}
223
235int Lpk_SuppToVars( unsigned uBoundSet, char * pVars )
236{
237 int i, nVars = 0;
238 Lpk_SuppForEachVar( uBoundSet, i )
239 pVars[nVars++] = i;
240 return nVars;
241}
242
246
247
249
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Cube * p
Definition exorList.c:222
int Var
Definition exorList.c:228
unsigned Kit_TruthSupport(unsigned *pTruth, int nVars)
Definition kitTruth.c:346
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition kitTruth.c:573
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition kitTruth.c:521
void Kit_TruthShrink(unsigned *pOut, unsigned *pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn)
Definition kitTruth.c:200
ABC_NAMESPACE_IMPL_START Lpk_Fun_t * Lpk_FunAlloc(int nVars)
DECLARATIONS ///.
Definition lpkAbcUtil.c:45
int Lpk_SuppToVars(unsigned uBoundSet, char *pVars)
Definition lpkAbcUtil.c:235
void Lpk_FunFree(Lpk_Fun_t *p)
Definition lpkAbcUtil.c:64
Lpk_Fun_t * Lpk_FunDup(Lpk_Fun_t *p, unsigned *pTruth)
Definition lpkAbcUtil.c:114
int Lpk_SuppDelay(unsigned uSupp, int *pDelays)
Definition lpkAbcUtil.c:215
int Lpk_FunSuppMinimize(Lpk_Fun_t *p)
Definition lpkAbcUtil.c:143
void Lpk_FunComputeCofSupps(Lpk_Fun_t *p)
Definition lpkAbcUtil.c:186
Lpk_Fun_t * Lpk_FunCreate(Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, unsigned *pTruth, int nLutK, int AreaLim, int DelayLim)
Definition lpkAbcUtil.c:80
#define Lpk_SuppForEachVar(Supp, Var)
Definition lpkInt.h:196
struct Lpk_Fun_t_ Lpk_Fun_t
Definition lpkInt.h:144
unsigned Level
Definition abc.h:142
int pDelays[16]
Definition lpkInt.h:157
unsigned nAreaLim
Definition lpkInt.h:151
unsigned nLutK
Definition lpkInt.h:150
char pFanins[16]
Definition lpkInt.h:158
unsigned nDelayLim
Definition lpkInt.h:156
unsigned nVars
Definition lpkInt.h:149
unsigned uSupp
Definition lpkInt.h:154
unsigned Id
Definition lpkInt.h:148
Vec_Ptr_t * vNodes
Definition lpkInt.h:147
#define assert(ex)
Definition util_old.h:213
char * memcpy()
char * memset()
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