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

Go to the source code of this file.

Macros

#define LARGE_NUM   1000000
 MACRO DEFINITIONS ///.
 

Enumerations

enum  { vs0 , vs1 , vsX }
 

Functions

int ExorLinkCubeIteratorStart (Cube **pGroup, Cube *pC1, Cube *pC2, cubedist Dist)
 EXTERNAL FUNCTION DECLARATIONS ///.
 
int ExorLinkCubeIteratorNext (Cube **pGroup)
 
int ExorLinkCubeIteratorPick (Cube **pGroup, int g)
 
void ExorLinkCubeIteratorCleanUp (int fTakeLastGroup)
 

Variables

cinfo g_CoverInfo
 EXTERNAL VARIABLES ///.
 
Cubeg_CubesFree
 
byte BitCount []
 
const int s_ELMax = 4
 EXORLINK INFO ///.
 
const int s_ELnCubes [4] = { 4, 12, 32, 80 }
 
const int s_ELnGroups [4] = { 2, 6, 24, 120 }
 

Macro Definition Documentation

◆ LARGE_NUM

#define LARGE_NUM   1000000

MACRO DEFINITIONS ///.

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

FileName [exorLink.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Exclusive sum-of-product minimization.]

Synopsis [Cube iterators.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

                                                            ///
           Generation of ExorLinked Cubes                   ///
                                                            ///

Ver. 1.0. Started - July 26, 2000. Last update - July 29, 2000 /// Ver. 1.4. Started - Aug 10, 2000. Last update - Aug 12, 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 49 of file exorLink.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
vs0 
vs1 
vsX 

Definition at line 108 of file exorLink.c.

108{ vs0, vs1, vsX };

Function Documentation

◆ ExorLinkCubeIteratorCleanUp()

void ExorLinkCubeIteratorCleanUp ( int fTakeLastGroup)

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
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExorLinkCubeIteratorNext()

int ExorLinkCubeIteratorNext ( Cube ** pGroup)

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}
int ComputeQCostBits(Cube *p)
Definition exor.c:139
ABC_NAMESPACE_IMPL_START cinfo g_CoverInfo
GLOBAL VARIABLES ///.
Definition exor.c:58
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 )

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 )

EXTERNAL FUNCTION DECLARATIONS ///.

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:

Variable Documentation

◆ BitCount

byte BitCount[]
extern

Definition at line 138 of file exorBits.c.

◆ g_CoverInfo

cinfo g_CoverInfo
extern

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.

◆ g_CubesFree

Cube* g_CubesFree
extern

◆ s_ELMax

const int s_ELMax = 4

EXORLINK INFO ///.

Definition at line 96 of file exorLink.c.

◆ s_ELnCubes

const int s_ELnCubes[4] = { 4, 12, 32, 80 }

Definition at line 103 of file exorLink.c.

103{ 4, 12, 32, 80 };

◆ s_ELnGroups

const int s_ELnGroups[4] = { 2, 6, 24, 120 }

Definition at line 104 of file exorLink.c.

104{ 2, 6, 24, 120 };