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

Go to the source code of this file.

Functions

CubeIterCubeSetStart ()
 EXTERNAL FUNCTIONS ///.
 
CubeIterCubeSetNext ()
 
varvalue GetVar (Cube *pC, int Var)
 INLINE FUNCTION DEFINITIONS ///.
 
int CountLiterals ()
 FUNCTION DECLARATIONS ///.
 
int CountLiteralsCheck ()
 
int CountQCost ()
 
void WriteTableIntoFile (FILE *pFile)
 
int WriteResultIntoFile (char *pFileName)
 

Variables

ABC_NAMESPACE_IMPL_START cinfo g_CoverInfo
 EXTERNAL VARIABLES ////.
 

Function Documentation

◆ CountLiterals()

int CountLiterals ( )

FUNCTION DECLARATIONS ///.

Definition at line 77 of file exorUtil.c.

78{
79 Cube* p;
80 int LitCounter = 0;
81 for ( p = IterCubeSetStart( ); p; p = IterCubeSetNext() )
82 LitCounter += p->a;
83 return LitCounter;
84}
Cube * p
Definition exorList.c:222
Cube * IterCubeSetStart()
EXTERNAL FUNCTIONS ///.
Definition exorList.c:880
Cube * IterCubeSetNext()
Definition exorList.c:892
struct cube Cube
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CountLiteralsCheck()

int CountLiteralsCheck ( )

Definition at line 86 of file exorUtil.c.

87{
88 Cube* p;
89 int Value, v;
90 int LitCounter = 0;
91 int LitCounterControl = 0;
92
93 for ( p = IterCubeSetStart( ); p; p = IterCubeSetNext() )
94 {
95 LitCounterControl += p->a;
96
97 assert( p->fMark == 0 );
98
99 // write the input variables
100 for ( v = 0; v < g_CoverInfo.nVarsIn; v++ )
101 {
102 Value = GetVar( p, v );
103 if ( Value == VAR_NEG )
104 LitCounter++;
105 else if ( Value == VAR_POS )
106 LitCounter++;
107 else if ( Value != VAR_ABS )
108 {
109 assert(0);
110 }
111 }
112 }
113
114 if ( LitCounterControl != LitCounter )
115 printf( "Warning! The recorded number of literals (%d) differs from the actual number (%d)\n", LitCounterControl, LitCounter );
116 return LitCounter;
117}
varvalue GetVar(Cube *pC, int Var)
INLINE FUNCTION DEFINITIONS ///.
Definition exorBits.c:188
ABC_NAMESPACE_IMPL_START cinfo g_CoverInfo
GLOBAL VARIABLES ///.
Definition exor.c:58
@ VAR_POS
Definition exor.h:178
@ VAR_NEG
Definition exor.h:178
@ VAR_ABS
Definition exor.h:178
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CountQCost()

int CountQCost ( )

Definition at line 119 of file exorUtil.c.

120{
121 Cube* p;
122 int QCost = 0;
123 int QCostControl = 0;
124 for ( p = IterCubeSetStart( ); p; p = IterCubeSetNext() )
125 {
126 QCostControl += p->q;
127 QCost += ComputeQCostBits( p );
128 }
129// if ( QCostControl != QCost )
130// printf( "Warning! The recorded number of literals (%d) differs from the actual number (%d)\n", QCostControl, QCost );
131 return QCost;
132}
int ComputeQCostBits(Cube *p)
Definition exor.c:139
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVar()

varvalue GetVar ( Cube * pC,
int Var )
extern

INLINE FUNCTION DEFINITIONS ///.

Definition at line 188 of file exorBits.c.

190{
191 int Bit = (Var<<1);
192 int Value = ((pC->pCubeDataIn[VarWord(Bit)] >> VarBit(Bit)) & 3);
193 assert( Value == VAR_NEG || Value == VAR_POS || Value == VAR_ABS );
194 return (varvalue)Value;
195}
int Var
Definition exorList.c:228
varvalue
VARVALUE and CUBEDIST enum typedefs ///.
Definition exor.h:178
drow * pCubeDataIn
Definition exor.h:129
Here is the caller graph for this function:

◆ IterCubeSetNext()

Cube * IterCubeSetNext ( )
extern

Definition at line 892 of file exorList.c.

895{
897 return ( s_pCubeLast = s_pCubeLast->Next );
898}
Cube * s_pCubeLast
CUBE ITERATOR ///.
Definition exorList.c:874
Here is the caller graph for this function:

◆ IterCubeSetStart()

Cube * IterCubeSetStart ( )
extern

EXTERNAL FUNCTIONS ///.

EXTERNAL FUNCTIONS ///.

Definition at line 880 of file exorList.c.

882{
883 assert( s_pCubeLast == NULL );
884
885 // check whether the List has cubes
886 if ( s_List == NULL )
887 return NULL;
888
889 return ( s_pCubeLast = s_List );
890}
Here is the caller graph for this function:

◆ WriteResultIntoFile()

int WriteResultIntoFile ( char * pFileName)

Definition at line 182 of file exorUtil.c.

184{
185 FILE * pFile;
186 time_t ltime;
187 char * TimeStr;
188
189 pFile = fopen( pFileName, "w" );
190 if ( pFile == NULL )
191 {
192 fprintf( stderr, "\n\nCannot open the output file\n" );
193 return 1;
194 }
195
196 // get current time
197 time( &ltime );
198 TimeStr = asctime( localtime( &ltime ) );
199 // get the number of literals
200 g_CoverInfo.nLiteralsAfter = CountLiteralsCheck();
201 g_CoverInfo.QCostAfter = CountQCost();
202 fprintf( pFile, "# EXORCISM-4 output for command line arguments: " );
203 fprintf( pFile, "\"-Q %d -V %d\"\n", g_CoverInfo.Quality, g_CoverInfo.Verbosity );
204 fprintf( pFile, "# Minimization performed %s", TimeStr );
205 fprintf( pFile, "# Initial statistics: " );
206 fprintf( pFile, "Cubes = %d Literals = %d QCost = %d\n", g_CoverInfo.nCubesBefore, g_CoverInfo.nLiteralsBefore, g_CoverInfo.QCostBefore );
207 fprintf( pFile, "# Final statistics: " );
208 fprintf( pFile, "Cubes = %d Literals = %d QCost = %d\n", g_CoverInfo.nCubesInUse, g_CoverInfo.nLiteralsAfter, g_CoverInfo.QCostAfter );
209 fprintf( pFile, "# File reading and reordering time = %.2f sec\n", TICKS_TO_SECONDS(g_CoverInfo.TimeRead) );
210 fprintf( pFile, "# Starting cover generation time = %.2f sec\n", TICKS_TO_SECONDS(g_CoverInfo.TimeStart) );
211 fprintf( pFile, "# Pure ESOP minimization time = %.2f sec\n", TICKS_TO_SECONDS(g_CoverInfo.TimeMin) );
212 fprintf( pFile, ".i %d\n", g_CoverInfo.nVarsIn );
213 fprintf( pFile, ".o %d\n", g_CoverInfo.nVarsOut );
214 fprintf( pFile, ".p %d\n", g_CoverInfo.nCubesInUse );
215 fprintf( pFile, ".type esop\n" );
216 WriteTableIntoFile( pFile );
217 fprintf( pFile, ".e\n" );
218 fclose( pFile );
219 return 0;
220}
int CountQCost()
Definition exorUtil.c:119
int CountLiteralsCheck()
Definition exorUtil.c:86
void WriteTableIntoFile(FILE *pFile)
Definition exorUtil.c:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteTableIntoFile()

void WriteTableIntoFile ( FILE * pFile)

Definition at line 135 of file exorUtil.c.

137{
138 int v, w;
139 Cube * p;
140 int cOutputs;
141 int nOutput;
142 int WordSize;
143
144 for ( p = IterCubeSetStart( ); p; p = IterCubeSetNext() )
145 {
146 assert( p->fMark == 0 );
147
148 // write the input variables
149 for ( v = 0; v < g_CoverInfo.nVarsIn; v++ )
150 {
151 int Value = GetVar( p, v );
152 if ( Value == VAR_NEG )
153 fprintf( pFile, "0" );
154 else if ( Value == VAR_POS )
155 fprintf( pFile, "1" );
156 else if ( Value == VAR_ABS )
157 fprintf( pFile, "-" );
158 else
159 assert(0);
160 }
161 fprintf( pFile, " " );
162
163 // write the output variables
164 cOutputs = 0;
165 nOutput = g_CoverInfo.nVarsOut;
166 WordSize = 8*sizeof( unsigned );
167 for ( w = 0; w < g_CoverInfo.nWordsOut; w++ )
168 for ( v = 0; v < WordSize; v++ )
169 {
170 if ( p->pCubeDataOut[w] & (1<<v) )
171 fprintf( pFile, "1" );
172 else
173 fprintf( pFile, "0" );
174 if ( ++cOutputs == nOutput )
175 break;
176 }
177 fprintf( pFile, "\n" );
178 }
179}
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_CoverInfo

ABC_NAMESPACE_IMPL_START cinfo g_CoverInfo
extern

EXTERNAL VARIABLES ////.

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

FileName [exorUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Exclusive sum-of-product minimization.]

Synopsis [Utilities.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id
exorUtil.c,v 1.0 2005/06/20 00:00:00 alanmi Exp

]

                                                            ///
            Implementation of EXORCISM - 4                  ///
        An Exclusive Sum-of-Product Minimizer               ///
         Alan Mishchenko  <alanmi@ee.pdx.edu>               ///
                                                            ///

                                                            ///
                  Utility Functions                         ///
                                                            ///
 1) allocating memory for and creating the ESOP cover       ///
 2) writing the resultant cover into an ESOP PLA file       ///
                                                            ///

Ver. 1.0. Started - July 15, 2000. Last update - July 20, 2000 /// Ver. 1.4. Started - Aug 10, 2000. Last update - Aug 10, 2000 /// Ver. 1.5. Started - Aug 19, 2000. Last update - Aug 19, 2000 /// Ver. 1.7. Started - Sep 20, 2000. Last update - Sep 23, 2000 /// ///

This software was tested with the BDD package "CUDD", v.2.3.0 /// by Fabio Somenzi /// http://vlsi.colorado.edu/~fabio/ ///

EXTERNAL VARIABLES ////.

EXTERNAL VARIABLES ///.

EXTERNAL FUNCTIONS ///.

MACRO DEFINITIONS ///.

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

FileName [exor.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Exclusive sum-of-product minimization.]

Synopsis [Main procedure.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id
exor.c,v 1.0 2005/06/20 00:00:00 alanmi Exp

]

                                                            ///
            Implementation of EXORCISM - 4                  ///
        An Exclusive Sum-of-Product Minimizer               ///
         Alan Mishchenko  <alanmi@ee.pdx.edu>               ///
                                                            ///

                                                            ///
                   Main Module                              ///
          ESOP Minimization Task Coordinator                ///
                                                            ///
    1) interprets command line                              ///  
    2) calls the approapriate reading procedure             ///
    3) calls the minimization module                        ///
                                                            ///

Ver. 1.0. Started - July 18, 2000. Last update - July 20, 2000 /// Ver. 1.1. Started - July 24, 2000. Last update - July 29, 2000 /// Ver. 1.4. Started - Aug 10, 2000. Last update - Aug 26, 2000 /// Ver. 1.6. Started - Sep 11, 2000. Last update - Sep 15, 2000 /// Ver. 1.7. Started - Sep 20, 2000. Last update - Sep 23, 2000 /// ///

This software was tested with the BDD package "CUDD", v.2.3.0 /// by Fabio Somenzi /// http://vlsi.colorado.edu/~fabio/ ///

Definition at line 58 of file exor.c.