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

Go to the source code of this file.

Classes

struct  que
 

Functions

int GetDistance (Cube *pC1, Cube *pC2)
 EXTERNAL FUNCTIONS ///.
 
int GetDistancePlus (Cube *pC1, Cube *pC2)
 
void ExorVar (Cube *pC, int Var, varvalue Val)
 
void AddToFreeCubes (Cube *pC)
 FREE CUBE LIST MANIPULATION FUNCTIONS ///.
 
CubeGetFreeCube ()
 
int ExorLinkCubeIteratorStart (Cube **pGroup, Cube *pC1, Cube *pC2, cubedist Dist)
 ExorLink Functions.
 
int ExorLinkCubeIteratorNext (Cube **pGroup)
 
int ExorLinkCubeIteratorPick (Cube **pGroup, int g)
 
void ExorLinkCubeIteratorCleanUp (int fTakeLastGroup)
 
int IterativelyApplyExorLink2 (char fDistEnable)
 FUNCTIONS OF THIS MODULE ///.
 
int IterativelyApplyExorLink3 (char fDistEnable)
 
int IterativelyApplyExorLink4 (char fDistEnable)
 
int CheckForCloseCubes (Cube *p, int fAddCube)
 
int CheckAndInsert (Cube *p)
 Iterative ExorLink Operation ///.
 
void UndoRecentChanges ()
 
int IteratorCubePairStart (cubedist Dist, Cube **ppC1, Cube **ppC2)
 
int IteratorCubePairNext ()
 
int AllocateCubeSets (int nVarsIn, int nVarsOut)
 CUBE SET MANIPULATION PROCEDURES ///.
 
void DelocateCubeSets ()
 
void CubeInsert (Cube *p)
 Insertion Operators ///.
 
CubeCubeExtract (Cube *p)
 
CubeIterCubeSetStart ()
 Cube Set Iterator ///.
 
CubeIterCubeSetNext ()
 
int AllocateQueques (int nPlaces)
 
void DelocateQueques ()
 
void PrintQuequeStats ()
 
int GetQuequeStats (cubedist Dist)
 
int GetPosDiff (int PosBeg, int PosEnd)
 

Variables

ABC_NAMESPACE_IMPL_START cinfo g_CoverInfo
 EXTERNAL VARIABLES ///.
 
unsigned char BitCount []
 
int s_nPosAlloc
 EXPORTED VARIABLES /// /////////////////////////////////////////////////////////////////////`.
 
int s_nPosMax [3]
 
int s_fDecreaseLiterals = 0
 
Cubes_q
 
int s_Distance
 
int s_DiffVarNum
 
int s_DiffVarValueP_old
 
int s_DiffVarValueP_new
 
int s_DiffVarValueQ
 
Cubes_pCubeLast
 CUBE ITERATOR ///.
 

Function Documentation

◆ AddToFreeCubes()

void AddToFreeCubes ( Cube * pC)
extern

FREE CUBE LIST MANIPULATION FUNCTIONS ///.

Definition at line 157 of file exorCubes.c.

158{
159 assert( p );
160 assert( p->Prev == NULL ); // the cube should not be in use
161 assert( p->Next == NULL );
162 assert( p->ID );
163
164 p->Next = s_CubesFree;
165 s_CubesFree = p;
166
167 // set the ID of the cube to 0,
168 // so that cube pair garbage collection could recognize it as different
169 p->ID = 0;
170
171 g_CoverInfo.nCubesFree++;
172}
Cube * s_CubesFree
Definition exorCubes.c:84
Cube * p
Definition exorList.c:222
ABC_NAMESPACE_IMPL_START cinfo g_CoverInfo
GLOBAL VARIABLES ///.
Definition exor.c:58
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ AllocateCubeSets()

int AllocateCubeSets ( int nVarsIn,
int nVarsOut )

CUBE SET MANIPULATION PROCEDURES ///.

Memory Allocation/Delocation ///

Definition at line 792 of file exorList.c.

793{
794 s_List = NULL;
795
796 // clean other data
797 s_fDistEnable2 = 1;
798 s_fDistEnable3 = 0;
799 s_fDistEnable4 = 0;
800 memset( s_CubeGroup, 0, sizeof(void *) * 5 );
801 memset( s_fInserted, 0, sizeof(int) * 5 );
803 s_cEnquequed = 0;
804 s_cAttempts = 0;
805 s_cReshapes = 0;
806 s_nCubesBefore = 0;
807 s_Gain = 0;
808 s_GainTotal = 0;
809 s_GroupCounter = 0;
810 s_GroupBest = 0;
811 s_pC1 = s_pC2 = NULL;
812
813 return 4;
814}
int s_fDecreaseLiterals
Definition exorList.c:247
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AllocateQueques()

int AllocateQueques ( int nPlaces)

Definition at line 1112 of file exorList.c.

1115{
1116 int i;
1117 s_nPosAlloc = nPlaces;
1118
1119 for ( i = 0; i < 3; i++ )
1120 {
1121 // clean data
1122 memset( &s_Que[i], 0, sizeof(que) );
1123
1124 s_Que[i].pC1 = (Cube**) ABC_ALLOC( Cube*, nPlaces );
1125 s_Que[i].pC2 = (Cube**) ABC_ALLOC( Cube*, nPlaces );
1126 s_Que[i].ID1 = (byte*) ABC_ALLOC( byte, nPlaces );
1127 s_Que[i].ID2 = (byte*) ABC_ALLOC( byte, nPlaces );
1128
1129 if ( s_Que[i].pC1==NULL || s_Que[i].pC2==NULL || s_Que[i].ID1==NULL || s_Que[i].ID2==NULL )
1130 return 0;
1131
1132 s_nPosMax[i] = 0;
1133 s_Que[i].fEmpty = 1;
1134 }
1135
1136 return nPlaces * (sizeof(Cube*) + sizeof(Cube*) + 2*sizeof(byte) );
1137}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
int s_nPosAlloc
EXPORTED VARIABLES /// /////////////////////////////////////////////////////////////////////`.
Definition exorList.c:179
int s_nPosMax[3]
Definition exorList.c:181
struct cube Cube
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckAndInsert()

int CheckAndInsert ( Cube * p)

Iterative ExorLink Operation ///.

Definition at line 270 of file exorList.c.

271{
272// return CheckForCloseCubes( p, 1 );
273 CubeInsert( p );
274 return 0;
275}
void CubeInsert(Cube *p)
Insertion Operators ///.
Definition exorList.c:824
Here is the call graph for this function:

◆ CheckForCloseCubes()

int CheckForCloseCubes ( Cube * p,
int fAddCube )

Definition at line 643 of file exorList.c.

650{
651 // start the new range
652 NewRangeReset();
653
654 for ( s_q = s_List; s_q; s_q = s_q->Next )
655 {
657 if ( s_Distance > 4 )
658 {
659 }
660 else if ( s_Distance == 4 )
661 {
662 if ( s_fDistEnable4 )
663 NewRangeInsertCubePair( DIST4, p, s_q );
664 }
665 else if ( s_Distance == 3 )
666 {
667 if ( s_fDistEnable3 )
668 NewRangeInsertCubePair( DIST3, p, s_q );
669 }
670 else if ( s_Distance == 2 )
671 {
672 if ( s_fDistEnable2 )
673 NewRangeInsertCubePair( DIST2, p, s_q );
674 }
675 else if ( s_Distance == 1 )
676 { // extract the cube from the data structure
677
679 // store the changes
680 s_ChangeStore.fInput = (s_DiffVarNum != -1);
681 s_ChangeStore.p = p;
682 s_ChangeStore.PrevQa = s_q->a;
683 s_ChangeStore.PrevPa = p->a;
684 s_ChangeStore.PrevQq = s_q->q;
685 s_ChangeStore.PrevPq = p->q;
686 s_ChangeStore.PrevPz = p->z;
687 s_ChangeStore.Var = s_DiffVarNum;
688 s_ChangeStore.Value = s_DiffVarValueQ;
689 s_ChangeStore.PrevID = s_q->ID;
691
692 CubeExtract( s_q );
693 // perform the EXOR of the two cubes and write the result into p
694
695 // it is important that the resultant cube is written into p!!!
696
697 if ( s_DiffVarNum == -1 )
698 {
699 int i;
700 // exor the output part
701 p->z = 0;
702 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
703 {
704 p->pCubeDataOut[i] ^= s_q->pCubeDataOut[i];
705 p->z += BIT_COUNT(p->pCubeDataOut[i]);
706 }
707 }
708 else
709 {
710 // the cube has already been updated by GetDistancePlus()
711
712 // modify the parameters of the number of literals in the new cube
713// p->a += s_UpdateLiterals[ s_DiffVarValueP ][ s_DiffVarValueQ ];
715 p->a--;
717 p->a++;
718 p->q = ComputeQCostBits(p);
719 }
720
721 // move q to the free cube list
723
724 // make sure that nobody with use the pairs created so far
725// NewRangeReset();
726 // call the function again for the new cube
727 return 1 + CheckForCloseCubes( p, 1 );
728 }
729 else // if ( Distance == 0 )
730 { // extract the second cube from the data structure and add them both to the free list
731 AddToFreeCubes( p );
733
734 // make sure that nobody with use the pairs created so far
735 NewRangeReset();
736 return 2;
737 }
738 }
739
740 // add the cube to the data structure if needed
741 if ( fAddCube )
742 CubeInsert( p );
743
744 // add temporarily stored new range of cube pairs to the queque
745 NewRangeAdd();
746
747 return 0;
748}
int s_DiffVarValueP_new
Definition exorList.c:640
int s_DiffVarValueQ
Definition exorList.c:641
int s_DiffVarNum
Definition exorList.c:638
int s_DiffVarValueP_old
Definition exorList.c:639
int s_Distance
Definition exorList.c:637
Cube * s_q
Definition exorList.c:636
int CheckForCloseCubes(Cube *p, int fAddCube)
Definition exorList.c:643
Cube * CubeExtract(Cube *p)
Definition exorList.c:843
void AddToFreeCubes(Cube *pC)
FREE CUBE LIST MANIPULATION FUNCTIONS ///.
Definition exorCubes.c:157
int GetDistancePlus(Cube *pC1, Cube *pC2)
Definition exorBits.c:246
int ComputeQCostBits(Cube *p)
Definition exor.c:139
@ DIST4
Definition exor.h:181
@ DIST2
Definition exor.h:181
@ DIST3
Definition exor.h:181
@ VAR_POS
Definition exor.h:178
@ VAR_NEG
Definition exor.h:178
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CubeExtract()

Cube * CubeExtract ( Cube * p)

Definition at line 843 of file exorList.c.

845{
846// assert( p->Prev && p->Next ); // can be done only with rings
847 assert( p->ID );
848
849// if ( s_List == p )
850// s_List = p->Next;
851// if ( p->Prev )
852// p->Prev->Next = p->Next;
853
854 if ( s_List == p )
855 s_List = p->Next;
856 else
857 p->Prev->Next = p->Next;
858
859 if ( p->Next )
860 p->Next->Prev = p->Prev;
861
862 p->Prev = NULL;
863 p->Next = NULL;
864
865 g_CoverInfo.nCubesInUse--;
866 return p;
867}
Here is the caller graph for this function:

◆ CubeInsert()

void CubeInsert ( Cube * p)

Insertion Operators ///.

Definition at line 824 of file exorList.c.

826{
827 assert( p->Prev == NULL && p->Next == NULL );
828 assert( p->ID );
829
830 if ( s_List == NULL )
831 s_List = p;
832 else
833 {
834 p->Next = s_List;
835
836 s_List->Prev = p;
837 s_List = p;
838 }
839
840 g_CoverInfo.nCubesInUse++;
841}
Here is the caller graph for this function:

◆ DelocateCubeSets()

void DelocateCubeSets ( )

Definition at line 816 of file exorList.c.

817{
818}
Here is the caller graph for this function:

◆ DelocateQueques()

void DelocateQueques ( )

Definition at line 1139 of file exorList.c.

1140{
1141 int i;
1142 for ( i = 0; i < 3; i++ )
1143 {
1144 ABC_FREE( s_Que[i].pC1 );
1145 ABC_FREE( s_Que[i].pC2 );
1146 ABC_FREE( s_Que[i].ID1 );
1147 ABC_FREE( s_Que[i].ID2 );
1148 }
1149}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ ExorLinkCubeIteratorCleanUp()

void ExorLinkCubeIteratorCleanUp ( int fTakeLastGroup)
extern

Definition at line 710 of file exorLink.c.

714{
715 int c;
716 assert( fWorking );
717
718 // put cubes back
719 // set the cube pointers to zero
720 if ( fTakeLastGroup == 0 )
721 for ( c = 0; c < nCubesInGroup; c++ )
722 {
723 ELCubes[c]->fMark = 0;
724 AddToFreeCubes( ELCubes[c] );
725 ELCubes[c] = NULL;
726 }
727 else
728 for ( c = 0; c < nCubesInGroup; c++ )
729 if ( ELCubes[c] )
730 {
731 ELCubes[c]->fMark = 0;
732 if ( (LastGroup & s_BitMasks[c]) == 0 ) // does not belong to the last group
733 AddToFreeCubes( ELCubes[c] );
734 ELCubes[c] = NULL;
735 }
736
737 // set the cube groups to zero
738 VisitedGroups = 0;
739 // shut down the iterator
740 fWorking = 0;
741}
void AddToFreeCubes(Cube *pC)
FREE CUBE LIST MANIPULATION FUNCTIONS ///.
Definition exorCubes.c:157
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExorLinkCubeIteratorNext()

int ExorLinkCubeIteratorNext ( Cube ** pGroup)
extern

Definition at line 560 of file exorLink.c.

563{
564 int i, c;
565
566 // check that everything is okey
567 assert( fWorking );
568
569 if ( nVisitedGroups == nGroups )
570 // we have iterated through all groups
571 return 0;
572
573 // find the min/max cost group
574 if ( fMinLitGroupsFirst[nDist] )
575// if ( nCubes == 4 )
576 { // find the minimum cost
577 // go through all groups
578 GroupCostBest = LARGE_NUM;
579 for ( i = 0; i < nGroups; i++ )
580 if ( !(VisitedGroups & s_BitMasks[i]) && GroupCostBest > GroupCosts[i] )
581 {
582 GroupCostBest = GroupCosts[i];
583 GroupCostBestNum = i;
584 }
585 assert( GroupCostBest != LARGE_NUM );
586 }
587 else
588 { // find the maximum cost
589 // go through all groups
590 GroupCostBest = -1;
591 for ( i = 0; i < nGroups; i++ )
592 if ( !(VisitedGroups & s_BitMasks[i]) && GroupCostBest < GroupCosts[i] )
593 {
594 GroupCostBest = GroupCosts[i];
595 GroupCostBestNum = i;
596 }
597 assert( GroupCostBest != -1 );
598 }
599
600 // create the cubes needed for the group, if they are not created already
601 LastGroup = 0;
602 for ( c = 0; c < nCubes; c++ )
603 {
604 CubeNum = s_ELGroupRules[nDist][GroupCostBestNum][c];
605 LastGroup |= s_BitMasks[CubeNum];
606
607 if ( ELCubes[CubeNum] == NULL ) // this cube does not exist
608 {
609 // bring a cube from the free cube list
610 ELCubes[CubeNum] = GetFreeCube();
611
612 // copy the input bit data into the cube
613 for ( i = 0; i < g_CoverInfo.nWordsIn; i++ )
614 ELCubes[CubeNum]->pCubeDataIn[i] = DammyBitData[i];
615
616 // copy the output bit data into the cube
617 NewZ = 0;
618 if ( DiffVars[0] >= 0 ) // the output is not involved in ExorLink
619 {
620 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
621 ELCubes[CubeNum]->pCubeDataOut[i] = pCA->pCubeDataOut[i];
622 NewZ = pCA->z;
623 }
624 else // the output is involved
625 { // determine where the output information comes from
626 Value = s_ELCubeRules[nDist][CubeNum][nDiffVarsIn];
627 if ( Value == vs0 )
628 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
629 {
630 Temp = pCA->pCubeDataOut[i];
631 ELCubes[CubeNum]->pCubeDataOut[i] = Temp;
632 NewZ += BIT_COUNT(Temp);
633 }
634 else if ( Value == vs1 )
635 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
636 {
637 Temp = pCB->pCubeDataOut[i];
638 ELCubes[CubeNum]->pCubeDataOut[i] = Temp;
639 NewZ += BIT_COUNT(Temp);
640 }
641 else if ( Value == vsX )
642 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
643 {
644 Temp = pCA->pCubeDataOut[i] ^ pCB->pCubeDataOut[i];
645 ELCubes[CubeNum]->pCubeDataOut[i] = Temp;
646 NewZ += BIT_COUNT(Temp);
647 }
648 }
649
650 // set the variables that should be there
651 for ( i = 0; i < nDiffVarsIn; i++ )
652 {
653 Value = DiffVarValues[i][ s_ELCubeRules[nDist][CubeNum][i] ];
654 ELCubes[CubeNum]->pCubeDataIn[ DiffVarWords[i] ] |= ( Value << DiffVarBits[i] );
655 }
656
657 // set the number of literals and output ones
658 ELCubes[CubeNum]->a = StartingLiterals + CubeLiterals[CubeNum];
659 ELCubes[CubeNum]->z = NewZ;
660 ELCubes[CubeNum]->q = ComputeQCostBits( ELCubes[CubeNum] );
661 assert( NewZ != 255 );
662
663 // assign the ID
664 ELCubes[CubeNum]->ID = g_CoverInfo.cIDs++;
665 // skip through zero-ID
666 if ( g_CoverInfo.cIDs == 256 )
667 g_CoverInfo.cIDs = 1;
668
669 }
670 // prepare the return array
671 pGroup[c] = ELCubes[CubeNum];
672 }
673
674 // mark this group as visited
675 VisitedGroups |= s_BitMasks[ GroupCostBestNum ];
676 // set the next visited group number and
677 // increment the counter of visited groups
678 GroupOrder[ nVisitedGroups++ ] = GroupCostBestNum;
679 return 1;
680}
Cube * GetFreeCube()
Definition exorCubes.c:174
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExorLinkCubeIteratorPick()

int ExorLinkCubeIteratorPick ( Cube ** pGroup,
int g )
extern

Definition at line 682 of file exorLink.c.

686{
687 int GroupNum, c;
688
689 assert( fWorking );
690 assert( g >= 0 && g < nGroups );
691 assert( VisitedGroups & s_BitMasks[g] );
692
693 GroupNum = GroupOrder[g];
694 // form the group
695 LastGroup = 0;
696 for ( c = 0; c < nCubes; c++ )
697 {
698 CubeNum = s_ELGroupRules[nDist][GroupNum][c];
699
700 // remember this group as the last one
701 LastGroup |= s_BitMasks[CubeNum];
702
703 assert( ELCubes[CubeNum] != NULL ); // this cube should exist
704 // prepare the return array
705 pGroup[c] = ELCubes[CubeNum];
706 }
707 return 1;
708}

◆ ExorLinkCubeIteratorStart()

int ExorLinkCubeIteratorStart ( Cube ** pGroup,
Cube * pC1,
Cube * pC2,
cubedist Dist )
extern

ExorLink Functions.

ExorLink Functions.

FUNCTION DEFINTIONS ///.

FUNCTIONS OF THIS MODULE ///

Definition at line 376 of file exorLink.c.

380{
381 int i, c;
382
383 // check that everything is okey
384 assert( pC1 != NULL );
385 assert( pC2 != NULL );
386 assert( !fWorking );
387
388 nDist = Dist;
389 nCubes = Dist + 2;
390 nCubesInGroup = s_ELnCubes[nDist];
391 nGroups = s_ELnGroups[Dist];
392 pCA = pC1;
393 pCB = pC2;
394 // find what variables are different in these two cubes
395 // FindDiffVars returns DiffVars[0] < 0, if the output is different
396 nDifferentVars = FindDiffVars( DiffVars, pCA, pCB );
397 if ( nCubes != nDifferentVars )
398 {
399// cout << "ExorLinkCubeIterator(): Distance mismatch";
400// cout << " nCubes = " << nCubes << " nDiffVars = " << nDifferentVars << endl;
401 fWorking = 0;
402 return 0;
403 }
404
405 // copy the input variable cube data into DammyBitData[]
406 for ( i = 0; i < g_CoverInfo.nWordsIn; i++ )
407 DammyBitData[i] = pCA->pCubeDataIn[i];
408
409 // find the number of different input variables
410 nDiffVarsIn = ( DiffVars[0] >= 0 )? nCubes: nCubes-1;
411 // assign the pointer to the place where the number of diff input vars is stored
412 pDiffVars = ( DiffVars[0] >= 0 )? DiffVars: DiffVars+1;
413 // find the bit offsets and remove different variables
414 for ( i = 0; i < nDiffVarsIn; i++ )
415 {
416 DiffVarWords[i] = ((2*pDiffVars[i]) >> LOGBPI) ;
417 DiffVarBits[i] = ((2*pDiffVars[i]) & BPIMASK);
418 // clear this position
419 DammyBitData[ DiffVarWords[i] ] &= ~( 3 << DiffVarBits[i] );
420 }
421
422 // extract the values from the cubes and create the mask of literals
423 MaskLiterals = 0;
424 // initialize the base for literal counts
425 StartingLiterals = pCA->a;
426 for ( i = 0, BitShift = 0; i < nDiffVarsIn; i++, BitShift++ )
427 {
428 DiffVarValues[i][0] = ( pCA->pCubeDataIn[DiffVarWords[i]] >> DiffVarBits[i] ) & 3;
429 if ( DiffVarValues[i][0] != VAR_ABS )
430 {
431 MaskLiterals |= ( 1 << BitShift );
432 // update the base for literal counts
433 StartingLiterals--;
434 }
435 BitShift++;
436
437 DiffVarValues[i][1] = ( pCB->pCubeDataIn[DiffVarWords[i]] >> DiffVarBits[i] ) & 3;
438 if ( DiffVarValues[i][1] != VAR_ABS )
439 MaskLiterals |= ( 1 << BitShift );
440 BitShift++;
441
442 DiffVarValues[i][2] = DiffVarValues[i][0] ^ DiffVarValues[i][1];
443 if ( DiffVarValues[i][2] != VAR_ABS )
444 MaskLiterals |= ( 1 << BitShift );
445 BitShift++;
446 }
447
448 // count the number of additional literals in each cube of the group
449 for ( i = 0; i < nCubesInGroup; i++ )
450 CubeLiterals[i] = BitCount[ MaskLiterals & s_CubeLitMasks[Dist][i] ];
451
452 // compute the costs of all groups
453 for ( i = 0; i < nGroups; i++ )
454 // go over all cubes in the group
455 for ( GroupCosts[i] = 0, c = 0; c < nCubes; c++ )
456 GroupCosts[i] += CubeLiterals[ s_ELGroupRules[Dist][i][c] ];
457
458 // find the best cost group
459 if ( fMinLitGroupsFirst[Dist] )
460 { // find the minimum cost group
461 GroupCostBest = LARGE_NUM;
462 for ( i = 0; i < nGroups; i++ )
463 if ( GroupCostBest > GroupCosts[i] )
464 {
465 GroupCostBest = GroupCosts[i];
466 GroupCostBestNum = i;
467 }
468 }
469 else
470 { // find the maximum cost group
471 GroupCostBest = -1;
472 for ( i = 0; i < nGroups; i++ )
473 if ( GroupCostBest < GroupCosts[i] )
474 {
475 GroupCostBest = GroupCosts[i];
476 GroupCostBestNum = i;
477 }
478 }
479
480 // create the cubes with min number of literals needed for the group
481 LastGroup = 0;
482 for ( c = 0; c < nCubes; c++ )
483 {
484 CubeNum = s_ELGroupRules[Dist][GroupCostBestNum][c];
485 LastGroup |= s_BitMasks[CubeNum];
486
487 // bring a cube from the free cube list
488 ELCubes[CubeNum] = GetFreeCube();
489
490 // copy the input bit data into the cube
491 for ( i = 0; i < g_CoverInfo.nWordsIn; i++ )
492 ELCubes[CubeNum]->pCubeDataIn[i] = DammyBitData[i];
493
494 // copy the output bit data into the cube
495 NewZ = 0;
496 if ( DiffVars[0] >= 0 ) // the output is not involved in ExorLink
497 {
498 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
499 ELCubes[CubeNum]->pCubeDataOut[i] = pCA->pCubeDataOut[i];
500 NewZ = pCA->z;
501 }
502 else // the output is involved
503 { // determine where the output information comes from
504 Value = s_ELCubeRules[Dist][CubeNum][nDiffVarsIn];
505 if ( Value == vs0 )
506 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
507 {
508 Temp = pCA->pCubeDataOut[i];
509 ELCubes[CubeNum]->pCubeDataOut[i] = Temp;
510 NewZ += BIT_COUNT(Temp);
511 }
512 else if ( Value == vs1 )
513 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
514 {
515 Temp = pCB->pCubeDataOut[i];
516 ELCubes[CubeNum]->pCubeDataOut[i] = Temp;
517 NewZ += BIT_COUNT(Temp);
518 }
519 else if ( Value == vsX )
520 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
521 {
522 Temp = pCA->pCubeDataOut[i] ^ pCB->pCubeDataOut[i];
523 ELCubes[CubeNum]->pCubeDataOut[i] = Temp;
524 NewZ += BIT_COUNT(Temp);
525 }
526 }
527
528 // set the variables that should be there
529 for ( i = 0; i < nDiffVarsIn; i++ )
530 {
531 Value = DiffVarValues[i][ s_ELCubeRules[Dist][CubeNum][i] ];
532 ELCubes[CubeNum]->pCubeDataIn[ DiffVarWords[i] ] |= ( Value << DiffVarBits[i] );
533 }
534
535 // set the number of literals
536 ELCubes[CubeNum]->a = StartingLiterals + CubeLiterals[CubeNum];
537 ELCubes[CubeNum]->z = NewZ;
538 ELCubes[CubeNum]->q = ComputeQCostBits( ELCubes[CubeNum] );
539
540 // assign the ID
541 ELCubes[CubeNum]->ID = g_CoverInfo.cIDs++;
542 // skip through zero-ID
543 if ( g_CoverInfo.cIDs == 256 )
544 g_CoverInfo.cIDs = 1;
545
546 // prepare the return array
547 pGroup[c] = ELCubes[CubeNum];
548 }
549
550 // mark this group as visited
551 VisitedGroups |= s_BitMasks[ GroupCostBestNum ];
552 // set the first visited group number
553 GroupOrder[0] = GroupCostBestNum;
554 // increment the counter of visited groups
555 nVisitedGroups = 1;
556 fWorking = 1;
557 return 1;
558}
#define LOGBPI
Definition espresso.h:69
cubedist Dist
Definition exorList.c:1012
int FindDiffVars(int *pDiffVars, Cube *pC1, Cube *pC2)
Definition exorBits.c:304
unsigned char BitCount[]
Definition exorBits.c:138
@ BPIMASK
Definition exor.h:60
@ VAR_ABS
Definition exor.h:178
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExorVar()

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

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:

◆ GetDistance()

int GetDistance ( Cube * pC1,
Cube * pC2 )
extern

EXTERNAL FUNCTIONS ///.

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}
@ DIFFERENT
Definition exor.h:74
drow * pCubeDataOut
Definition exor.h:130

◆ GetDistancePlus()

int GetDistancePlus ( Cube * pC1,
Cube * pC2 )
extern

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}
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
@ 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:

◆ GetFreeCube()

Cube * GetFreeCube ( )
extern

Definition at line 174 of file exorCubes.c.

175{
176 Cube * p;
178 p = s_CubesFree;
179 s_CubesFree = s_CubesFree->Next;
180 p->Next = NULL;
181 g_CoverInfo.nCubesFree--;
182 return p;
183}
Here is the caller graph for this function:

◆ GetPosDiff()

int GetPosDiff ( int PosBeg,
int PosEnd )

Definition at line 928 of file exorList.c.

929{
930 return (PosEnd - PosBeg + s_nPosAlloc) % s_nPosAlloc;
931}
Here is the caller graph for this function:

◆ GetQuequeStats()

int GetQuequeStats ( cubedist Dist)

Definition at line 998 of file exorList.c.

999{
1000 return GetPosDiff( s_Que[Dist].PosOut, s_Que[Dist].PosIn );
1001}
int GetPosDiff(int PosBeg, int PosEnd)
Definition exorList.c:928
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IterativelyApplyExorLink2()

int IterativelyApplyExorLink2 ( char fDistEnable)

FUNCTIONS OF THIS MODULE ///.

Definition at line 277 of file exorList.c.

281{
282 int z;
283
284 // this var is specific to ExorLink-2
285 s_Dist = (cubedist)0;
286
287 // enable pair accumulation
288 s_fDistEnable2 = fDistEnable & 1;
289 s_fDistEnable3 = fDistEnable & 2;
290 s_fDistEnable4 = fDistEnable & 4;
291
292 // initialize counters
293 s_cEnquequed = GetQuequeStats( s_Dist );
294 s_cAttempts = 0;
295 s_cReshapes = 0;
296
297 // remember the number of cubes before minimization
298 s_nCubesBefore = g_CoverInfo.nCubesInUse;
299
300 for ( z = IteratorCubePairStart( s_Dist, &s_pC1, &s_pC2 ); z; z = IteratorCubePairNext() )
301 {
302 s_cAttempts++;
303 // start ExorLink of the given Distance
304 if ( ExorLinkCubeIteratorStart( s_CubeGroup, s_pC1, s_pC2, s_Dist ) )
305 {
306 // extract old cubes from storage (to prevent EXORing with their derivitives)
307 CubeExtract( s_pC1 );
308 CubeExtract( s_pC2 );
309
310 // mark the current position in the cube pair queques
311 MarkSet();
312
313 // check the first group (generated by ExorLinkCubeIteratorStart())
314 if ( CheckForCloseCubes( s_CubeGroup[0], 0 ) )
315 { // the first cube leads to improvement - it is already inserted
316 CheckForCloseCubes( s_CubeGroup[1], 1 ); // insert the second cube
317 goto SUCCESS;
318 }
319 if ( CheckForCloseCubes( s_CubeGroup[1], 0 ) )
320 { // the second cube leads to improvement - it is already inserted
321 CheckForCloseCubes( s_CubeGroup[0], 1 ); // insert the first cube
322// CheckAndInsert( s_CubeGroup[0] );
323 goto SUCCESS;
324 }
325 // the first group does not lead to improvement
326
327 // rewind to the previously marked position in the cube pair queques
328 MarkRewind();
329
330 // generate the second group
331 ExorLinkCubeIteratorNext( s_CubeGroup );
332
333 // check the second group
334 if ( CheckForCloseCubes( s_CubeGroup[0], 0 ) )
335 { // the first cube leads to improvement - it is already inserted
336 CheckForCloseCubes( s_CubeGroup[1], 1 ); // insert the second cube
337 goto SUCCESS;
338 }
339 if ( CheckForCloseCubes( s_CubeGroup[1], 0 ) )
340 { // the second cube leads to improvement - it is already inserted
341 CheckForCloseCubes( s_CubeGroup[0], 1 ); // insert the first cube
342// CheckAndInsert( s_CubeGroup[0] );
343 goto SUCCESS;
344 }
345 // the second group does not lead to improvement
346
347 // decide whether to accept the second group, depending on literals
349 {
350 if ( g_CoverInfo.fUseQCost ?
351 s_CubeGroup[0]->q + s_CubeGroup[1]->q >= s_pC1->q + s_pC2->q :
352 s_CubeGroup[0]->a + s_CubeGroup[1]->a >= s_pC1->a + s_pC2->a )
353 // the group increases literals
354 { // do not take the last group
355
356 // rewind to the previously marked position in the cube pair queques
357 MarkRewind();
358
359 // return the old cubes back to storage
360 CubeInsert( s_pC1 );
361 CubeInsert( s_pC2 );
362 // clean the results of generating ExorLinked cubes
364 continue;
365 }
366 }
367
368 // take the last group
369 // there is no need to test these cubes again,
370 // because they have been tested and did not yield any improvement
371 CubeInsert( s_CubeGroup[0] );
372 CubeInsert( s_CubeGroup[1] );
373// CheckForCloseCubes( s_CubeGroup[0], 1 );
374// CheckForCloseCubes( s_CubeGroup[1], 1 );
375
376SUCCESS:
377 // clean the results of generating ExorLinked cubes
378 ExorLinkCubeIteratorCleanUp( 1 ); // take the last group
379 // free old cubes
380 AddToFreeCubes( s_pC1 );
381 AddToFreeCubes( s_pC2 );
382 // increate the counter
383 s_cReshapes++;
384 }
385 }
386 // print the report
387 if ( g_CoverInfo.Verbosity == 2 )
388 {
389 printf( "ExLink-%d", 2 );
390 printf( ": Que= %5d", s_cEnquequed );
391 printf( " Att= %4d", s_cAttempts );
392 printf( " Resh= %4d", s_cReshapes );
393 printf( " NoResh= %4d", s_cAttempts - s_cReshapes );
394 printf( " Cubes= %3d", g_CoverInfo.nCubesInUse );
395 printf( " (%d)", s_nCubesBefore - g_CoverInfo.nCubesInUse );
396 printf( " Lits= %5d", CountLiterals() );
397 printf( " QCost = %6d", CountQCost() );
398 printf( "\n" );
399 }
400
401 // return the number of cubes gained in the process
402 return s_nCubesBefore - g_CoverInfo.nCubesInUse;
403}
int IteratorCubePairNext()
Definition exorList.c:1073
int IteratorCubePairStart(cubedist Dist, Cube **ppC1, Cube **ppC2)
Definition exorList.c:1023
int GetQuequeStats(cubedist Dist)
Definition exorList.c:998
int ExorLinkCubeIteratorNext(Cube **pGroup)
Definition exorLink.c:560
int ExorLinkCubeIteratorStart(Cube **pGroup, Cube *pC1, Cube *pC2, cubedist Dist)
ExorLink Functions.
Definition exorLink.c:376
void ExorLinkCubeIteratorCleanUp(int fTakeLastGroup)
Definition exorLink.c:710
int CountLiterals()
FUNCTION DECLARATIONS ///.
Definition exorUtil.c:77
int CountQCost()
Definition exorUtil.c:119
cubedist
Definition exor.h:181
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IterativelyApplyExorLink3()

int IterativelyApplyExorLink3 ( char fDistEnable)

Definition at line 405 of file exorList.c.

406{
407 int z, c, d;
408 // this var is specific to ExorLink-3
409 s_Dist = (cubedist)1;
410
411 // enable pair accumulation
412 s_fDistEnable2 = fDistEnable & 1;
413 s_fDistEnable3 = fDistEnable & 2;
414 s_fDistEnable4 = fDistEnable & 4;
415
416 // initialize counters
417 s_cEnquequed = GetQuequeStats( s_Dist );
418 s_cAttempts = 0;
419 s_cReshapes = 0;
420
421 // remember the number of cubes before minimization
422 s_nCubesBefore = g_CoverInfo.nCubesInUse;
423
424 for ( z = IteratorCubePairStart( s_Dist, &s_pC1, &s_pC2 ); z; z = IteratorCubePairNext() )
425 {
426 s_cAttempts++;
427 // start ExorLink of the given Distance
428 if ( ExorLinkCubeIteratorStart( s_CubeGroup, s_pC1, s_pC2, s_Dist ) )
429 {
430 // extract old cubes from storage (to prevent EXORing with their derivitives)
431 CubeExtract( s_pC1 );
432 CubeExtract( s_pC2 );
433
434 // mark the current position in the cube pair queques
435 MarkSet();
436
437 // check cube groups one by one
438 s_GroupCounter = 0;
439 do
440 { // check the cubes of this group one by one
441 for ( c = 0; c < 3; c++ )
442 if ( !s_CubeGroup[c]->fMark ) // this cube has not yet been checked
443 {
444 s_Gain = CheckForCloseCubes( s_CubeGroup[c], 0 ); // do not insert the cube, by default
445 if ( s_Gain )
446 { // this cube leads to improvement or reshaping - it is already inserted
447
448 // decide whether to accept this group based on literal count
449 if ( s_fDecreaseLiterals && s_Gain == 1 )
450 if ( g_CoverInfo.fUseQCost ?
451 s_CubeGroup[0]->q + s_CubeGroup[1]->q + s_CubeGroup[2]->q > s_pC1->q + s_pC2->q + s_ChangeStore.PrevQq :
452 s_CubeGroup[0]->a + s_CubeGroup[1]->a + s_CubeGroup[2]->a > s_pC1->a + s_pC2->a + s_ChangeStore.PrevQa
453 ) // the group increases literals
454 { // do not take this group
455 // remember the group
456 s_GroupBest = s_GroupCounter;
457 // undo changes to be able to continue checking other groups
459 break;
460 }
461
462 // take this group
463 for ( d = 0; d < 3; d++ ) // insert other cubes
464 if ( d != c )
465 {
466 CheckForCloseCubes( s_CubeGroup[d], 1 );
467// if ( s_CubeGroup[d]->fMark )
468// CheckAndInsert( s_CubeGroup[d] );
469// CheckOnlyOneCube( s_CubeGroup[d] );
470// CheckForCloseCubes( s_CubeGroup[d], 1 );
471// else
472// CheckForCloseCubes( s_CubeGroup[d], 1 );
473 }
474
475 // clean the results of generating ExorLinked cubes
476 ExorLinkCubeIteratorCleanUp( 1 ); // take the last group
477 // free old cubes
478 AddToFreeCubes( s_pC1 );
479 AddToFreeCubes( s_pC2 );
480 // update the counter
481 s_cReshapes++;
482 goto END_OF_LOOP;
483 }
484 else // mark the cube as checked
485 s_CubeGroup[c]->fMark = 1;
486 }
487 // the group is not taken - find the new group
488 s_GroupCounter++;
489
490 // rewind to the previously marked position in the cube pair queques
491 MarkRewind();
492 }
493 while ( ExorLinkCubeIteratorNext( s_CubeGroup ) );
494 // none of the groups leads to improvement
495
496 // return the old cubes back to storage
497 CubeInsert( s_pC1 );
498 CubeInsert( s_pC2 );
499 // clean the results of generating ExorLinked cubes
501 }
502END_OF_LOOP: {}
503 }
504
505 // print the report
506 if ( g_CoverInfo.Verbosity == 2 )
507 {
508 printf( "ExLink-%d", 3 );
509 printf( ": Que= %5d", s_cEnquequed );
510 printf( " Att= %4d", s_cAttempts );
511 printf( " Resh= %4d", s_cReshapes );
512 printf( " NoResh= %4d", s_cAttempts - s_cReshapes );
513 printf( " Cubes= %3d", g_CoverInfo.nCubesInUse );
514 printf( " (%d)", s_nCubesBefore - g_CoverInfo.nCubesInUse );
515 printf( " Lits= %5d", CountLiterals() );
516 printf( " QCost = %6d", CountQCost() );
517 printf( "\n" );
518 }
519
520 // return the number of cubes gained in the process
521 return s_nCubesBefore - g_CoverInfo.nCubesInUse;
522}
void UndoRecentChanges()
Definition exorList.c:750
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IterativelyApplyExorLink4()

int IterativelyApplyExorLink4 ( char fDistEnable)

Definition at line 524 of file exorList.c.

525{
526 int z, c;
527 // this var is specific to ExorLink-4
528 s_Dist = (cubedist)2;
529
530 // enable pair accumulation
531 s_fDistEnable2 = fDistEnable & 1;
532 s_fDistEnable3 = fDistEnable & 2;
533 s_fDistEnable4 = fDistEnable & 4;
534
535 // initialize counters
536 s_cEnquequed = GetQuequeStats( s_Dist );
537 s_cAttempts = 0;
538 s_cReshapes = 0;
539
540 // remember the number of cubes before minimization
541 s_nCubesBefore = g_CoverInfo.nCubesInUse;
542
543 for ( z = IteratorCubePairStart( s_Dist, &s_pC1, &s_pC2 ); z; z = IteratorCubePairNext() )
544 {
545 s_cAttempts++;
546 // start ExorLink of the given Distance
547 if ( ExorLinkCubeIteratorStart( s_CubeGroup, s_pC1, s_pC2, s_Dist ) )
548 {
549 // extract old cubes from storage (to prevent EXORing with their derivitives)
550 CubeExtract( s_pC1 );
551 CubeExtract( s_pC2 );
552
553 // mark the current position in the cube pair queques
554 MarkSet();
555
556 // check cube groups one by one
557 do
558 { // check the cubes of this group one by one
559 s_GainTotal = 0;
560 for ( c = 0; c < 4; c++ )
561 if ( !s_CubeGroup[c]->fMark ) // this cube has not yet been checked
562 {
563 s_Gain = CheckForCloseCubes( s_CubeGroup[c], 0 ); // do not insert the cube, by default
564 // if the cube leads to gain, it is already inserted
565 s_fInserted[c] = (int)(s_Gain>0);
566 // increment the total gain
567 s_GainTotal += s_Gain;
568 }
569 else
570 s_fInserted[c] = 0; // the cube has already been checked - it is not inserted
571
572 if ( s_GainTotal == 0 ) // the group does not lead to any gain
573 { // mark the cubes
574 for ( c = 0; c < 4; c++ )
575 s_CubeGroup[c]->fMark = 1;
576 }
577 else if ( s_GainTotal == 1 ) // the group does not lead to substantial gain, too
578 {
579 // undo changes to be able to continue checking groups
581 // mark those cubes that were not inserted
582 for ( c = 0; c < 4; c++ )
583 s_CubeGroup[c]->fMark = !s_fInserted[c];
584 }
585 else // if ( s_GainTotal > 1 ) // the group reshapes or improves
586 { // accept the group
587 for ( c = 0; c < 4; c++ ) // insert other cubes
588 if ( !s_fInserted[c] )
589 CheckForCloseCubes( s_CubeGroup[c], 1 );
590// CheckAndInsert( s_CubeGroup[c] );
591 // clean the results of generating ExorLinked cubes
592 ExorLinkCubeIteratorCleanUp( 1 ); // take the last group
593 // free old cubes
594 AddToFreeCubes( s_pC1 );
595 AddToFreeCubes( s_pC2 );
596 // update the counter
597 s_cReshapes++;
598 goto END_OF_LOOP;
599 }
600
601 // rewind to the previously marked position in the cube pair queques
602 MarkRewind();
603 }
604 while ( ExorLinkCubeIteratorNext( s_CubeGroup ) );
605 // none of the groups leads to improvement
606
607 // return the old cubes back to storage
608 CubeInsert( s_pC1 );
609 CubeInsert( s_pC2 );
610 // clean the results of generating ExorLinked cubes
612 }
613END_OF_LOOP: {}
614 }
615
616 // print the report
617 if ( g_CoverInfo.Verbosity == 2 )
618 {
619 printf( "ExLink-%d", 4 );
620 printf( ": Que= %5d", s_cEnquequed );
621 printf( " Att= %4d", s_cAttempts );
622 printf( " Resh= %4d", s_cReshapes );
623 printf( " NoResh= %4d", s_cAttempts - s_cReshapes );
624 printf( " Cubes= %3d", g_CoverInfo.nCubesInUse );
625 printf( " (%d)", s_nCubesBefore - g_CoverInfo.nCubesInUse );
626 printf( " Lits= %5d", CountLiterals() );
627 printf( " QCost = %6d", CountQCost() );
628 printf( "\n" );
629 }
630
631 // return the number of cubes gained in the process
632 return s_nCubesBefore - g_CoverInfo.nCubesInUse;
633}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IteratorCubePairNext()

int IteratorCubePairNext ( )

Definition at line 1073 of file exorList.c.

1075{
1076 int fEntryFound = 0;
1077 assert( s_Iter.fStarted );
1078
1079 // go through the entries while there is something in the queque
1080 for ( pQ = &s_Que[ s_Iter.Dist ]; pQ->PosOut != s_Iter.PosStop; pQ->PosOut = (pQ->PosOut+1)%s_nPosAlloc )
1081 {
1082 p1 = pQ->pC1[ pQ->PosOut ];
1083 p2 = pQ->pC2[ pQ->PosOut ];
1084
1085 // check whether the entry is valid
1086 if ( p1->ID == pQ->ID1[ pQ->PosOut ] &&
1087 p2->ID == pQ->ID2[ pQ->PosOut ] ) //&&
1088 //p1->x + p1->y + p2->x + p2->y > s_Iter.CutValue )
1089 {
1090 fEntryFound = 1;
1091 break;
1092 }
1093 }
1094
1095 if ( fEntryFound )
1096 { // write the result into the pick-up place
1097 *(s_Iter.ppC1) = pQ->pC1[ pQ->PosOut ];
1098 *(s_Iter.ppC2) = pQ->pC2[ pQ->PosOut ];
1099
1100 pQ->PosOut = (pQ->PosOut+1)%s_nPosAlloc;
1101 }
1102 else // iteration has finished
1103 s_Iter.fStarted = 0;
1104
1105 return fEntryFound;
1106}
Here is the caller graph for this function:

◆ IteratorCubePairStart()

int IteratorCubePairStart ( cubedist Dist,
Cube ** ppC1,
Cube ** ppC2 )

Definition at line 1023 of file exorList.c.

1027{
1028 int fEntryFound;
1029
1030 assert( s_Iter.fStarted == 0 );
1031 assert( CubeDist >= 0 && CubeDist <= 2 );
1032
1033 s_Iter.fStarted = 1;
1034 s_Iter.Dist = CubeDist;
1035 s_Iter.ppC1 = ppC1;
1036 s_Iter.ppC2 = ppC2;
1037
1038 s_Iter.PosStop = s_Que[ CubeDist ].PosIn;
1039
1040 // determine the cut value
1041// s_Iter.CutValue = s_nLiteralsInUse/s_nCubesInUse/2;
1042 s_Iter.CutValue = -1;
1043
1044 fEntryFound = 0;
1045 // go through the entries while there is something in the queque
1046 for ( pQ = &s_Que[ CubeDist ]; pQ->PosOut != s_Iter.PosStop; pQ->PosOut = (pQ->PosOut+1)%s_nPosAlloc )
1047 {
1048 p1 = pQ->pC1[ pQ->PosOut ];
1049 p2 = pQ->pC2[ pQ->PosOut ];
1050
1051 // check whether the entry is valid
1052 if ( p1->ID == pQ->ID1[ pQ->PosOut ] &&
1053 p2->ID == pQ->ID2[ pQ->PosOut ] ) //&&
1054 //p1->x + p1->y + p2->x + p2->y > s_Iter.CutValue )
1055 {
1056 fEntryFound = 1;
1057 break;
1058 }
1059 }
1060
1061 if ( fEntryFound )
1062 { // write the result into the pick-up place
1063 *ppC1 = pQ->pC1[ pQ->PosOut ];
1064 *ppC2 = pQ->pC2[ pQ->PosOut ];
1065
1066 pQ->PosOut = (pQ->PosOut+1)%s_nPosAlloc;
1067 }
1068 else
1069 s_Iter.fStarted = 0;
1070 return fEntryFound;
1071}
Cube ** ppC2
Definition exorList.c:1014
Cube ** ppC1
Definition exorList.c:1013
Here is the caller graph for this function:

◆ IterCubeSetNext()

Cube * IterCubeSetNext ( )

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 ( )

Cube Set Iterator ///.

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:

◆ PrintQuequeStats()

void PrintQuequeStats ( )

Definition at line 985 of file exorList.c.

986{
987/*
988 cout << endl << "Queque statistics: ";
989 cout << " Alloc = " << s_nPosAlloc;
990 cout << " DIST2 = " << GetPosDiff( s_Que[0].PosOut, s_Que[0].PosIn );
991 cout << " DIST3 = " << GetPosDiff( s_Que[1].PosOut, s_Que[1].PosIn );
992 cout << " DIST4 = " << GetPosDiff( s_Que[2].PosOut, s_Que[2].PosIn );
993 cout << endl;
994 cout << endl;
995*/
996}

◆ UndoRecentChanges()

void UndoRecentChanges ( )

Definition at line 750 of file exorList.c.

751{
752 Cube * p, * q;
753 // get back cube q that was deleted
754 q = GetFreeCube();
755 // restore the ID
756 q->ID = s_ChangeStore.PrevID;
757 // insert the cube into storage again
758 CubeInsert( q );
759
760 // extract cube p
761 p = CubeExtract( s_ChangeStore.p );
762
763 // modify it back
764 if ( s_ChangeStore.fInput ) // the input has changed
765 {
766 ExorVar( p, s_ChangeStore.Var, (varvalue)s_ChangeStore.Value );
767 p->a = s_ChangeStore.PrevPa;
768 p->q = s_ChangeStore.PrevPq;
769 // p->z did not change
770 }
771 else // if ( s_ChangeStore.fInput ) // the output has changed
772 {
773 int i;
774 for ( i = 0; i < g_CoverInfo.nWordsOut; i++ )
775 p->pCubeDataOut[i] ^= q->pCubeDataOut[i];
776 p->z = s_ChangeStore.PrevPz;
777 // p->a did not change
778 }
779}
void ExorVar(Cube *pC, int Var, varvalue Val)
Definition exorBits.c:197
Cube * GetFreeCube()
Definition exorCubes.c:174
byte ID
Definition exor.h:125
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ BitCount

unsigned char BitCount[]
extern

Definition at line 138 of file exorBits.c.

◆ CutValue

int CutValue

Definition at line 1017 of file exorList.c.

◆ Dist

cubedist Dist

Definition at line 1012 of file exorList.c.

◆ fInput

int fInput

Definition at line 221 of file exorList.c.

◆ fStarted

int fStarted

Definition at line 1011 of file exorList.c.

◆ g_CoverInfo

ABC_NAMESPACE_IMPL_START cinfo g_CoverInfo
extern

EXTERNAL VARIABLES ///.

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

FileName [exorList.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Exclusive sum-of-product minimization.]

Synopsis [Cube lists.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

                                                            ///
           Iterative Cube Set Minimization                  ///
            Iterative ExorLink Procedure                    ///
            Support of Cube Pair Queques                    ///
                                                            ///

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.2. Started - July 30, 2000. Last update - July 31, 2000 /// Ver. 1.4. Started - Aug 10, 2000. Last update - Aug 26, 2000 /// Ver. 1.5. Started - Aug 30, 2000. Last update - Aug 30, 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/ ///

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.

◆ p

Cube* p

Definition at line 222 of file exorList.c.

◆ PosStop

int PosStop

Definition at line 1015 of file exorList.c.

◆ ppC1

Cube** ppC1

Definition at line 1013 of file exorList.c.

◆ ppC2

Cube** ppC2

Definition at line 1014 of file exorList.c.

◆ PrevID

int PrevID

Definition at line 230 of file exorList.c.

◆ PrevPa

int PrevPa

Definition at line 224 of file exorList.c.

◆ PrevPq

int PrevPq

Definition at line 226 of file exorList.c.

◆ PrevPz

int PrevPz

Definition at line 227 of file exorList.c.

◆ PrevQa

int PrevQa

Definition at line 223 of file exorList.c.

◆ PrevQq

int PrevQq

Definition at line 225 of file exorList.c.

◆ s_DiffVarNum

int s_DiffVarNum

Definition at line 638 of file exorList.c.

◆ s_DiffVarValueP_new

int s_DiffVarValueP_new

Definition at line 640 of file exorList.c.

◆ s_DiffVarValueP_old

int s_DiffVarValueP_old

Definition at line 639 of file exorList.c.

◆ s_DiffVarValueQ

int s_DiffVarValueQ

Definition at line 641 of file exorList.c.

◆ s_Distance

int s_Distance

Definition at line 637 of file exorList.c.

◆ s_fDecreaseLiterals

int s_fDecreaseLiterals = 0

Definition at line 247 of file exorList.c.

◆ s_nPosAlloc

int s_nPosAlloc

EXPORTED VARIABLES /// /////////////////////////////////////////////////////////////////////`.

Definition at line 179 of file exorList.c.

◆ s_nPosMax

int s_nPosMax[3]

Definition at line 181 of file exorList.c.

◆ s_pCubeLast

Cube* s_pCubeLast

CUBE ITERATOR ///.

Definition at line 874 of file exorList.c.

◆ s_q

Cube* s_q

Definition at line 636 of file exorList.c.

◆ Value

int Value

Definition at line 229 of file exorList.c.

◆ Var

int Var

Definition at line 228 of file exorList.c.