abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fxuPrint.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [fxuPrint.c]
4 
5  PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
6 
7  Synopsis [Various printing procedures.]
8 
9  Author [MVSIS Group]
10 
11  Affiliation [UC Berkeley]
12 
13  Date [Ver. 1.0. Started - February 1, 2003.]
14 
15  Revision [$Id: fxuPrint.c,v 1.0 2003/02/01 00:00:00 alanmi Exp $]
16 
17 ***********************************************************************/
18 
19 #include "fxuInt.h"
20 
22 
23 
24 ////////////////////////////////////////////////////////////////////////
25 /// DECLARATIONS ///
26 ////////////////////////////////////////////////////////////////////////
27 
28 ////////////////////////////////////////////////////////////////////////
29 /// FUNCTION DEFINITIONS ///
30 ////////////////////////////////////////////////////////////////////////
31 
32 /**Function*************************************************************
33 
34  Synopsis []
35 
36  Description []
37 
38  SideEffects []
39 
40  SeeAlso []
41 
42 ***********************************************************************/
43 void Fxu_MatrixPrint( FILE * pFile, Fxu_Matrix * p )
44 {
45  Fxu_Var * pVar;
46  Fxu_Cube * pCube;
47  Fxu_Double * pDiv;
48  Fxu_Single * pSingle;
49  Fxu_Lit * pLit;
50  Fxu_Pair * pPair;
51  int i, LastNum;
52  int fStdout;
53 
54  fStdout = 1;
55  if ( pFile == NULL )
56  {
57  pFile = fopen( "matrix.txt", "w" );
58  fStdout = 0;
59  }
60 
61  fprintf( pFile, "Matrix has %d vars, %d cubes, %d literals, %d divisors.\n",
62  p->lVars.nItems, p->lCubes.nItems, p->nEntries, p->nDivs );
63  fprintf( pFile, "Divisors selected so far: single = %d, double = %d.\n",
64  p->nDivs1, p->nDivs2 );
65  fprintf( pFile, "\n" );
66 
67  // print the numbers on top of the matrix
68  for ( i = 0; i < 12; i++ )
69  fprintf( pFile, " " );
70  Fxu_MatrixForEachVariable( p, pVar )
71  fprintf( pFile, "%d", pVar->iVar % 10 );
72  fprintf( pFile, "\n" );
73 
74  // print the rows
75  Fxu_MatrixForEachCube( p, pCube )
76  {
77  fprintf( pFile, "%4d", pCube->iCube );
78  fprintf( pFile, " " );
79  fprintf( pFile, "%4d", pCube->pVar->iVar );
80  fprintf( pFile, " " );
81 
82  // print the literals
83  LastNum = -1;
84  Fxu_CubeForEachLiteral( pCube, pLit )
85  {
86  for ( i = LastNum + 1; i < pLit->pVar->iVar; i++ )
87  fprintf( pFile, "." );
88  fprintf( pFile, "1" );
89  LastNum = i;
90  }
91  for ( i = LastNum + 1; i < p->lVars.nItems; i++ )
92  fprintf( pFile, "." );
93  fprintf( pFile, "\n" );
94  }
95  fprintf( pFile, "\n" );
96 
97  // print the double-cube divisors
98  fprintf( pFile, "The double divisors are:\n" );
99  Fxu_MatrixForEachDouble( p, pDiv, i )
100  {
101  fprintf( pFile, "Divisor #%3d (lit=%d,%d) (w=%2d): ",
102  pDiv->Num, pDiv->lPairs.pHead->nLits1,
103  pDiv->lPairs.pHead->nLits2, pDiv->Weight );
104  Fxu_DoubleForEachPair( pDiv, pPair )
105  fprintf( pFile, " <%d, %d> (b=%d)",
106  pPair->pCube1->iCube, pPair->pCube2->iCube, pPair->nBase );
107  fprintf( pFile, "\n" );
108  }
109  fprintf( pFile, "\n" );
110 
111  // print the divisors associated with each cube
112  fprintf( pFile, "The cubes are:\n" );
113  Fxu_MatrixForEachCube( p, pCube )
114  {
115  fprintf( pFile, "Cube #%3d: ", pCube->iCube );
116  if ( pCube->pVar->ppPairs )
117  {
118  Fxu_CubeForEachPair( pCube, pPair, i )
119  fprintf( pFile, " <%d %d> (d=%d) (b=%d)",
120  pPair->iCube1, pPair->iCube2, pPair->pDiv->Num, pPair->nBase );
121  }
122  fprintf( pFile, "\n" );
123  }
124  fprintf( pFile, "\n" );
125 
126  // print the single-cube divisors
127  fprintf( pFile, "The single divisors are:\n" );
128  Fxu_MatrixForEachSingle( p, pSingle )
129  {
130  fprintf( pFile, "Single-cube divisor #%5d: Var1 = %4d. Var2 = %4d. Weight = %2d\n",
131  pSingle->Num, pSingle->pVar1->iVar, pSingle->pVar2->iVar, pSingle->Weight );
132  }
133  fprintf( pFile, "\n" );
134 
135 /*
136  {
137  int Index;
138  fprintf( pFile, "Distribution of divisors in the hash table:\n" );
139  for ( Index = 0; Index < p->nTableSize; Index++ )
140  fprintf( pFile, " %d", p->pTable[Index].nItems );
141  fprintf( pFile, "\n" );
142  }
143 */
144  if ( !fStdout )
145  fclose( pFile );
146 }
147 
148 /**Function*************************************************************
149 
150  Synopsis []
151 
152  Description []
153 
154  SideEffects []
155 
156  SeeAlso []
157 
158 ***********************************************************************/
160 {
161  Fxu_Double * pDiv;
162  int WeightMax;
163  int * pProfile;
164  int Counter1; // the number of -1 weight
165  int CounterL; // the number of less than -1 weight
166  int i;
167 
168  WeightMax = Fxu_HeapDoubleReadMaxWeight( p->pHeapDouble );
169  pProfile = ABC_ALLOC( int, (WeightMax + 1) );
170  memset( pProfile, 0, sizeof(int) * (WeightMax + 1) );
171 
172  Counter1 = 0;
173  CounterL = 0;
174  Fxu_MatrixForEachDouble( p, pDiv, i )
175  {
176  assert( pDiv->Weight <= WeightMax );
177  if ( pDiv->Weight == -1 )
178  Counter1++;
179  else if ( pDiv->Weight < 0 )
180  CounterL++;
181  else
182  pProfile[ pDiv->Weight ]++;
183  }
184 
185  fprintf( pFile, "The double divisors profile:\n" );
186  fprintf( pFile, "Weight < -1 divisors = %6d\n", CounterL );
187  fprintf( pFile, "Weight -1 divisors = %6d\n", Counter1 );
188  for ( i = 0; i <= WeightMax; i++ )
189  if ( pProfile[i] )
190  fprintf( pFile, "Weight %3d divisors = %6d\n", i, pProfile[i] );
191  fprintf( pFile, "End of divisor profile printout\n" );
192  ABC_FREE( pProfile );
193 }
194 
195 
196 ////////////////////////////////////////////////////////////////////////
197 /// END OF FILE ///
198 ////////////////////////////////////////////////////////////////////////
199 
200 
202 
char * memset()
Definition: fxuInt.h:213
int iCube
Definition: fxuInt.h:203
Fxu_Pair * pHead
Definition: fxuInt.h:117
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int iVar
Definition: fxuInt.h:215
int iCube1
Definition: fxuInt.h:247
Fxu_ListPair lPairs
Definition: fxuInt.h:260
#define Fxu_MatrixForEachSingle(Matrix, Single)
Definition: fxuInt.h:312
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Fxu_Var * pVar2
Definition: fxuInt.h:273
Fxu_Cube * pCube1
Definition: fxuInt.h:245
int Fxu_HeapDoubleReadMaxWeight(Fxu_HeapDouble *p)
Definition: fxuHeapD.c:319
Fxu_Double * pDiv
Definition: fxuInt.h:244
#define Fxu_MatrixForEachVariable(Matrix, Var)
Definition: fxuInt.h:303
#define Fxu_DoubleForEachPair(Div, Pair)
Definition: fxuInt.h:357
int Num
Definition: fxuInt.h:256
#define Fxu_CubeForEachLiteral(Cube, Lit)
Definition: fxuInt.h:338
Fxu_Var * pVar
Definition: fxuInt.h:205
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
int nBase
Definition: fxuInt.h:243
void Fxu_MatrixPrintDivisorProfile(FILE *pFile, Fxu_Matrix *p)
Definition: fxuPrint.c:159
int nLits2
Definition: fxuInt.h:242
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
Fxu_Cube * pCube2
Definition: fxuInt.h:246
ABC_NAMESPACE_IMPL_START void Fxu_MatrixPrint(FILE *pFile, Fxu_Matrix *p)
DECLARATIONS ///.
Definition: fxuPrint.c:43
Fxu_Var * pVar1
Definition: fxuInt.h:272
int Weight
Definition: fxuInt.h:258
#define Fxu_MatrixForEachCube(Matrix, Cube)
Definition: fxuInt.h:294
#define ABC_FREE(obj)
Definition: abc_global.h:232
Fxu_Pair *** ppPairs
Definition: fxuInt.h:218
int Weight
Definition: fxuInt.h:271
Fxu_Var * pVar
Definition: fxuInt.h:231
#define assert(ex)
Definition: util_old.h:213
int Num
Definition: fxuInt.h:269
int nLits1
Definition: fxuInt.h:241
typedefABC_NAMESPACE_HEADER_START struct FxuMatrix Fxu_Matrix
INCLUDES ///.
Definition: fxuInt.h:63
Definition: fxuInt.h:226
#define Fxu_MatrixForEachDouble(Matrix, Div, Index)
Definition: fxuInt.h:330
int iCube2
Definition: fxuInt.h:248
#define Fxu_CubeForEachPair(pCube, pPair, i)
Definition: fxuInt.h:368