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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Llb_MtrVerifyRowsAll (Llb_Mtr_t *p)
 DECLARATIONS ///.
 
void Llb_MtrVerifyColumnsAll (Llb_Mtr_t *p)
 
void Llb_MtrVerifyMatrix (Llb_Mtr_t *p)
 
int * Llb_MtrFindVarOrder (Llb_Mtr_t *p)
 
char * Llb_MtrVarName (Llb_Mtr_t *p, int iVar)
 
void Llb_MtrPrint (Llb_Mtr_t *p, int fOrder)
 
void Llb_MtrPrintMatrixStats (Llb_Mtr_t *p)
 
Llb_Mtr_tLlb_MtrAlloc (int nPis, int nFfs, int nCols, int nRows)
 
void Llb_MtrFree (Llb_Mtr_t *p)
 
void Llb_MtrAddColumn (Llb_Mtr_t *p, Llb_Grp_t *pGrp)
 
void Llb_MtrRemoveSingletonRows (Llb_Mtr_t *p)
 
Llb_Mtr_tLlb_MtrCreate (Llb_Man_t *p)
 

Function Documentation

◆ Llb_MtrAddColumn()

void Llb_MtrAddColumn ( Llb_Mtr_t * p,
Llb_Grp_t * pGrp )

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

Synopsis [Creates one column with vars in the array.]

Description []

SideEffects []

SeeAlso []

Definition at line 346 of file llb1Matrix.c.

347{
348 Aig_Obj_t * pVar;
349 int i, iRow, iCol = pGrp->Id;
350 assert( iCol >= 0 && iCol < p->nCols );
351 p->pColGrps[iCol] = pGrp;
352 Vec_PtrForEachEntry( Aig_Obj_t *, pGrp->vIns, pVar, i )
353 {
354 iRow = Vec_IntEntry( pGrp->pMan->vObj2Var, Aig_ObjId(pVar) );
355 assert( iRow >= 0 && iRow < p->nRows );
356 p->pMatrix[iCol][iRow] = 1;
357 p->pColSums[iCol]++;
358 p->pRowSums[iRow]++;
359 }
360 Vec_PtrForEachEntry( Aig_Obj_t *, pGrp->vOuts, pVar, i )
361 {
362 iRow = Vec_IntEntry( pGrp->pMan->vObj2Var, Aig_ObjId(pVar) );
363 assert( iRow >= 0 && iRow < p->nRows );
364 p->pMatrix[iCol][iRow] = 1;
365 p->pColSums[iCol]++;
366 p->pRowSums[iRow]++;
367 }
368}
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
Cube * p
Definition exorList.c:222
int Id
Definition llbInt.h:97
Vec_Ptr_t * vIns
Definition llbInt.h:98
Vec_Ptr_t * vOuts
Definition llbInt.h:99
Llb_Man_t * pMan
Definition llbInt.h:101
#define assert(ex)
Definition util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the caller graph for this function:

◆ Llb_MtrAlloc()

Llb_Mtr_t * Llb_MtrAlloc ( int nPis,
int nFfs,
int nCols,
int nRows )

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

Synopsis [Starts the matrix representation.]

Description []

SideEffects []

SeeAlso []

Definition at line 289 of file llb1Matrix.c.

290{
291 Llb_Mtr_t * p;
292 int i;
293 p = ABC_CALLOC( Llb_Mtr_t, 1 );
294 p->nPis = nPis;
295 p->nFfs = nFfs;
296 p->nRows = nRows;
297 p->nCols = nCols;
298 p->pRowSums = ABC_CALLOC( int, nRows );
299 p->pColSums = ABC_CALLOC( int, nCols );
300 p->pColGrps = ABC_CALLOC( Llb_Grp_t *, nCols );
301 p->pMatrix = ABC_CALLOC( char *, nCols );
302 for ( i = 0; i < nCols; i++ )
303 p->pMatrix[i] = ABC_CALLOC( char, nRows );
304 // partial product
305 p->pProdVars = ABC_CALLOC( char, nRows ); // variables in the partial product
306 p->pProdNums = ABC_CALLOC( int, nRows ); // var counts in the remaining partitions
307 return p;
308}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
struct Llb_Grp_t_ Llb_Grp_t
Definition llbInt.h:49
struct Llb_Mtr_t_ Llb_Mtr_t
Definition llbInt.h:48
Here is the caller graph for this function:

◆ Llb_MtrCreate()

Llb_Mtr_t * Llb_MtrCreate ( Llb_Man_t * p)

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

Synopsis [Matrix reduce.]

Description []

SideEffects []

SeeAlso []

Definition at line 410 of file llb1Matrix.c.

411{
412 Llb_Mtr_t * pMatrix;
413 Llb_Grp_t * pGroup;
414 int i;
415 pMatrix = Llb_MtrAlloc( Saig_ManPiNum(p->pAig), Saig_ManRegNum(p->pAig),
416 Vec_PtrSize(p->vGroups), Vec_IntSize(p->vVar2Obj) );
417 Vec_PtrForEachEntry( Llb_Grp_t *, p->vGroups, pGroup, i )
418 Llb_MtrAddColumn( pMatrix, pGroup );
419// Llb_MtrRemoveSingletonRows( pMatrix );
420 return pMatrix;
421}
void Llb_MtrAddColumn(Llb_Mtr_t *p, Llb_Grp_t *pGrp)
Definition llb1Matrix.c:346
Llb_Mtr_t * Llb_MtrAlloc(int nPis, int nFfs, int nCols, int nRows)
Definition llb1Matrix.c:289
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Llb_MtrFindVarOrder()

int * Llb_MtrFindVarOrder ( Llb_Mtr_t * p)

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

Synopsis [Sort variables in the order of removal.]

Description []

SideEffects []

SeeAlso []

Definition at line 132 of file llb1Matrix.c.

133{
134 int * pOrder, * pLast;
135 int i, k, fChanges, Temp;
136 pOrder = ABC_CALLOC( int, p->nRows );
137 pLast = ABC_CALLOC( int, p->nRows );
138 for ( i = 0; i < p->nRows; i++ )
139 {
140 pOrder[i] = i;
141 for ( k = p->nCols - 1; k >= 0; k-- )
142 if ( p->pMatrix[k][i] )
143 {
144 pLast[i] = k;
145 break;
146 }
147 }
148 do
149 {
150 fChanges = 0;
151 for ( i = 0; i < p->nRows - 1; i++ )
152 if ( pLast[i] > pLast[i+1] )
153 {
154 Temp = pOrder[i];
155 pOrder[i] = pOrder[i+1];
156 pOrder[i+1] = Temp;
157
158 Temp = pLast[i];
159 pLast[i] = pLast[i+1];
160 pLast[i+1] = Temp;
161
162 fChanges = 1;
163 }
164 }
165 while ( fChanges );
166 ABC_FREE( pLast );
167 return pOrder;
168}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Llb_MtrFree()

void Llb_MtrFree ( Llb_Mtr_t * p)

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

Synopsis [Stops the matrix representation.]

Description []

SideEffects []

SeeAlso []

Definition at line 321 of file llb1Matrix.c.

322{
323 int i;
324 ABC_FREE( p->pProdVars );
325 ABC_FREE( p->pProdNums );
326 for ( i = 0; i < p->nCols; i++ )
327 ABC_FREE( p->pMatrix[i] );
328 ABC_FREE( p->pRowSums );
329 ABC_FREE( p->pColSums );
330 ABC_FREE( p->pMatrix );
331 ABC_FREE( p->pColGrps );
332 ABC_FREE( p );
333}
Here is the caller graph for this function:

◆ Llb_MtrPrint()

void Llb_MtrPrint ( Llb_Mtr_t * p,
int fOrder )

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

Synopsis [Creates one column with vars in the array.]

Description []

SideEffects []

SeeAlso []

Definition at line 206 of file llb1Matrix.c.

207{
208 int * pOrder = NULL;
209 int i, iRow, iCol;
210 if ( fOrder )
211 pOrder = Llb_MtrFindVarOrder( p );
212 for ( i = 0; i < p->nRows; i++ )
213 {
214 iRow = pOrder ? pOrder[i] : i;
215 printf( "%3d : ", iRow );
216 printf( "%3d ", p->pRowSums[iRow] );
217 printf( "%3s ", Llb_MtrVarName(p, iRow) );
218 for ( iCol = 0; iCol < p->nCols; iCol++ )
219 printf( "%c", p->pMatrix[iCol][iRow] ? '*' : ' ' );
220 printf( "\n" );
221 }
222 ABC_FREE( pOrder );
223}
char * Llb_MtrVarName(Llb_Mtr_t *p, int iVar)
Definition llb1Matrix.c:181
int * Llb_MtrFindVarOrder(Llb_Mtr_t *p)
Definition llb1Matrix.c:132
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Llb_MtrPrintMatrixStats()

void Llb_MtrPrintMatrixStats ( Llb_Mtr_t * p)

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

Synopsis [Verify columns.]

Description []

SideEffects []

SeeAlso []

Definition at line 236 of file llb1Matrix.c.

237{
238 int iVar, iGrp, iGrp1, iGrp2, Span = 0, nCutSize = 0, nCutSizeMax = 0;
239 int * pGrp1 = ABC_CALLOC( int, p->nRows );
240 int * pGrp2 = ABC_CALLOC( int, p->nRows );
241 for ( iVar = 0; iVar < p->nRows; iVar++ )
242 {
243 if ( p->pRowSums[iVar] == 0 )
244 continue;
245 for ( iGrp1 = 0; iGrp1 < p->nCols; iGrp1++ )
246 if ( p->pMatrix[iGrp1][iVar] == 1 )
247 break;
248 for ( iGrp2 = p->nCols - 1; iGrp2 >= 0; iGrp2-- )
249 if ( p->pMatrix[iGrp2][iVar] == 1 )
250 break;
251 assert( iGrp1 <= iGrp2 );
252 pGrp1[iVar] = iGrp1;
253 pGrp2[iVar] = iGrp2;
254 Span += iGrp2 - iGrp1;
255 }
256 // compute span
257 for ( iGrp = 0; iGrp < p->nCols; iGrp++ )
258 {
259 for ( iVar = 0; iVar < p->nRows; iVar++ )
260 if ( pGrp1[iVar] == iGrp )
261 nCutSize++;
262 if ( nCutSizeMax < nCutSize )
263 nCutSizeMax = nCutSize;
264 for ( iVar = 0; iVar < p->nRows; iVar++ )
265 if ( pGrp2[iVar] == iGrp )
266 nCutSize--;
267 }
268 ABC_FREE( pGrp1 );
269 ABC_FREE( pGrp2 );
270 printf( "[%4d x %4d] Life-span =%6.2f Max-cut =%5d\n",
271 p->nCols, p->nRows, 1.0*Span/p->nRows, nCutSizeMax );
272 if ( nCutSize )
273 Abc_Print( -1, "Cut size is not zero (%d).\n", nCutSize );
274}
Here is the caller graph for this function:

◆ Llb_MtrRemoveSingletonRows()

void Llb_MtrRemoveSingletonRows ( Llb_Mtr_t * p)

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

Synopsis [Matrix reduce.]

Description []

SideEffects []

SeeAlso []

Definition at line 381 of file llb1Matrix.c.

382{
383 int i, k;
384 for ( i = 0; i < p->nRows; i++ )
385 if ( p->pRowSums[i] < 2 )
386 {
387 p->pRowSums[i] = 0;
388 for ( k = 0; k < p->nCols; k++ )
389 {
390 if ( p->pMatrix[k][i] == 1 )
391 {
392 p->pMatrix[k][i] = 0;
393 p->pColSums[k]--;
394 }
395 }
396 }
397}

◆ Llb_MtrVarName()

char * Llb_MtrVarName ( Llb_Mtr_t * p,
int iVar )

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

Synopsis [Returns type of a variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 181 of file llb1Matrix.c.

182{
183 static char Buffer[10];
184 if ( iVar < p->nPis )
185 strcpy( Buffer, "pi" );
186 else if ( iVar < p->nPis + p->nFfs )
187 strcpy( Buffer, "CS" );
188 else if ( iVar >= p->nRows - p->nFfs )
189 strcpy( Buffer, "NS" );
190 else
191 strcpy( Buffer, "int" );
192 return Buffer;
193}
char * strcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Llb_MtrVerifyColumnsAll()

void Llb_MtrVerifyColumnsAll ( Llb_Mtr_t * p)

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

Synopsis [Verify columns.]

Description []

SideEffects []

SeeAlso []

Definition at line 91 of file llb1Matrix.c.

92{
93 int iRow, iCol, Counter;
94 for ( iRow = 0; iRow < p->nRows; iRow++ )
95 {
96 Counter = 0;
97 for ( iCol = 0; iCol < p->nCols; iCol++ )
98 if ( p->pMatrix[iCol][iRow] == 1 )
99 Counter++;
100 assert( Counter == p->pRowSums[iRow] );
101 }
102}
Here is the caller graph for this function:

◆ Llb_MtrVerifyMatrix()

void Llb_MtrVerifyMatrix ( Llb_Mtr_t * p)

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

Synopsis [Verify columns.]

Description []

SideEffects []

SeeAlso []

Definition at line 115 of file llb1Matrix.c.

116{
119}
ABC_NAMESPACE_IMPL_START void Llb_MtrVerifyRowsAll(Llb_Mtr_t *p)
DECLARATIONS ///.
Definition llb1Matrix.c:67
void Llb_MtrVerifyColumnsAll(Llb_Mtr_t *p)
Definition llb1Matrix.c:91
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Llb_MtrVerifyRowsAll()

ABC_NAMESPACE_IMPL_START void Llb_MtrVerifyRowsAll ( Llb_Mtr_t * p)

DECLARATIONS ///.

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

FileName [llb1Matrix.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [BDD based reachability.]

Synopsis [Partition clustering as a matrix problem.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Verify columns.]

Description []

SideEffects []

SeeAlso []

Definition at line 67 of file llb1Matrix.c.

68{
69 int iRow, iCol, Counter;
70 for ( iCol = 0; iCol < p->nCols; iCol++ )
71 {
72 Counter = 0;
73 for ( iRow = 0; iRow < p->nRows; iRow++ )
74 if ( p->pMatrix[iCol][iRow] == 1 )
75 Counter++;
76 assert( Counter == p->pColSums[iCol] );
77 }
78}
Here is the caller graph for this function: