ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
acecPolyn.c File Reference
#include "acecInt.h"
#include "misc/vec/vecWec.h"
#include "misc/vec/vecHsh.h"
#include "misc/vec/vecQue.h"
Include dependency graph for acecPolyn.c:

Go to the source code of this file.

Classes

struct  Pln_Man_t_
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Pln_Man_t_ Pln_Man_t
 DECLARATIONS ///.
 

Functions

Pln_Man_tPln_ManAlloc (Gia_Man_t *pGia, Vec_Int_t *vOrder)
 FUNCTION DEFINITIONS ///.
 
void Pln_ManStop (Pln_Man_t *p)
 
int Pln_ManCompare3 (int *pData0, int *pData1)
 
void Pln_ManPrintFinal (Pln_Man_t *p, int fVerbose, int fVeryVerbose)
 
void Gia_PolynBuildOne (Pln_Man_t *p, int iMono)
 
void Gia_PolynBuild (Gia_Man_t *pGia, Vec_Int_t *vOrder, int fSigned, int fVerbose, int fVeryVerbose)
 
void Gia_PolynBuild2 (Gia_Man_t *pGia, int fSigned, int fVerbose, int fVeryVerbose)
 

Typedef Documentation

◆ Pln_Man_t

typedef typedefABC_NAMESPACE_IMPL_START struct Pln_Man_t_ Pln_Man_t

DECLARATIONS ///.

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

FileName [acecPolyn.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [CEC for arithmetic circuits.]

Synopsis [Polynomial extraction.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 45 of file acecPolyn.c.

Function Documentation

◆ Gia_PolynBuild()

void Gia_PolynBuild ( Gia_Man_t * pGia,
Vec_Int_t * vOrder,
int fSigned,
int fVerbose,
int fVeryVerbose )

Definition at line 340 of file acecPolyn.c.

341{
342 abctime clk = Abc_Clock();//, clk2 = 0;
343 Gia_Obj_t * pObj;
344 Vec_Bit_t * vPres = Vec_BitStart( Gia_ManObjNum(pGia) );
345 int i, iMono, iDriver, LevPrev, LevCur, Iter, Line = 0;
346 Pln_Man_t * p = Pln_ManAlloc( pGia, vOrder );
347 Gia_ManForEachCoReverse( pGia, pObj, i )
348 {
349 Vec_IntFill( p->vTempC[0], 1, i+1 ); // 2^i
350 Vec_IntFill( p->vTempC[1], 1, -i-1 ); // -2^i
351
352 iDriver = Gia_ObjFaninId0p( pGia, pObj );
353 Vec_IntFill( p->vTempM[0], 1, iDriver ); // Driver
354
355 if ( fSigned && i == Gia_ManCoNum(pGia)-1 )
356 {
357 if ( Gia_ObjFaninC0(pObj) )
358 {
359 Gia_PolynBuildAdd( p, p->vTempC[1], NULL ); // -C
360 Gia_PolynBuildAdd( p, p->vTempC[0], p->vTempM[0] ); // C * Driver
361 }
362 else
363 Gia_PolynBuildAdd( p, p->vTempC[1], p->vTempM[0] ); // -C * Driver
364 }
365 else
366 {
367 if ( Gia_ObjFaninC0(pObj) )
368 {
369 Gia_PolynBuildAdd( p, p->vTempC[0], NULL ); // C
370 Gia_PolynBuildAdd( p, p->vTempC[1], p->vTempM[0] ); // -C * Driver
371 }
372 else
373 Gia_PolynBuildAdd( p, p->vTempC[0], p->vTempM[0] ); // C * Driver
374 }
375 }
376 LevPrev = -1;
377 for ( Iter = 0; ; Iter++ )
378 {
379 Vec_Int_t * vTempM;
380 //abctime temp = Abc_Clock();
381 if ( Vec_QueSize(p->vQue) == 0 )
382 break;
383 iMono = Vec_QuePop(p->vQue);
384
385 // report
386 vTempM = Hsh_VecReadEntry( p->pHashM, iMono );
387 //printf( "Removing var %d\n", Vec_IntEntryLast(vTempM) );
388 LevCur = Vec_IntEntryLast(vTempM);
389 if ( !Gia_ObjIsAnd(Gia_ManObj(pGia, LevCur)) )
390 continue;
391
392 if ( LevPrev != LevCur )
393 {
394 if ( Vec_BitEntry( vPres, LevCur ) && fVerbose )
395 printf( "Repeating entry %d\n", LevCur );
396 else
397 Vec_BitSetEntry( vPres, LevCur, 1 );
398
399 if ( fVeryVerbose )
400 printf( "Line%5d Iter%10d : Obj =%6d. Order =%6d. HashC =%6d. HashM =%10d. Total =%10d. Used =%10d.\n",
401 Line++, Iter, LevCur, Vec_IntEntry(p->vOrder, LevCur), Hsh_VecSize(p->pHashC), Hsh_VecSize(p->pHashM), p->nBuilds, p->nUsed );
402 }
403 LevPrev = LevCur;
404
405 Gia_PolynBuildOne( p, iMono );
406 //clk2 += Abc_Clock() - temp;
407 }
408 //Abc_PrintTime( 1, "Time2", clk2 );
409 Pln_ManPrintFinal( p, fVerbose, fVeryVerbose );
410 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
411 Pln_ManStop( p );
412 Vec_BitFree( vPres );
413}
ABC_INT64_T abctime
Definition abc_global.h:332
void Pln_ManStop(Pln_Man_t *p)
Definition acecPolyn.c:101
void Pln_ManPrintFinal(Pln_Man_t *p, int fVerbose, int fVeryVerbose)
Definition acecPolyn.c:125
void Gia_PolynBuildOne(Pln_Man_t *p, int iMono)
Definition acecPolyn.c:258
typedefABC_NAMESPACE_IMPL_START struct Pln_Man_t_ Pln_Man_t
DECLARATIONS ///.
Definition acecPolyn.c:45
Pln_Man_t * Pln_ManAlloc(Gia_Man_t *pGia, Vec_Int_t *vOrder)
FUNCTION DEFINITIONS ///.
Definition acecPolyn.c:76
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
#define Gia_ManForEachCoReverse(p, pObj, i)
Definition gia.h:1242
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
Definition vecBit.h:42
Here is the call graph for this function:

◆ Gia_PolynBuild2()

void Gia_PolynBuild2 ( Gia_Man_t * pGia,
int fSigned,
int fVerbose,
int fVeryVerbose )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 428 of file acecPolyn.c.

429{
430 Hsh_VecMan_t * pHashC = Hsh_VecManStart( 1000 ); // hash table for constants
431 Hsh_VecMan_t * pHashM = Hsh_VecManStart( 1000 ); // hash table for monomials
432 //Vec_Wec_t * vLit2Mono = Vec_WecStart( Gia_ManObjNum(pGia) * 2 );
433
434 Hsh_VecManStop( pHashC );
435 Hsh_VecManStop( pHashM );
436}
struct Hsh_VecMan_t_ Hsh_VecMan_t
Definition vecHsh.h:85

◆ Gia_PolynBuildOne()

void Gia_PolynBuildOne ( Pln_Man_t * p,
int iMono )

Definition at line 258 of file acecPolyn.c.

259{
260 Gia_Obj_t * pObj;
261 Vec_Int_t * vArray, * vConst;
262 int iFan0, iFan1;
263 int k, iConst, iDriver;
264
265 assert( Vec_IntSize(p->vCoefs) == Hsh_VecSize(p->pHashM) );
266 vArray = Hsh_VecReadEntry( p->pHashM, iMono );
267 iDriver = Vec_IntEntryLast( vArray );
268 pObj = Gia_ManObj( p->pGia, iDriver );
269 if ( !Gia_ObjIsAnd(pObj) )
270 return;
271 assert( !Gia_ObjIsMux(p->pGia, pObj) );
272
273 iConst = Vec_IntEntry( p->vCoefs, iMono );
274 if ( iConst == 0 )
275 return;
276 Vec_IntWriteEntry( p->vCoefs, iMono, 0 );
277 p->nUsed--;
278
279 iFan0 = Gia_ObjFaninId0p(p->pGia, pObj);
280 iFan1 = Gia_ObjFaninId1p(p->pGia, pObj);
281 for ( k = 0; k < 4; k++ )
282 {
283 Vec_IntClear( p->vTempM[k] );
284 Vec_IntAppend( p->vTempM[k], vArray );
285 Vec_IntPop( p->vTempM[k] );
286 if ( k == 1 || k == 3 )
287 Vec_IntPushUniqueOrderCost( p->vTempM[k], iFan0, p->vOrder ); // x
288// Vec_IntPushUniqueOrder( p->vTempM[k], iFan0 ); // x
289 if ( k == 2 || k == 3 )
290 Vec_IntPushUniqueOrderCost( p->vTempM[k], iFan1, p->vOrder ); // y
291// Vec_IntPushUniqueOrder( p->vTempM[k], iFan1 ); // y
292 }
293
294 vConst = Hsh_VecReadEntry( p->pHashC, iConst );
295
296 if ( !Gia_ObjIsXor(pObj) )
297 for ( k = 0; k < 2; k++ )
298 Vec_IntAppendMinus( p->vTempC[k], vConst, k );
299
300 if ( Gia_ObjIsXor(pObj) )
301 {
302 vConst = Hsh_VecReadEntry( p->pHashC, iConst );
303 Vec_IntAppendMinus( p->vTempC[0], vConst, 0 );
304 Gia_PolynBuildAdd( p, p->vTempC[0], p->vTempM[1] ); // C * x
305
306 vConst = Hsh_VecReadEntry( p->pHashC, iConst );
307 Vec_IntAppendMinus( p->vTempC[0], vConst, 0 );
308 Gia_PolynBuildAdd( p, p->vTempC[0], p->vTempM[2] ); // C * y
309
310 //if ( !p->pGia->vXors || Vec_IntFind(p->pGia->vXors, iDriver) == -1 || Vec_IntFind(p->pGia->vXors, iDriver) == 5 )
311 {
312 vConst = Hsh_VecReadEntry( p->pHashC, iConst );
313 Vec_IntAppendMinus2x( p->vTempC[0], vConst );
314 Gia_PolynBuildAdd( p, p->vTempC[0], p->vTempM[3] ); // -C * x * y
315 }
316 }
317 else if ( Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) ) // C * (1 - x) * (1 - y)
318 {
319 Gia_PolynBuildAdd( p, p->vTempC[0], p->vTempM[0] ); // C * 1
320 Gia_PolynBuildAdd( p, p->vTempC[1], p->vTempM[1] ); // -C * x
321 vConst = Hsh_VecReadEntry( p->pHashC, iConst );
322 for ( k = 0; k < 2; k++ )
323 Vec_IntAppendMinus( p->vTempC[k], vConst, k );
324 Gia_PolynBuildAdd( p, p->vTempC[1], p->vTempM[2] ); // -C * y
325 Gia_PolynBuildAdd( p, p->vTempC[0], p->vTempM[3] ); // C * x * y
326 }
327 else if ( Gia_ObjFaninC0(pObj) && !Gia_ObjFaninC1(pObj) ) // C * (1 - x) * y
328 {
329 Gia_PolynBuildAdd( p, p->vTempC[0], p->vTempM[2] ); // C * y
330 Gia_PolynBuildAdd( p, p->vTempC[1], p->vTempM[3] ); // -C * x * y
331 }
332 else if ( !Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) ) // C * x * (1 - y)
333 {
334 Gia_PolynBuildAdd( p, p->vTempC[0], p->vTempM[1] ); // C * x
335 Gia_PolynBuildAdd( p, p->vTempC[1], p->vTempM[3] ); // -C * x * y
336 }
337 else
338 Gia_PolynBuildAdd( p, p->vTempC[0], p->vTempM[3] ); // C * x * y
339}
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ Pln_ManAlloc()

Pln_Man_t * Pln_ManAlloc ( Gia_Man_t * pGia,
Vec_Int_t * vOrder )

FUNCTION DEFINITIONS ///.

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

Synopsis [Computation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 76 of file acecPolyn.c.

77{
79 p->pGia = pGia;
80 p->pHashC = Hsh_VecManStart( 1000 );
81 p->pHashM = Hsh_VecManStart( 1000 );
82 p->vQue = Vec_QueAlloc( 1000 );
83 p->vCounts = Vec_FltAlloc( 1000 );
84 p->vCoefs = Vec_IntAlloc( 1000 );
85 p->vTempC[0] = Vec_IntAlloc( 100 );
86 p->vTempC[1] = Vec_IntAlloc( 100 );
87 p->vTempM[0] = Vec_IntAlloc( 100 );
88 p->vTempM[1] = Vec_IntAlloc( 100 );
89 p->vTempM[2] = Vec_IntAlloc( 100 );
90 p->vTempM[3] = Vec_IntAlloc( 100 );
91 p->vOrder = vOrder ? Vec_IntDup(vOrder) : Vec_IntStartNatural( Gia_ManObjNum(pGia) );
92 assert( Vec_IntSize(p->vOrder) == Gia_ManObjNum(pGia) );
93 Vec_QueSetPriority( p->vQue, Vec_FltArrayP(p->vCounts) );
94 // add 0-constant and 1-monomial
95 Hsh_VecManAdd( p->pHashC, p->vTempC[0] );
96 Hsh_VecManAdd( p->pHashM, p->vTempM[0] );
97 Vec_FltPush( p->vCounts, 0 );
98 Vec_IntPush( p->vCoefs, 0 );
99 return p;
100}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Here is the caller graph for this function:

◆ Pln_ManCompare3()

int Pln_ManCompare3 ( int * pData0,
int * pData1 )

Definition at line 117 of file acecPolyn.c.

118{
119 if ( pData0[0] < pData1[0] ) return -1;
120 if ( pData0[0] > pData1[0] ) return 1;
121 if ( pData0[1] < pData1[1] ) return -1;
122 if ( pData0[1] > pData1[1] ) return 1;
123 return 0;
124}
Here is the caller graph for this function:

◆ Pln_ManPrintFinal()

void Pln_ManPrintFinal ( Pln_Man_t * p,
int fVerbose,
int fVeryVerbose )

Definition at line 125 of file acecPolyn.c.

126{
127 Vec_Int_t * vArray;
128 int i, k, Entry, iMono, iConst;
129 // collect triples
130 Vec_Int_t * vPairs = Vec_IntAlloc( 100 );
131 Vec_IntForEachEntry( p->vCoefs, iConst, iMono )
132 {
133 if ( iConst == 0 )
134 continue;
135 vArray = Hsh_VecReadEntry( p->pHashC, iConst );
136 Vec_IntPush( vPairs, Vec_IntEntry(vArray, 0) );
137 vArray = Hsh_VecReadEntry( p->pHashM, iMono );
138 Vec_IntPush( vPairs, Vec_IntSize(vArray) ? Vec_IntEntry(vArray, 0) : 0 );
139 Vec_IntPushTwo( vPairs, iConst, iMono );
140 }
141 // sort triples
142 qsort( Vec_IntArray(vPairs), (size_t)(Vec_IntSize(vPairs)/4), 16, (int (*)(const void *, const void *))Pln_ManCompare3 );
143 // print
144 if ( fVerbose )
145 Vec_IntForEachEntryDouble( vPairs, iConst, iMono, i )
146 {
147 if ( i % 4 == 0 )
148 continue;
149 printf( "%-6d : ", i/4 );
150 vArray = Hsh_VecReadEntry( p->pHashC, iConst );
151 Vec_IntForEachEntry( vArray, Entry, k )
152 printf( "%s%d", Entry < 0 ? "-" : "+", (1 << (Abc_AbsInt(Entry)-1)) );
153 vArray = Hsh_VecReadEntry( p->pHashM, iMono );
154 Vec_IntForEachEntry( vArray, Entry, k )
155 printf( " * %d", Entry );
156 printf( "\n" );
157 }
158 printf( "HashC = %d. HashM = %d. Total = %d. Used = %d. ", Hsh_VecSize(p->pHashC), Hsh_VecSize(p->pHashM), p->nBuilds, Vec_IntSize(vPairs)/4 );
159 Vec_IntFree( vPairs );
160}
int Pln_ManCompare3(int *pData0, int *pData1)
Definition acecPolyn.c:117
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition vecInt.h:72
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Pln_ManStop()

void Pln_ManStop ( Pln_Man_t * p)

Definition at line 101 of file acecPolyn.c.

102{
103 Hsh_VecManStop( p->pHashC );
104 Hsh_VecManStop( p->pHashM );
105 Vec_QueFree( p->vQue );
106 Vec_FltFree( p->vCounts );
107 Vec_IntFree( p->vCoefs );
108 Vec_IntFree( p->vTempC[0] );
109 Vec_IntFree( p->vTempC[1] );
110 Vec_IntFree( p->vTempM[0] );
111 Vec_IntFree( p->vTempM[1] );
112 Vec_IntFree( p->vTempM[2] );
113 Vec_IntFree( p->vTempM[3] );
114 Vec_IntFree( p->vOrder );
115 ABC_FREE( p );
116}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function: