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

Go to the source code of this file.

Macros

#define FULL16BITS   0x10000
 
#define MARKNUMBER   200
 

Functions

int GetDistance (Cube *pC1, Cube *pC2)
 FUNCTIONS OF THIS MODULE ///.
 
int GetDistancePlus (Cube *pC1, Cube *pC2)
 
int FindDiffVars (int *pDiffVars, Cube *pC1, Cube *pC2)
 
void InsertVars (Cube *pC, int *pVars, int nVarsIn, int *pVarValues)
 
varvalue GetVar (Cube *pC, int Var)
 INLINE FUNCTION DEFINITIONS ///.
 
void ExorVar (Cube *pC, int Var, varvalue Val)
 
void PrepareBitSetModule ()
 FUNCTION DEFINITIONS ///.
 
void InsertVarsWithoutClearing (Cube *pC, int *pVars, int nVarsIn, int *pVarValues, int Output)
 

Variables

ABC_NAMESPACE_IMPL_START cinfo g_CoverInfo
 MACRO DEFINITIONS ///.
 
unsigned char BitCount [FULL16BITS]
 
int s_DiffVarNum
 
int s_DiffVarValueP_old
 
int s_DiffVarValueP_new
 
int s_DiffVarValueQ
 

Macro Definition Documentation

◆ FULL16BITS

#define FULL16BITS   0x10000

Definition at line 134 of file exorBits.c.

◆ MARKNUMBER

#define MARKNUMBER   200

Definition at line 135 of file exorBits.c.

Function Documentation

◆ ExorVar()

void ExorVar ( Cube * pC,
int Var,
varvalue Val )

Definition at line 197 of file exorBits.c.

200{
201 int Bit = (Var<<1);
202 pC->pCubeDataIn[VarWord(Bit)] ^= ( Val << VarBit(Bit) );
203}
int Var
Definition exorList.c:228
drow * pCubeDataIn
Definition exor.h:129
Here is the caller graph for this function:

◆ FindDiffVars()

int FindDiffVars ( int * pDiffVars,
Cube * pC1,
Cube * pC2 )

Definition at line 304 of file exorBits.c.

309{
310 int i, v;
311 DiffVarCounter = 0;
312 // check whether the output parts of the cubes are different
313
314 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
315 if ( pC1->pCubeDataOut[i] != pC2->pCubeDataOut[i] )
316 { // they are different
317 pDiffVars[0] = -1;
318 DiffVarCounter = 1;
319 break;
320 }
321
322 for ( i = 0; i < g_CoverInfo.nWordsIn; i++ )
323 {
324
325 Temp1 = pC1->pCubeDataIn[i] ^ pC2->pCubeDataIn[i];
326 Temp2 = (Temp1|(Temp1>>1)) & DIFFERENT;
327
328 // check the first part of this word
329 Temp = Temp2 & 0xffff;
330 cVars = BitCount[ Temp ];
331 if ( cVars )
332 {
333 if ( cVars < 5 )
334 for ( v = 0; v < cVars; v++ )
335 {
336 assert( BitGroupNumbers[Temp] != MARKNUMBER );
337 pDiffVars[ DiffVarCounter++ ] = i*16 + GroupLiterals[ BitGroupNumbers[Temp] ][v];
338 }
339 else
340 return 5;
341 }
342 if ( DiffVarCounter > 4 )
343 return 5;
344
345 // check the second part of this word
346 Temp = Temp2 >> 16;
347 cVars = BitCount[ Temp ];
348 if ( cVars )
349 {
350 if ( cVars < 5 )
351 for ( v = 0; v < cVars; v++ )
352 {
353 assert( BitGroupNumbers[Temp] != MARKNUMBER );
354 pDiffVars[ DiffVarCounter++ ] = i*16 + 8 + GroupLiterals[ BitGroupNumbers[Temp] ][v];
355 }
356 else
357 return 5;
358 }
359 if ( DiffVarCounter > 4 )
360 return 5;
361 }
362 return DiffVarCounter;
363}
#define MARKNUMBER
Definition exorBits.c:135
ABC_NAMESPACE_IMPL_START cinfo g_CoverInfo
GLOBAL VARIABLES ///.
Definition exor.c:58
unsigned char BitCount[]
Definition exorBits.c:138
@ DIFFERENT
Definition exor.h:74
drow * pCubeDataOut
Definition exor.h:130
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ GetDistance()

int GetDistance ( Cube * pC1,
Cube * pC2 )

FUNCTIONS OF THIS MODULE ///.

EXTERNAL FUNCTIONS ///.

Definition at line 214 of file exorBits.c.

216{
217 int i;
218 DiffVarCounter = 0;
219
220 for ( i = 0; i < g_CoverInfo.nWordsIn; i++ )
221 {
222 Temp1 = pC1->pCubeDataIn[i] ^ pC2->pCubeDataIn[i];
223 Temp2 = (Temp1|(Temp1>>1)) & DIFFERENT;
224
225 // count how many bits are one in this var difference
226 DiffVarCounter += BIT_COUNT(Temp2);
227 if ( DiffVarCounter > 4 )
228 return 5;
229 }
230 // check whether the output parts are different
231 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
232 if ( pC1->pCubeDataOut[i] ^ pC2->pCubeDataOut[i] )
233 {
234 DiffVarCounter++;
235 break;
236 }
237 return DiffVarCounter;
238}

◆ GetDistancePlus()

int GetDistancePlus ( Cube * pC1,
Cube * pC2 )

Definition at line 246 of file exorBits.c.

249{
250 int i;
251
252 DiffVarCounter = 0;
253 LastNonZeroWordNum = -1;
254 for ( i = 0; i < g_CoverInfo.nWordsIn; i++ )
255 {
256 Temp1 = pC1->pCubeDataIn[i] ^ pC2->pCubeDataIn[i];
257 Temp2 = (Temp1|(Temp1>>1)) & DIFFERENT;
258
259 // save the value of var difference, in case
260 // the distance is one and we need to return the var number
261 if ( Temp2 )
262 {
263 LastNonZeroWordNum = i;
264 LastNonZeroWord = Temp2;
265 }
266
267 // count how many bits are one in this var difference
268 DiffVarCounter += BIT_COUNT(Temp2);
269 if ( DiffVarCounter > 4 )
270 return 5;
271 }
272 // check whether the output parts are different
273 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
274 if ( pC1->pCubeDataOut[i] ^ pC2->pCubeDataOut[i] )
275 {
276 DiffVarCounter++;
277 break;
278 }
279
280 if ( DiffVarCounter == 1 )
281 {
282 if ( LastNonZeroWordNum == -1 ) // the output is the only different variable
283 s_DiffVarNum = -1;
284 else
285 {
286 Temp = (LastNonZeroWord>>2);
287 for ( i = 0; Temp; Temp>>=2, i++ );
288 s_DiffVarNum = LastNonZeroWordNum*BPI/2 + i;
289
290 // save the old var value
293
294 // EXOR this value with the corresponding value in p cube
296
298 }
299 }
300
301 return DiffVarCounter;
302}
int s_DiffVarValueP_new
Definition exorList.c:640
int s_DiffVarValueQ
Definition exorList.c:641
int s_DiffVarNum
Definition exorList.c:638
varvalue GetVar(Cube *pC, int Var)
INLINE FUNCTION DEFINITIONS ///.
Definition exorBits.c:188
void ExorVar(Cube *pC, int Var, varvalue Val)
Definition exorBits.c:197
int s_DiffVarValueP_old
Definition exorList.c:639
@ BPI
Definition exor.h:59
varvalue
VARVALUE and CUBEDIST enum typedefs ///.
Definition exor.h:178
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVar()

varvalue GetVar ( Cube * pC,
int Var )

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}
@ VAR_POS
Definition exor.h:178
@ VAR_NEG
Definition exor.h:178
@ VAR_ABS
Definition exor.h:178
Here is the caller graph for this function:

◆ InsertVars()

void InsertVars ( Cube * pC,
int * pVars,
int nVarsIn,
int * pVarValues )

Definition at line 365 of file exorBits.c.

369{
370 int GlobalBit;
371 int LocalWord;
372 int LocalBit;
373 int i;
374 assert( nVarsIn > 0 && nVarsIn <= g_CoverInfo.nVarsIn );
375 for ( i = 0; i < nVarsIn; i++ )
376 {
377 assert( pVars[i] >= 0 && pVars[i] < g_CoverInfo.nVarsIn );
378 assert( pVarValues[i] == VAR_NEG || pVarValues[i] == VAR_POS || pVarValues[i] == VAR_ABS );
379 GlobalBit = (pVars[i]<<1);
380 LocalWord = VarWord(GlobalBit);
381 LocalBit = VarBit(GlobalBit);
382
383 // correct this variables
384 pC->pCubeDataIn[LocalWord] = ((pC->pCubeDataIn[LocalWord]&(~(3<<LocalBit)))|(pVarValues[i]<<LocalBit));
385 }
386}

◆ InsertVarsWithoutClearing()

void InsertVarsWithoutClearing ( Cube * pC,
int * pVars,
int nVarsIn,
int * pVarValues,
int Output )

Definition at line 388 of file exorBits.c.

392{
393 int GlobalBit;
394 int LocalWord;
395 int LocalBit;
396 int i;
397 assert( nVarsIn > 0 && nVarsIn <= g_CoverInfo.nVarsIn );
398 for ( i = 0; i < nVarsIn; i++ )
399 {
400 assert( pVars[i] >= 0 && pVars[i] < g_CoverInfo.nVarsIn );
401 assert( pVarValues[i] == VAR_NEG || pVarValues[i] == VAR_POS || pVarValues[i] == VAR_ABS );
402 GlobalBit = (pVars[i]<<1);
403 LocalWord = VarWord(GlobalBit);
404 LocalBit = VarBit(GlobalBit);
405
406 // correct this variables
407 pC->pCubeDataIn[LocalWord] |= ( pVarValues[i] << LocalBit );
408 }
409 // insert the output bit
410 pC->pCubeDataOut[VarWord(Output)] |= ( 1 << VarBit(Output) );
411}
Here is the caller graph for this function:

◆ PrepareBitSetModule()

void PrepareBitSetModule ( )

FUNCTION DEFINITIONS ///.

Definition at line 144 of file exorBits.c.

146{
147 // prepare bit count
148 int i, k;
149 int nLimit;
150
151 nLimit = FULL16BITS;
152 for ( i = 0; i < nLimit; i++ )
153 {
154 BitCount[i] = __builtin_popcount( i & 0xffff );
155 BitGroupNumbers[i] = MARKNUMBER;
156 }
157 // prepare bit groups
158 for ( k = 0; k < 163; k++ )
159 BitGroupNumbers[ SparseNumbers[k] ] = k;
160/*
161 // verify bit groups
162 int n = 4368;
163 char Buff[100];
164 cout << "The number is " << n << endl;
165 cout << "The binary is " << itoa(n,Buff,2) << endl;
166 cout << "BitGroupNumbers[n] is " << (int)BitGroupNumbers[n] << endl;
167 cout << "The group literals are ";
168 for ( int g = 0; g < 4; g++ )
169 cout << " " << (int)GroupLiterals[BitGroupNumbers[n]][g];
170*/
171}
#define FULL16BITS
Definition exorBits.c:134
Here is the caller graph for this function:

Variable Documentation

◆ BitCount

unsigned char BitCount[FULL16BITS]

Definition at line 138 of file exorBits.c.

◆ g_CoverInfo

ABC_NAMESPACE_IMPL_START cinfo g_CoverInfo
extern

MACRO DEFINITIONS ///.

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

FileName [exorBits.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Exclusive sum-of-product minimization.]

Synopsis [Bit-level procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id
exorBits.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>               ///
                                                            ///

                                                            ///
        EXOR-Oriented Bit String Manipulation               ///
                                                            ///

Ver. 1.0. Started - July 18, 2000. Last update - July 20, 2000 /// Ver. 1.4. Started - Aug 10, 2000. Last update - Aug 10, 2000 /// ///

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

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.

◆ s_DiffVarNum

int s_DiffVarNum
extern

Definition at line 638 of file exorList.c.

◆ s_DiffVarValueP_new

int s_DiffVarValueP_new
extern

Definition at line 640 of file exorList.c.

◆ s_DiffVarValueP_old

int s_DiffVarValueP_old
extern

Definition at line 639 of file exorList.c.

◆ s_DiffVarValueQ

int s_DiffVarValueQ
extern

Definition at line 641 of file exorList.c.