ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaPack.c File Reference
#include "gia.h"
Include dependency graph for giaPack.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START Vec_Int_tGia_ManLutCollect2 (Gia_Man_t *p)
 DECLARATIONS ///.
 
Vec_Int_tGia_ManLutCollect (Gia_Man_t *p)
 
void Gia_ManLutPacking (Gia_Man_t *p, int nBlockSize, int DelayRoute, int DelayDir, int fVerbose)
 

Function Documentation

◆ Gia_ManLutCollect()

Vec_Int_t * Gia_ManLutCollect ( Gia_Man_t * p)

Definition at line 80 of file giaPack.c.

81{
82 Vec_Int_t * vLuts, * vDist, * vOrder;
83 int i, k, Id, iFan, * pPerm;
84 // collect LUTs
85 vLuts = Vec_IntAlloc( Gia_ManAndNum(p) );
86 Gia_ManForEachLut( p, Id )
87 Vec_IntPush( vLuts, Id );
88 // propagate distance
89 vDist = Vec_IntStart( Gia_ManObjNum(p) );
91 Vec_IntWriteEntry( vDist, Id, 1 );
92 Vec_IntForEachEntryReverse( vLuts, Id, i )
93 {
94 int Dist = 1 + Vec_IntEntry(vDist, Id);
95 Gia_LutForEachFanin( p, Id, iFan, k )
96 Vec_IntUpdateEntry( vDist, iFan, Dist );
97 }
98 // sort LUTs by distance
99 k = 0;
100 Vec_IntForEachEntry( vLuts, Id, i )
101 Vec_IntWriteEntry( vDist, k++, -Vec_IntEntry(vDist, Id) );
102 Vec_IntShrink( vDist, k );
103 pPerm = Abc_MergeSortCost( Vec_IntArray(vDist), Vec_IntSize(vDist) );
104 // collect
105 vOrder = Vec_IntAlloc( Vec_IntSize(vLuts) );
106 for ( i = 0; i < Vec_IntSize(vLuts); i++ )
107 Vec_IntPush( vOrder, Vec_IntEntry(vLuts, pPerm[i]) );
108 Vec_IntFree( vDist );
109 Vec_IntFree( vLuts );
110 ABC_FREE( pPerm );
111 return vOrder;
112}
int * Abc_MergeSortCost(int *pCosts, int nSize)
Definition utilSort.c:442
#define ABC_FREE(obj)
Definition abc_global.h:267
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
cubedist Dist
Definition exorList.c:1012
#define Gia_ManForEachCoDriverId(p, DriverId, i)
Definition gia.h:1246
#define Gia_ManForEachLut(p, i)
Definition gia.h:1157
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition gia.h:1161
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_IntForEachEntryReverse(vVec, pEntry, i)
Definition vecInt.h:62
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManLutCollect2()

ABC_NAMESPACE_IMPL_START Vec_Int_t * Gia_ManLutCollect2 ( Gia_Man_t * p)

DECLARATIONS ///.

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

FileName [giaPack.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [LUT packing.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Collects LUT nodes in the increasing order of distance from COs.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file giaPack.c.

46{
47 Gia_Obj_t * pObj;
48 Vec_Int_t * vOrder;
49 int i, k, Id, iFan;
50 vOrder = Vec_IntAlloc( Gia_ManLutNum(p) );
52 Gia_ManForEachCoDriver( p, pObj, i )
53 {
54 if ( !Gia_ObjIsAnd(pObj) )
55 continue;
56 Id = Gia_ObjId( p, pObj );
57 assert( Gia_ObjIsLut(p, Id) );
58 if ( Gia_ObjIsTravIdCurrentId(p, Id) )
59 continue;
60 Gia_ObjSetTravIdCurrentId(p, Id);
61 Vec_IntPush( vOrder, Id );
62 }
63 Vec_IntForEachEntry( vOrder, Id, i )
64 {
65 Gia_LutForEachFanin( p, Id, iFan, k )
66 {
67 if ( !Gia_ObjIsAnd(Gia_ManObj(p, iFan)) )
68 continue;
69 assert( Gia_ObjIsLut(p, iFan) );
70 if ( Gia_ObjIsTravIdCurrentId(p, iFan) )
71 continue;
72 Gia_ObjSetTravIdCurrentId(p, iFan);
73 Vec_IntPush( vOrder, iFan );
74 }
75 }
76 assert( Vec_IntCap(vOrder) == 16 || Vec_IntSize(vOrder) == Vec_IntCap(vOrder) );
77 Vec_IntReverseOrder( vOrder );
78 return vOrder;
79}
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
int Gia_ManLutNum(Gia_Man_t *p)
Definition giaIf.c:146
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
#define Gia_ManForEachCoDriver(p, pObj, i)
Definition gia.h:1244
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Gia_ManLutPacking()

void Gia_ManLutPacking ( Gia_Man_t * p,
int nBlockSize,
int DelayRoute,
int DelayDir,
int fVerbose )

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

Synopsis [LUT packing algorithm.]

Description []

SideEffects []

SeeAlso []

Definition at line 125 of file giaPack.c.

126{
127 int Delays[32], Perm[32];
128 Vec_Int_t * vPacking, * vStarts;
129 Vec_Int_t * vOrder = Gia_ManLutCollect( p );
130 Vec_Int_t * vDelay = Vec_IntStart( Gia_ManObjNum(p) );
131 Vec_Int_t * vBlock = Vec_IntStart( Gia_ManObjNum(p) );
132 Vec_Int_t * vBSize = Vec_IntAlloc( 2 * Vec_IntSize(vOrder) / nBlockSize );
133 int i, k, Id, iFan, nSize, iBlock, Delay, DelayMax = 0;
134 // create blocks
135 Vec_IntForEachEntry( vOrder, Id, i )
136 {
137 nSize = Gia_ObjLutSize( p, Id );
138 assert( nSize <= 32 );
139 Gia_LutForEachFanin( p, Id, iFan, k )
140 {
141 Delays[k] = Vec_IntEntry(vDelay, iFan);
142 Perm[k] = iFan;
143 }
144 Vec_IntSelectSortCost2Reverse( Perm, nSize, Delays );
145 assert( nSize < 2 || Delays[0] >= Delays[nSize-1] );
146 assert( Delays[0] >= 0 && Delays[nSize-1] >= 0 );
147 // check if we can reduce delay by adding it to the same bin as the latest one
148 iBlock = Vec_IntEntry( vBlock, Perm[0] );
149 if ( Delays[0] > 0 && Delays[0] > Delays[1] && Vec_IntEntry(vBSize, iBlock) < nBlockSize )
150 {
151 Delay = Delays[0] + DelayDir;
152 Vec_IntWriteEntry( vBlock, Id, iBlock );
153 Vec_IntAddToEntry( vBSize, iBlock, 1 );
154 }
155 else // clean new block
156 {
157 Delay = Delays[0] + DelayRoute;
158 Vec_IntWriteEntry( vBlock, Id, Vec_IntSize(vBSize) );
159 Vec_IntPush( vBSize, 1 );
160 }
161 // calculate delay
162 for ( k = 1; k < nSize; k++ )
163 Delay = Abc_MaxInt( Delay, Delays[k] + DelayRoute );
164 Vec_IntWriteEntry( vDelay, Id, Delay );
165 DelayMax = Abc_MaxInt( DelayMax, Delay );
166 }
167 assert( Vec_IntSum(vBSize) == Vec_IntSize(vOrder) );
168 // create packing info
169 vPacking = Vec_IntAlloc( Vec_IntSize(vBSize) + Vec_IntSize(vOrder) + 1 );
170 Vec_IntPush( vPacking, Vec_IntSize(vBSize) );
171 // create starting places for each block
172 vStarts = Vec_IntAlloc( Vec_IntSize(vBSize) );
173 Vec_IntForEachEntry( vBSize, nSize, i )
174 {
175 Vec_IntPush( vPacking, nSize );
176 Vec_IntPush( vStarts, Vec_IntSize(vPacking) );
177 Vec_IntFillExtra( vPacking, Vec_IntSize(vPacking) + nSize, -1 );
178 }
179 assert( Vec_IntCap(vPacking) == 16 || Vec_IntSize(vPacking) == Vec_IntCap(vPacking) );
180 // collect LUTs from the block
181 Vec_IntForEachEntryReverse( vOrder, Id, i )
182 {
183 int Block = Vec_IntEntry( vBlock, Id );
184 int Start = Vec_IntEntry( vStarts, Block );
185 assert( Vec_IntEntry(vPacking, Start) == -1 );
186 Vec_IntWriteEntry( vPacking, Start, Id );
187 Vec_IntAddToEntry( vStarts, Block, 1 );
188 }
189 assert( Vec_IntCountEntry(vPacking, -1) == 0 );
190 // cleanup
191 Vec_IntFree( vOrder );
192 Vec_IntFree( vDelay );
193 Vec_IntFree( vBlock );
194 Vec_IntFree( vBSize );
195 Vec_IntFree( vStarts );
196 Vec_IntFreeP( &p->vPacking );
197 p->vPacking = vPacking;
198 printf( "Global delay = %d.\n", DelayMax );
199}
Vec_Int_t * Gia_ManLutCollect(Gia_Man_t *p)
Definition giaPack.c:80
Here is the call graph for this function: