ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioReadPlaMo.c File Reference
#include "ioAbc.h"
#include "misc/util/utilTruth.h"
Include dependency graph for ioReadPlaMo.c:

Go to the source code of this file.

Classes

struct  Mop_Man_t_
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Mop_Man_t_ Mop_Man_t
 DECLARATIONS ///.
 

Functions

Mop_Man_tMop_ManAlloc (int nIns, int nOuts, int nCubes)
 FUNCTION DEFINITIONS ///.
 
void Mop_ManStop (Mop_Man_t *p)
 
char * Mop_ManLoadFile (char *pFileName)
 
int Mop_ManReadParams (char *pBuffer, int *pnIns, int *pnOuts)
 
Mop_Man_tMop_ManRead (char *pFileName)
 
void Mop_ManPrintOne (Mop_Man_t *p, int iCube)
 
void Mop_ManPrint (Mop_Man_t *p)
 
Vec_Int_tMop_ManCollectStats (Mop_Man_t *p)
 
int Mop_ManRemoveIdentical (Mop_Man_t *p, Vec_Int_t *vGroup)
 
Vec_Int_tMop_ManCompatiblePairs (Vec_Int_t *vPairs, int nObjs)
 
Vec_Int_tMop_ManFindDist1Pairs (Mop_Man_t *p, Vec_Int_t *vGroup)
 
int Mop_ManMergeDist1Pairs (Mop_Man_t *p, Vec_Int_t *vGroup, Vec_Int_t *vGroupPrev, Vec_Int_t *vStats, int nLimit)
 
int Mop_ManMergeDist1Pairs2 (Mop_Man_t *p, Vec_Int_t *vGroup, Vec_Int_t *vGroupPrev)
 
int Mop_ManMergeDist1All (Mop_Man_t *p, Vec_Wec_t *vGroups, Vec_Int_t *vStats, int nLimit)
 
int Mop_ManMergeContainTwo (Mop_Man_t *p, Vec_Int_t *vGroup, Vec_Int_t *vGroup2)
 
int Mop_ManMergeContainAll (Mop_Man_t *p, Vec_Wec_t *vGroups)
 
void Mop_ManReduce2 (Mop_Man_t *p)
 
void Mop_ManReduce (Mop_Man_t *p)
 
Vec_Wec_tMop_ManCubeCount (Mop_Man_t *p)
 
Abc_Ntk_tMop_ManDerive (Mop_Man_t *p, char *pFileName)
 
Abc_Ntk_tMop_ManTest (char *pFileName, int fMerge, int fVerbose)
 

Typedef Documentation

◆ Mop_Man_t

typedef typedefABC_NAMESPACE_IMPL_START struct Mop_Man_t_ Mop_Man_t

DECLARATIONS ///.

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

FileName [ioReadPlaMo.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedure to read network from file.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id
ioReadPlaMo.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 30 of file ioReadPlaMo.c.

Function Documentation

◆ Mop_ManAlloc()

Mop_Man_t * Mop_ManAlloc ( int nIns,
int nOuts,
int nCubes )

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 64 of file ioReadPlaMo.c.

65{
67 p->nIns = nIns;
68 p->nOuts = nOuts;
69 p->nWordsIn = Abc_Bit6WordNum( 2 * nIns );
70 p->nWordsOut = Abc_Bit6WordNum( nOuts );
71 p->vWordsIn = Vec_WrdStart( 2 * p->nWordsIn * nCubes );
72 p->vWordsOut = Vec_WrdStart( 2 * p->nWordsOut * nCubes );
73 p->vCubes = Vec_IntAlloc( 2 * nCubes );
74 p->vFree = Vec_IntAlloc( 2 * nCubes );
75 return p;
76}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Cube * p
Definition exorList.c:222
typedefABC_NAMESPACE_IMPL_START struct Mop_Man_t_ Mop_Man_t
DECLARATIONS ///.
Definition ioReadPlaMo.c:30
Here is the caller graph for this function:

◆ Mop_ManCollectStats()

Vec_Int_t * Mop_ManCollectStats ( Mop_Man_t * p)

Function*************************************************************

Synopsis [Count how many times each variable appears in the input parts.]

Description []

SideEffects []

SeeAlso []

Definition at line 309 of file ioReadPlaMo.c.

310{
311 int i, v, iCube, nVars = 32 * p->nWordsIn;
312 Vec_Int_t * vStats = Vec_IntStart( nVars );
313 Vec_IntForEachEntry( p->vCubes, iCube, i )
314 {
315 word * pCube = Mop_ManCubeIn(p, iCube);
316 int nOutLits = Mop_ManCountOnes( Mop_ManCubeOut(p, iCube), p->nWordsOut );
317 for ( v = 0; v < nVars; v++ )
318 if ( Abc_TtGetQua(pCube, v) )
319 Vec_IntAddToEntry( vStats, v, nOutLits );
320 }
321 return vStats;
322}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the caller graph for this function:

◆ Mop_ManCompatiblePairs()

Vec_Int_t * Mop_ManCompatiblePairs ( Vec_Int_t * vPairs,
int nObjs )

Definition at line 409 of file ioReadPlaMo.c.

410{
411 int i, Entry, Entry2;
412 Vec_Int_t * vCounts = Vec_IntStart( nObjs );
413 Vec_Int_t * vPairsNew = Vec_IntAlloc( Vec_IntSize(vPairs) );
414 Vec_IntForEachEntry( vPairs, Entry, i )
415 Vec_IntAddToEntry( vCounts, Entry, 1 );
416 // include pairs which have those that appear only once
417 Vec_IntForEachEntryDouble( vPairs, Entry, Entry2, i )
418 if ( Vec_IntEntry(vCounts, Entry) == 1 || Vec_IntEntry(vCounts, Entry2) == 1 )
419 {
420 if ( Vec_IntEntry(vCounts, Entry) == 1 )
421 Vec_IntPushTwo( vPairsNew, Entry, Entry2 );
422 else
423 Vec_IntPushTwo( vPairsNew, Entry2, Entry );
424 Vec_IntWriteEntry( vCounts, Entry, -1 );
425 Vec_IntWriteEntry( vCounts, Entry2, -1 );
426 }
427 // add those remaining pairs that are both present
428 Vec_IntForEachEntryDouble( vPairs, Entry, Entry2, i )
429 if ( Vec_IntEntry(vCounts, Entry) > 0 && Vec_IntEntry(vCounts, Entry2) > 0 )
430 {
431 Vec_IntPushTwo( vPairsNew, Entry, Entry2 );
432 Vec_IntWriteEntry( vCounts, Entry, -1 );
433 Vec_IntWriteEntry( vCounts, Entry2, -1 );
434 }
435 // add remaining pairs
436 Vec_IntForEachEntryDouble( vPairs, Entry, Entry2, i )
437 if ( Vec_IntEntry(vCounts, Entry) > 0 || Vec_IntEntry(vCounts, Entry2) > 0 )
438 {
439 if ( Vec_IntEntry(vCounts, Entry) > 0 )
440 Vec_IntPushTwo( vPairsNew, Entry, Entry2 );
441 else
442 Vec_IntPushTwo( vPairsNew, Entry2, Entry );
443 Vec_IntWriteEntry( vCounts, Entry, -1 );
444 Vec_IntWriteEntry( vCounts, Entry2, -1 );
445 }
446 Vec_IntFree( vCounts );
447 // verify the result
448 if ( 0 )
449 {
450 Vec_Int_t * vTemp1 = Vec_IntDup( vPairs );
451 Vec_Int_t * vTemp2 = Vec_IntDup( vPairsNew );
452 Vec_IntUniqify( vTemp1 );
453 Vec_IntUniqify( vTemp2 );
454 assert( Vec_IntEqual( vTemp1, vTemp2 ) );
455 Vec_IntFree( vTemp1 );
456 Vec_IntFree( vTemp2 );
457 }
458 return vPairsNew;
459}
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition vecInt.h:72
Here is the caller graph for this function:

◆ Mop_ManCubeCount()

Vec_Wec_t * Mop_ManCubeCount ( Mop_Man_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 721 of file ioReadPlaMo.c.

722{
723 int i, k, iCube;
724 Vec_Wec_t * vOuts = Vec_WecStart( p->nOuts );
725 Vec_IntForEachEntry( p->vCubes, iCube, i )
726 if ( iCube != -1 )
727 {
728 word * pCube = Mop_ManCubeOut( p, iCube );
729 for ( k = 0; k < p->nOuts; k++ )
730 if ( Abc_TtGetBit( pCube, k ) )
731 Vec_WecPush( vOuts, k, iCube );
732 }
733 return vOuts;
734}
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
Here is the caller graph for this function:

◆ Mop_ManDerive()

Abc_Ntk_t * Mop_ManDerive ( Mop_Man_t * p,
char * pFileName )

Definition at line 735 of file ioReadPlaMo.c.

736{
737 int i, k, c, iCube;
738 char Symb[4] = { '-', '0', '1', '?' }; // cube symbols
739 Vec_Str_t * vSop = Vec_StrAlloc( 1000 ); // storage for one SOP
740 Vec_Wec_t * vOuts = Mop_ManCubeCount( p ); // cube count for each output
742 pNtk->pName = Extra_UtilStrsav( pFileName );
743 pNtk->pSpec = Extra_UtilStrsav( pFileName );
744 for ( i = 0; i < p->nIns; i++ )
745 Abc_NtkCreatePi(pNtk);
746 for ( i = 0; i < p->nOuts; i++ )
747 {
748 Vec_Int_t * vThis = Vec_WecEntry( vOuts, i );
749 Abc_Obj_t * pPo = Abc_NtkCreatePo(pNtk);
750 Abc_Obj_t * pNode = Abc_NtkCreateNode(pNtk);
751 Abc_ObjAddFanin( pPo, pNode );
752 if ( Vec_IntSize(vThis) == 0 )
753 {
754 pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, " 0\n" );
755 continue;
756 }
757 for ( k = 0; k < p->nIns; k++ )
758 Abc_ObjAddFanin( pNode, Abc_NtkPi(pNtk, k) );
759 Vec_StrClear( vSop );
760 Vec_IntForEachEntry( vThis, iCube, c )
761 {
762 word * pCube = Mop_ManCubeIn( p, iCube );
763 for ( k = 0; k < p->nIns; k++ )
764 Vec_StrPush( vSop, Symb[Abc_TtGetQua(pCube, k)] );
765 Vec_StrAppend( vSop, " 1\n" );
766 }
767 Vec_StrPush( vSop, '\0' );
768 pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, Vec_StrArray(vSop) );
769 }
770 Vec_StrFree( vSop );
771 Vec_WecFree( vOuts );
774 return pNtk;
775}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition abcNtk.c:53
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
@ ABC_NTK_LOGIC
Definition abc.h:57
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:521
@ ABC_FUNC_SOP
Definition abc.h:65
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
Definition abcSop.c:62
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:495
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
char * Extra_UtilStrsav(const char *s)
Vec_Wec_t * Mop_ManCubeCount(Mop_Man_t *p)
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
char * pName
Definition abc.h:158
void * pManFunc
Definition abc.h:191
char * pSpec
Definition abc.h:159
void * pData
Definition abc.h:145
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mop_ManFindDist1Pairs()

Vec_Int_t * Mop_ManFindDist1Pairs ( Mop_Man_t * p,
Vec_Int_t * vGroup )

Definition at line 461 of file ioReadPlaMo.c.

462{
463 int c1, c2, iCube1, iCube2;
464 Vec_Int_t * vPairs = Vec_IntAlloc( 100 );
465 Vec_IntForEachEntry( vGroup, iCube1, c1 )
466 {
467 word * pCube1Out, * pCube1 = Mop_ManCubeIn( p, iCube1 );
468 Vec_IntForEachEntryStart( vGroup, iCube2, c2, c1+1 )
469 {
470 word * pCube2Out, * pCube2 = Mop_ManCubeIn( p, iCube2 );
471 if ( !Mop_ManCheckDist1(pCube1, pCube2, p->nWordsIn) )
472 continue;
473 pCube1Out = Mop_ManCubeOut( p, iCube1 );
474 pCube2Out = Mop_ManCubeOut( p, iCube2 );
475 if ( !memcmp(pCube1Out, pCube2Out, sizeof(word)*p->nWordsOut) )
476 Vec_IntPushTwo( vPairs, c1, c2 );
477 }
478 }
479 return vPairs;
480}
int memcmp()
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition vecInt.h:56
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mop_ManLoadFile()

char * Mop_ManLoadFile ( char * pFileName)

Function*************************************************************

Synopsis [Reads the file into a character buffer.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file ioReadPlaMo.c.

98{
99 FILE * pFile;
100 int nFileSize, RetValue;
101 char * pContents;
102 pFile = fopen( pFileName, "rb" );
103 if ( pFile == NULL )
104 {
105 Abc_Print( -1, "Mop_ManLoadFile(): The file is unavailable (absent or open).\n" );
106 return NULL;
107 }
108 fseek( pFile, 0, SEEK_END );
109 nFileSize = ftell( pFile );
110 if ( nFileSize == 0 )
111 {
112 Abc_Print( -1, "Mop_ManLoadFile(): The file is empty.\n" );
113 return NULL;
114 }
115 pContents = ABC_ALLOC( char, nFileSize + 10 );
116 rewind( pFile );
117 RetValue = fread( pContents, nFileSize, 1, pFile );
118 fclose( pFile );
119 strcpy( pContents + nFileSize, "\n" );
120 return pContents;
121}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
char * strcpy()
VOID_HACK rewind()
#define SEEK_END
Definition zconf.h:392
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mop_ManMergeContainAll()

int Mop_ManMergeContainAll ( Mop_Man_t * p,
Vec_Wec_t * vGroups )

Definition at line 637 of file ioReadPlaMo.c.

638{
639 Vec_Int_t * vGroup, * vGroup2;
640 int i, k, Count = 0;
641 Vec_WecForEachLevel( vGroups, vGroup, i )
642 {
643 Count += Mop_ManRemoveIdentical( p, vGroup );
644 Vec_WecForEachLevelStart( vGroups, vGroup2, k, i+1 )
645 Count += Mop_ManMergeContainTwo( p, vGroup, vGroup2 );
646 }
647 return Count;
648}
int Mop_ManRemoveIdentical(Mop_Man_t *p, Vec_Int_t *vGroup)
int Mop_ManMergeContainTwo(Mop_Man_t *p, Vec_Int_t *vGroup, Vec_Int_t *vGroup2)
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
#define Vec_WecForEachLevelStart(vGlob, vVec, i, LevelStart)
Definition vecWec.h:59
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mop_ManMergeContainTwo()

int Mop_ManMergeContainTwo ( Mop_Man_t * p,
Vec_Int_t * vGroup,
Vec_Int_t * vGroup2 )

Definition at line 606 of file ioReadPlaMo.c.

607{
608 int w, c1, c2, iCube1, iCube2, Count = 0;
609 Vec_IntForEachEntry( vGroup, iCube1, c1 )
610 {
611 word * pCube1Out, * pCube1 = Mop_ManCubeIn( p, iCube1 );
612 Vec_IntForEachEntry( vGroup2, iCube2, c2 )
613 if ( iCube2 != -1 )
614 {
615 word * pCube2Out, * pCube2 = Mop_ManCubeIn( p, iCube2 );
616 if ( !Mop_ManCheckContain(pCube2, pCube1, p->nWordsIn) )
617 continue;
618 pCube1Out = Mop_ManCubeOut( p, iCube1 );
619 pCube2Out = Mop_ManCubeOut( p, iCube2 );
620 for ( w = 0; w < p->nWordsOut; w++ )
621 pCube2Out[w] &= ~pCube1Out[w];
622 for ( w = 0; w < p->nWordsOut; w++ )
623 if ( pCube2Out[w] )
624 break;
625 if ( w < p->nWordsOut ) // has output literals
626 continue;
627 // remove larger cube
628 Vec_IntWriteEntry( vGroup2, c2, -1 );
629 Vec_IntPush( p->vFree, iCube2 );
630 Count++;
631 }
632 }
633 if ( Count )
634 Map_ManGroupCompact( vGroup2 );
635 return Count;
636}
Here is the caller graph for this function:

◆ Mop_ManMergeDist1All()

int Mop_ManMergeDist1All ( Mop_Man_t * p,
Vec_Wec_t * vGroups,
Vec_Int_t * vStats,
int nLimit )

Definition at line 583 of file ioReadPlaMo.c.

584{
585 Vec_Int_t * vGroup;
586 int i, nEqual, nReduce, Count = 0;
587 Vec_WecForEachLevelReverse( vGroups, vGroup, i )
588 {
589 if ( Vec_IntSize(vGroup) == 0 )
590 continue;
591 if ( i == 0 )
592 {
593 printf( "Detected constant-1 cover.\n" );
594 fflush( stdout );
595 return -1;
596 }
597 nEqual = Mop_ManRemoveIdentical( p, vGroup );
598 nReduce = Mop_ManMergeDist1Pairs( p, vGroup, Vec_WecEntry(vGroups, i-1), vStats, nLimit );
599 //Mop_ManMergeDist1Pairs2( p, vGroup, Vec_WecEntry(vGroups, i-1) );
600 Count += nEqual + nReduce;
601 //printf( "Group %3d : Equal =%5d. Reduce =%5d.\n", i, nEqual, nReduce );
602 }
603 return Count;
604}
int nEqual
Definition abcCut.c:34
int Mop_ManMergeDist1Pairs(Mop_Man_t *p, Vec_Int_t *vGroup, Vec_Int_t *vGroupPrev, Vec_Int_t *vStats, int nLimit)
#define Vec_WecForEachLevelReverse(vGlob, vVec, i)
Definition vecWec.h:65
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mop_ManMergeDist1Pairs()

int Mop_ManMergeDist1Pairs ( Mop_Man_t * p,
Vec_Int_t * vGroup,
Vec_Int_t * vGroupPrev,
Vec_Int_t * vStats,
int nLimit )

Definition at line 482 of file ioReadPlaMo.c.

483{
484 Vec_Int_t * vPairs = Mop_ManFindDist1Pairs( p, vGroup );
485 Vec_Int_t * vPairsNew = Mop_ManCompatiblePairs( vPairs, Vec_IntSize(vGroup) );
486 int nCubes = Vec_IntSize(vGroup) + Vec_IntSize(vGroupPrev);
487 int w, i, c1, c2, iCubeNew, iVar;
488 // move cubes to the previous group
489 word * pCube, * pCube1, * pCube2;
490 Vec_Int_t * vToFree = Vec_IntAlloc( Vec_IntSize(vPairsNew) );
491 Vec_IntForEachEntryDouble( vPairsNew, c1, c2, i )
492 {
493 pCube1 = Mop_ManCubeIn( p, Vec_IntEntry(vGroup, c1) );
494 pCube2 = Mop_ManCubeIn( p, Vec_IntEntry(vGroup, c2) );
495 assert( Mop_ManCheckDist1(pCube1, pCube2, p->nWordsIn) );
496
497 // skip those cubes that have frequently appearing variables
498 iVar = Mop_ManFindDiffVar( pCube1, pCube2, p->nWordsIn );
499 if ( Vec_IntEntry( vStats, iVar ) > nLimit )
500 continue;
501 Vec_IntPush( vToFree, c1 );
502 Vec_IntPush( vToFree, c2 );
503
504 iCubeNew = Vec_IntPop( p->vFree );
505 pCube = Mop_ManCubeIn( p, iCubeNew );
506 for ( w = 0; w < p->nWordsIn; w++ )
507 pCube[w] = pCube1[w] & pCube2[w];
508
509 pCube = Mop_ManCubeOut( p, iCubeNew );
510 pCube1 = Mop_ManCubeOut( p, Vec_IntEntry(vGroup, c1) );
511 pCube2 = Mop_ManCubeOut( p, Vec_IntEntry(vGroup, c2) );
512
513 assert( !memcmp(pCube1, pCube2, sizeof(word)*p->nWordsOut) );
514 for ( w = 0; w < p->nWordsOut; w++ )
515 pCube[w] = pCube1[w];
516
517 Vec_IntPush( vGroupPrev, iCubeNew );
518 }
519// Vec_IntForEachEntry( vPairsNew, c1, i )
520 Vec_IntForEachEntry( vToFree, c1, i )
521 {
522 if ( Vec_IntEntry(vGroup, c1) == -1 )
523 continue;
524 Vec_IntPush( p->vFree, Vec_IntEntry(vGroup, c1) );
525 Vec_IntWriteEntry( vGroup, c1, -1 );
526 }
527 Vec_IntFree( vToFree );
528 if ( Vec_IntSize(vPairsNew) > 0 )
529 Map_ManGroupCompact( vGroup );
530 Vec_IntFree( vPairs );
531 Vec_IntFree( vPairsNew );
532 return nCubes - Vec_IntSize(vGroup) - Vec_IntSize(vGroupPrev);
533}
Vec_Int_t * Mop_ManCompatiblePairs(Vec_Int_t *vPairs, int nObjs)
Vec_Int_t * Mop_ManFindDist1Pairs(Mop_Man_t *p, Vec_Int_t *vGroup)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mop_ManMergeDist1Pairs2()

int Mop_ManMergeDist1Pairs2 ( Mop_Man_t * p,
Vec_Int_t * vGroup,
Vec_Int_t * vGroupPrev )

Definition at line 535 of file ioReadPlaMo.c.

536{
537 int w, c1, c2, iCube1, iCube2, Count = 0;
538 Vec_IntForEachEntry( vGroup, iCube1, c1 )
539 if ( iCube1 != -1 )
540 {
541 word * pCube1Out, * pCube1 = Mop_ManCubeIn( p, iCube1 );
542 Vec_IntForEachEntryStart( vGroup, iCube2, c2, c1+1 )
543 if ( iCube2 != -1 )
544 {
545 word * pCube2Out, * pCube2 = Mop_ManCubeIn( p, iCube2 );
546 if ( !Mop_ManCheckDist1(pCube1, pCube2, p->nWordsIn) )
547 continue;
548 pCube1Out = Mop_ManCubeOut( p, iCube1 );
549 pCube2Out = Mop_ManCubeOut( p, iCube2 );
550 assert( memcmp(pCube1Out, pCube2Out, sizeof(word)*p->nWordsOut) );
551 if ( Mop_ManCheckContain(pCube1Out, pCube2Out, p->nWordsOut) ) // pCube1 has more outputs
552 {
553 // update the input part
554 for ( w = 0; w < p->nWordsIn; w++ )
555 pCube2[w] &= pCube1[w];
556 // sharp the output part
557 for ( w = 0; w < p->nWordsOut; w++ )
558 pCube1Out[w] &= ~pCube2Out[w];
559 // move to another group
560 Vec_IntPush( vGroupPrev, iCube2 );
561 Vec_IntWriteEntry( vGroup, c2, -1 );
562 Count++;
563 }
564 else if ( Mop_ManCheckContain(pCube2Out, pCube1Out, p->nWordsOut) ) // pCube2 has more outputs
565 {
566 // update the input part
567 for ( w = 0; w < p->nWordsIn; w++ )
568 pCube1[w] &= pCube2[w];
569 // sharp the output part
570 for ( w = 0; w < p->nWordsOut; w++ )
571 pCube2Out[w] &= ~pCube1Out[w];
572 // move to another group
573 Vec_IntPush( vGroupPrev, iCube1 );
574 Vec_IntWriteEntry( vGroup, c1, -1 );
575 Count++;
576 }
577 }
578 }
579 if ( Count )
580 Map_ManGroupCompact( vGroup );
581 return Count;
582}
if(last==0)
Definition sparse_int.h:34
Here is the call graph for this function:

◆ Mop_ManPrint()

void Mop_ManPrint ( Mop_Man_t * p)

Definition at line 220 of file ioReadPlaMo.c.

221{
222 int i, iCube;
223 printf( ".%d\n", p->nIns );
224 printf( ".%d\n", p->nOuts );
225 Vec_IntForEachEntry( p->vCubes, iCube, i )
226 Mop_ManPrintOne( p, iCube );
227 printf( ".e\n" );
228}
void Mop_ManPrintOne(Mop_Man_t *p, int iCube)
Here is the call graph for this function:

◆ Mop_ManPrintOne()

void Mop_ManPrintOne ( Mop_Man_t * p,
int iCube )

Definition at line 207 of file ioReadPlaMo.c.

208{
209 int k;
210 char Symb[4] = { '-', '0', '1', '?' };
211 word * pCubeIn = Mop_ManCubeIn( p, iCube );
212 word * pCubeOut = Mop_ManCubeOut( p, iCube );
213 for ( k = 0; k < p->nIns; k++ )
214 printf( "%c", Symb[Abc_TtGetQua(pCubeIn, k)] );
215 printf( " " );
216 for ( k = 0; k < p->nOuts; k++ )
217 printf( "%d", Abc_TtGetBit(pCubeOut, k) );
218 printf( "\n" );
219}
Here is the caller graph for this function:

◆ Mop_ManRead()

Mop_Man_t * Mop_ManRead ( char * pFileName)

Definition at line 147 of file ioReadPlaMo.c.

148{
149 Mop_Man_t * p;
150 int nIns, nOuts, nCubes, iCube;
151 char * pToken, * pBuffer = Mop_ManLoadFile( pFileName );
152 if ( pBuffer == NULL )
153 return NULL;
154 nCubes = Mop_ManReadParams( pBuffer, &nIns, &nOuts );
155 if ( nCubes == -1 )
156 return NULL;
157 p = Mop_ManAlloc( nIns, nOuts, nCubes );
158 // get the first cube
159 pToken = strtok( pBuffer, "\n" );
160 while ( pToken )
161 {
162 while ( Mop_ManIsSpace(*pToken) )
163 pToken++;
164 if ( Mop_ManIsSopSymb(*pToken) )
165 break;
166 pToken = strtok( NULL, "\n" );
167 }
168 // read cubes
169 for ( iCube = 0; pToken && Mop_ManIsSopSymb(*pToken); iCube++ )
170 {
171 char * pTokenCopy = pToken;
172 int i, o, nVars[2] = {nIns, nOuts};
173 word * pCube[2] = { Mop_ManCubeIn(p, iCube), Mop_ManCubeOut(p, iCube) };
174 for ( o = 0; o < 2; o++ )
175 {
176 while ( Mop_ManIsSpace(*pToken) )
177 pToken++;
178 for ( i = 0; i < nVars[o]; i++, pToken++ )
179 {
180 if ( !Mop_ManIsSopSymb(*pToken) )
181 {
182 printf( "Cannot read cube %d (%s).\n", iCube+1, pTokenCopy );
183 ABC_FREE( pBuffer );
184 Mop_ManStop( p );
185 return NULL;
186 }
187 if ( o == 1 )
188 {
189 if ( *pToken == '1' )
190 Abc_TtSetBit( pCube[o], i );
191 }
192 else if ( *pToken == '0' )
193 Abc_TtSetBit( pCube[o], 2*i );
194 else if ( *pToken == '1' )
195 Abc_TtSetBit( pCube[o], 2*i+1 );
196 }
197 }
198 assert( iCube < nCubes );
199 Vec_IntPush( p->vCubes, iCube );
200 pToken = strtok( NULL, "\n" );
201 }
202 for ( ; iCube < 2 * nCubes; iCube++ )
203 Vec_IntPush( p->vFree, iCube );
204 ABC_FREE( pBuffer );
205 return p;
206}
#define ABC_FREE(obj)
Definition abc_global.h:267
char * Mop_ManLoadFile(char *pFileName)
Definition ioReadPlaMo.c:97
void Mop_ManStop(Mop_Man_t *p)
Definition ioReadPlaMo.c:77
Mop_Man_t * Mop_ManAlloc(int nIns, int nOuts, int nCubes)
FUNCTION DEFINITIONS ///.
Definition ioReadPlaMo.c:64
int Mop_ManReadParams(char *pBuffer, int *pnIns, int *pnOuts)
char * strtok()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mop_ManReadParams()

int Mop_ManReadParams ( char * pBuffer,
int * pnIns,
int * pnOuts )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 134 of file ioReadPlaMo.c.

135{
136 char * pIns = strstr( pBuffer, ".i " );
137 char * pOuts = strstr( pBuffer, ".o " );
138 char * pStr = pBuffer; int nCubes = 0;
139 if ( pIns == NULL || pOuts == NULL )
140 return -1;
141 *pnIns = atoi( pIns + 2 );
142 *pnOuts = atoi( pOuts + 2 );
143 while ( *pStr )
144 nCubes += (*pStr++ == '\n');
145 return nCubes;
146}
char * strstr()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mop_ManReduce()

void Mop_ManReduce ( Mop_Man_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 686 of file ioReadPlaMo.c.

687{
688 abctime clk = Abc_Clock();
689 Vec_Int_t * vGroup, * vGroup2;
690 int i, k, nOutLits, nOutLits2, nEqual = 0, nContain = 0;
691 Vec_Wec_t * vGroups = Mop_ManCreateGroups( p );
692 // initial stats
693 nOutLits = Mop_ManCountOutputLits( p );
694 // check identical cubes within each group
695 Vec_WecForEachLevel( vGroups, vGroup, i )
696 nEqual += Mop_ManRemoveIdentical( p, vGroup );
697 // check contained cubes
698 Vec_WecForEachLevel( vGroups, vGroup, i )
699 Vec_WecForEachLevelStart( vGroups, vGroup2, k, i+1 )
700 nContain += Mop_ManMergeContainTwo( p, vGroup, vGroup2 );
701 // final stats
702 nOutLits2 = Mop_ManCountOutputLits( p );
703 Mop_ManUnCreateGroups( p, vGroups );
704 Vec_WecFree( vGroups );
705 // report
706 printf( "Total = %d. Reduced %d equal and %d contained cubes. Output lits: %d -> %d. ", Vec_IntSize(p->vCubes), nEqual, nContain, nOutLits, nOutLits2 );
707 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
708}
ABC_INT64_T abctime
Definition abc_global.h:332
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mop_ManReduce2()

void Mop_ManReduce2 ( Mop_Man_t * p)

Definition at line 649 of file ioReadPlaMo.c.

650{
651 abctime clk = Abc_Clock();
652 int nCubes = Vec_IntSize(p->vCubes);
653 Vec_Int_t * vStats = Mop_ManCollectStats( p );
654 Vec_Wec_t * vGroups = Mop_ManCreateGroups( p );
655 int nLimit = ABC_INFINITY; // 5 * Vec_IntSum(vStats) / Vec_IntSize(vStats) + 1;
656 int nOutLits = Mop_ManCountOutputLits( p );
657 int Count1 = Mop_ManMergeContainAll( p, vGroups );
658 int Count2 = Mop_ManMergeDist1All( p, vGroups, vStats, nLimit );
659 int Count3 = Mop_ManMergeContainAll( p, vGroups );
660 int Count4 = Mop_ManMergeDist1All( p, vGroups, vStats, nLimit );
661 int Count5 = Mop_ManMergeContainAll( p, vGroups );
662 int Removed = Mop_ManUnCreateGroups( p, vGroups );
663 int nOutLits2 = Mop_ManCountOutputLits( p );
664 Vec_WecFree( vGroups );
665//Vec_IntPrint( vStats );
666 Vec_IntFree( vStats );
667 assert( Removed == Count1 + Count2 + Count3 );
668 // report
669 printf( "Cubes: %d -> %d. C = %d. M = %d. C = %d. M = %d. C = %d. Output lits: %d -> %d. ",
670 nCubes, Vec_IntSize(p->vCubes), Count1, Count2, Count3, Count4, Count5, nOutLits, nOutLits2 );
671 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
672}
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
Vec_Int_t * Mop_ManCollectStats(Mop_Man_t *p)
int Mop_ManMergeContainAll(Mop_Man_t *p, Vec_Wec_t *vGroups)
int Mop_ManMergeDist1All(Mop_Man_t *p, Vec_Wec_t *vGroups, Vec_Int_t *vStats, int nLimit)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mop_ManRemoveIdentical()

int Mop_ManRemoveIdentical ( Mop_Man_t * p,
Vec_Int_t * vGroup )

Definition at line 381 of file ioReadPlaMo.c.

382{
383 int w, c1, c2, iCube1, iCube2, nEqual = 0;
384 Vec_IntForEachEntry( vGroup, iCube1, c1 )
385 if ( iCube1 != -1 )
386 {
387 word * pCube1Out, * pCube1 = Mop_ManCubeIn( p, iCube1 );
388 Vec_IntForEachEntryStart( vGroup, iCube2, c2, c1+1 )
389 if ( iCube2 != -1 )
390 {
391 word * pCube2Out, * pCube2 = Mop_ManCubeIn( p, iCube2 );
392 if ( memcmp(pCube1, pCube2, sizeof(word)*p->nWordsIn) )
393 continue;
394 // merge cubes
395 pCube1Out = Mop_ManCubeOut( p, iCube1 );
396 pCube2Out = Mop_ManCubeOut( p, iCube2 );
397 for ( w = 0; w < p->nWordsOut; w++ )
398 pCube1Out[w] |= pCube2Out[w];
399 Vec_IntWriteEntry( vGroup, c2, -1 );
400 Vec_IntPush( p->vFree, iCube2 );
401 nEqual++;
402 }
403 }
404 if ( nEqual )
405 Map_ManGroupCompact( vGroup );
406 return nEqual;
407}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mop_ManStop()

void Mop_ManStop ( Mop_Man_t * p)

Definition at line 77 of file ioReadPlaMo.c.

78{
79 Vec_WrdFree( p->vWordsIn );
80 Vec_WrdFree( p->vWordsOut );
81 Vec_IntFree( p->vCubes );
82 Vec_IntFree( p->vFree );
83 ABC_FREE( p );
84}
Here is the caller graph for this function:

◆ Mop_ManTest()

Abc_Ntk_t * Mop_ManTest ( char * pFileName,
int fMerge,
int fVerbose )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 788 of file ioReadPlaMo.c.

789{
790 Abc_Ntk_t * pNtk = NULL;
791 Mop_Man_t * p = Mop_ManRead( pFileName );
792 if ( p == NULL )
793 return NULL;
794 Mop_ManRemoveEmpty( p );
795 //Mop_ManPrint( p );
796 if ( fMerge )
797 Mop_ManReduce2( p );
798 else
799 Mop_ManReduce( p );
800 //Mop_ManPrint( p );
801 pNtk = Mop_ManDerive( p, pFileName );
802 Mop_ManStop( p );
803 return pNtk;
804}
void Mop_ManReduce2(Mop_Man_t *p)
void Mop_ManReduce(Mop_Man_t *p)
Mop_Man_t * Mop_ManRead(char *pFileName)
Abc_Ntk_t * Mop_ManDerive(Mop_Man_t *p, char *pFileName)
Here is the call graph for this function: