ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaMinLut.c File Reference
#include "gia.h"
#include "giaAig.h"
#include "base/main/mainInt.h"
#include "opt/sfm/sfm.h"
Include dependency graph for giaMinLut.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START Abc_Ntk_tAbc_NtkFromAigPhase (Aig_Man_t *pMan)
 DECLARATIONS ///.
 
Vec_Wec_tVec_WrdReadLayerText (char *pFileName, int *pnIns, int *pnOuts)
 FUNCTION DEFINITIONS ///.
 
int Vec_WrdReadTruthTextOne (char *pFileName, int nIns, int nOuts, word *pRes)
 
wordVec_WrdReadTruthText (char *pFileName, int nIns, int nOuts, int nFiles)
 
Gia_Man_tVec_WrdReadTest (char *pFileName)
 
void Vec_WrdReadText (char *pFileName, Vec_Wrd_t **pvSimI, Vec_Wrd_t **pvSimO, int nIns, int nOuts)
 
int Vec_WrdReadText2 (char *pFileName, Vec_Wrd_t **pvSimI)
 
Vec_Int_tVec_WrdReadNumsOut (char *pFileName, int fVerbose)
 
Vec_Wrd_tVec_WrdReadTextOut (char *pFileName, int nOuts)
 
void Gia_ManReadSimInfoInputs (char *pFileName, char *pFileOut1, int fVerbose)
 
void Gia_ManReadSimInfoOutputs (char *pFileName, char *pFileOut, int nOuts)
 
Vec_Wrd_tVec_WrdZoneExtract (int ZoneSize, Vec_Wrd_t *p, int iWord, int nWords)
 
void Vec_WrdZoneInsert (Vec_Wrd_t *pNew, int ZoneSize, Vec_Wrd_t *p, int iWord, int nWords)
 
void Gia_ManSimInfoPrintOne (Gia_Man_t *p, Vec_Wrd_t *vSimsIn, Vec_Wrd_t *vSimsOut, int nWords, int nPats)
 
Vec_Wrd_tGia_ManSimInfoTryOne (Gia_Man_t *p, Vec_Wrd_t *vSimI, int fPrint)
 
int Gia_ManSimEvalOne (Gia_Man_t *p, Vec_Wrd_t *vSimO, Vec_Wrd_t *vSimO_new)
 
int Gia_ManSimEvalOne2 (Gia_Man_t *p, Vec_Wrd_t *vSimO, Vec_Wrd_t *vSimO_new)
 
int Gia_ManSimEvalMaxValue (Vec_Wrd_t *vSimO, int nWords, int nOuts, int nBits, int iPat)
 
int Gia_ManSimEvalOne3 (Gia_Man_t *p, Vec_Wrd_t *vSimO, Vec_Int_t *vValues, int nBits)
 
Vec_Wrd_tGia_ManSimInfoTry (Gia_Man_t *p, Vec_Wrd_t *vSimI)
 
int Gia_ManSimInfoEval_old (Gia_Man_t *p, Vec_Wrd_t *vSimO, Vec_Wrd_t *vSimO_new)
 
void Gia_ManSimInfoPassTest (Gia_Man_t *p, char *pFileName, char *pFileName2, int fVerbose)
 
void Gia_ManSimInfoEval (Gia_Man_t *p, char *pFileName, char *pFileName2, int nOuts, int fVerbose)
 
wordGia_ManCountFraction (Gia_Man_t *p, Vec_Wrd_t *vSimI, Vec_Int_t *vSupp, int Thresh, int fVerbose, int *pCare)
 
void Gia_ManPermuteSupp_rec (Gia_Man_t *p, int iObj, Vec_Int_t *vLevels, Vec_Int_t *vCounts)
 
void Gia_ManPermuteSupp (Gia_Man_t *p, int iOut, int nOuts, Vec_Int_t *vSupp)
 
void Gia_ManCollectSupp_rec (Gia_Man_t *p, int iObj, Vec_Int_t *vSupp)
 
Vec_Int_tGia_ManCollectSupp (Gia_Man_t *p, int iOut, int nOuts)
 
Vec_Int_tGia_ManCollectSuppNew (Gia_Man_t *p, int iOut, int nOuts)
 
int Gia_ManPerformLNetOpt_rec (Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj)
 
Gia_Man_tGia_ManPerformLNetOpt (Gia_Man_t *p, int fTryNew, char *pFileName, int nIns, int nOuts, int Thresh, int nRounds, int fVerbose)
 
Gia_Man_tGia_ManPerformLNetOptNew (Gia_Man_t *p, char *pFileName, int nIns, int nOuts, int Thresh, int nRounds, int fVerbose)
 
Abc_Ntk_tGia_ManPerformLNetMap (Gia_Man_t *p, int GroupSize, int fUseFixed, int fTryNew, int fVerbose)
 

Function Documentation

◆ Abc_NtkFromAigPhase()

ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Abc_NtkFromAigPhase ( Aig_Man_t * pMan)
extern

DECLARATIONS ///.

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

FileName [giaMinLut.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Collapsing AIG.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

Synopsis [Converts the network from the AIG manager into ABC.]

Description [This procedure should be called after seq sweeping, which changes the number of registers.]

SideEffects []

SeeAlso []

Definition at line 595 of file abcDar.c.

596{
597 Vec_Ptr_t * vNodes;
598 Abc_Ntk_t * pNtkNew;
599 Abc_Obj_t * pObjNew;
600 Aig_Obj_t * pObj, * pObjLo, * pObjLi;
601 int i;
602 assert( pMan->nAsserts == 0 );
603 // perform strashing
605 pNtkNew->nConstrs = pMan->nConstrs;
606 pNtkNew->nBarBufs = pMan->nBarBufs;
607 // duplicate the name and the spec
608// pNtkNew->pName = Extra_UtilStrsav(pMan->pName);
609// pNtkNew->pSpec = Extra_UtilStrsav(pMan->pSpec);
610 Aig_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew);
611 // create PIs
612 Aig_ManForEachPiSeq( pMan, pObj, i )
613 {
614 pObjNew = Abc_NtkCreatePi( pNtkNew );
615// Abc_ObjAssignName( pObjNew, Abc_ObjName(pObjNew), NULL );
616 pObj->pData = pObjNew;
617 }
618 // create POs
619 Aig_ManForEachPoSeq( pMan, pObj, i )
620 {
621 pObjNew = Abc_NtkCreatePo( pNtkNew );
622// Abc_ObjAssignName( pObjNew, Abc_ObjName(pObjNew), NULL );
623 pObj->pData = pObjNew;
624 }
625 assert( Abc_NtkCiNum(pNtkNew) == Aig_ManCiNum(pMan) - Aig_ManRegNum(pMan) );
626 assert( Abc_NtkCoNum(pNtkNew) == Aig_ManCoNum(pMan) - Aig_ManRegNum(pMan) );
627 // create as many latches as there are registers in the manager
628 Aig_ManForEachLiLoSeq( pMan, pObjLi, pObjLo, i )
629 {
630 pObjNew = Abc_NtkCreateLatch( pNtkNew );
631 pObjLi->pData = Abc_NtkCreateBi( pNtkNew );
632 pObjLo->pData = Abc_NtkCreateBo( pNtkNew );
633 Abc_ObjAddFanin( pObjNew, (Abc_Obj_t *)pObjLi->pData );
634 Abc_ObjAddFanin( (Abc_Obj_t *)pObjLo->pData, pObjNew );
635 Abc_LatchSetInit0( pObjNew );
636// Abc_ObjAssignName( (Abc_Obj_t *)pObjLi->pData, Abc_ObjName((Abc_Obj_t *)pObjLi->pData), NULL );
637// Abc_ObjAssignName( (Abc_Obj_t *)pObjLo->pData, Abc_ObjName((Abc_Obj_t *)pObjLo->pData), NULL );
638 }
639 // rebuild the AIG
640 vNodes = Aig_ManDfs( pMan, 1 );
641 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
642 if ( Aig_ObjIsBuf(pObj) )
643 pObj->pData = (Abc_Obj_t *)Aig_ObjChild0Copy(pObj);
644 else
645 pObj->pData = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
646 Vec_PtrFree( vNodes );
647 // connect the PO nodes
648 Aig_ManForEachCo( pMan, pObj, i )
649 {
650 pObjNew = (Abc_Obj_t *)Aig_ObjChild0Copy(pObj);
651 Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), pObjNew );
652 }
653
654 Abc_NtkAddDummyPiNames( pNtkNew );
655 Abc_NtkAddDummyPoNames( pNtkNew );
656 Abc_NtkAddDummyBoxNames( pNtkNew );
657
658 // check the resulting AIG
659 if ( !Abc_NtkCheck( pNtkNew ) )
660 Abc_Print( 1, "Abc_NtkFromAigPhase(): Network check has failed.\n" );
661 return pNtkNew;
662}
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
ABC_DLL void Abc_NtkAddDummyBoxNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:547
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
struct Abc_Aig_t_ Abc_Aig_t
Definition abc.h:117
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
@ ABC_NTK_STRASH
Definition abc.h:58
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:521
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:700
@ ABC_FUNC_AIG
Definition abc.h:67
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:495
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition aig.h:438
#define Aig_ManForEachCo(p, pObj, i)
Definition aig.h:398
Vec_Ptr_t * Aig_ManDfs(Aig_Man_t *p, int fNodesOnly)
Definition aigDfs.c:145
#define Aig_ManForEachPoSeq(p, pObj, i)
Definition aig.h:444
#define Aig_ManForEachLiLoSeq(p, pObjLi, pObjLo, k)
Definition aig.h:450
int nBarBufs
Definition abc.h:174
int nConstrs
Definition abc.h:173
void * pManFunc
Definition abc.h:191
void * pData
Definition aig.h:87
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCollectSupp()

Vec_Int_t * Gia_ManCollectSupp ( Gia_Man_t * p,
int iOut,
int nOuts )

Definition at line 624 of file giaMinLut.c.

625{
626 Vec_Int_t * vSupp = Vec_IntAlloc( 16 ); int i;
628 for ( i = 0; i < nOuts; i++ )
629 Gia_ManCollectSupp_rec( p, Gia_ObjFaninId0p(p, Gia_ManCo(p, iOut+i)), vSupp );
630 return vSupp;
631}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
void Gia_ManCollectSupp_rec(Gia_Man_t *p, int iObj, Vec_Int_t *vSupp)
Definition giaMinLut.c:607
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCollectSupp_rec()

void Gia_ManCollectSupp_rec ( Gia_Man_t * p,
int iObj,
Vec_Int_t * vSupp )

Definition at line 607 of file giaMinLut.c.

608{
609 Gia_Obj_t * pObj;
610 if ( !iObj || Gia_ObjIsTravIdCurrentId(p, iObj) )
611 return;
612 Gia_ObjSetTravIdCurrentId(p, iObj);
613 pObj = Gia_ManObj( p, iObj );
614 if ( Gia_ObjIsCi(pObj) )
615 {
616 //Vec_IntPush( vSupp, Gia_ObjCioId(pObj) );
617 Vec_IntPush( vSupp, Gia_ObjId(p, pObj) );
618 return;
619 }
620 assert( Gia_ObjIsAnd(pObj) );
621 Gia_ManCollectSupp_rec( p, Gia_ObjFaninId0(pObj, iObj), vSupp );
622 Gia_ManCollectSupp_rec( p, Gia_ObjFaninId1(pObj, iObj), vSupp );
623}
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCollectSuppNew()

Vec_Int_t * Gia_ManCollectSuppNew ( Gia_Man_t * p,
int iOut,
int nOuts )

Definition at line 632 of file giaMinLut.c.

633{
634 Vec_Int_t * vRes = Gia_ManCollectSupp( p, iOut, nOuts );
635 Gia_ManPermuteSupp( p, iOut, nOuts, vRes );
636 return vRes;
637}
Vec_Int_t * Gia_ManCollectSupp(Gia_Man_t *p, int iOut, int nOuts)
Definition giaMinLut.c:624
void Gia_ManPermuteSupp(Gia_Man_t *p, int iOut, int nOuts, Vec_Int_t *vSupp)
Definition giaMinLut.c:590
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCountFraction()

word * Gia_ManCountFraction ( Gia_Man_t * p,
Vec_Wrd_t * vSimI,
Vec_Int_t * vSupp,
int Thresh,
int fVerbose,
int * pCare )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 531 of file giaMinLut.c.

532{
533 Gia_Obj_t * pObj;
534 int i, k, nUsed = 0, nGood = 0;
535 int nWords = Vec_WrdSize(vSimI) / Gia_ManCiNum(p);
536 int nMints = 1 << Vec_IntSize(vSupp);
537 word ** pSims = ABC_ALLOC( word *, Vec_IntSize(vSupp) );
538 word * pRes = ABC_CALLOC( word, Abc_Truth6WordNum(Vec_IntSize(vSupp)) );
539 int * pCounts = ABC_CALLOC( int, nMints );
540 Gia_ManForEachObjVec( vSupp, p, pObj, i )
541 pSims[i] = Vec_WrdEntryP( vSimI, Gia_ObjCioId(pObj) * nWords );
542 for ( k = 0; k < 64*nWords; k++ )
543 {
544 int iMint = 0;
545 for ( i = 0; i < Vec_IntSize(vSupp); i++ )
546 if ( Abc_TtGetBit(pSims[i], k) )
547 iMint |= 1 << i;
548 assert( iMint < nMints );
549 pCounts[iMint]++;
550 }
551 for ( k = 0; k < nMints; k++ )
552 {
553 nUsed += (pCounts[k] > 0);
554 nGood += (pCounts[k] >= Thresh);
555 if ( pCounts[k] >= Thresh )
556 Abc_TtXorBit( pRes, k );
557 //printf( "%d ", pCounts[k] );
558 }
559 if ( Vec_IntSize(vSupp) < 6 )
560 pRes[0] = Abc_Tt6Stretch( pRes[0], Vec_IntSize(vSupp) );
561 //printf( "\n" );
562 if ( fVerbose )
563 printf( "Used %4d and good %4d (out of %4d).\n", nUsed, nGood, nMints );
564 ABC_FREE( pSims );
565 ABC_FREE( pCounts );
566 *pCare = nGood;
567 return pRes;
568}
int nWords
Definition abcNpn.c:127
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
int nGood
Definition abcCut.c:34
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition gia.h:1194
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
Here is the caller graph for this function:

◆ Gia_ManPerformLNetMap()

Abc_Ntk_t * Gia_ManPerformLNetMap ( Gia_Man_t * p,
int GroupSize,
int fUseFixed,
int fTryNew,
int fVerbose )

Definition at line 1045 of file giaMinLut.c.

1046{
1047 return NULL;
1048}

◆ Gia_ManPerformLNetOpt()

Gia_Man_t * Gia_ManPerformLNetOpt ( Gia_Man_t * p,
int fTryNew,
char * pFileName,
int nIns,
int nOuts,
int Thresh,
int nRounds,
int fVerbose )

Definition at line 647 of file giaMinLut.c.

648{
649 extern Gia_Man_t * Gia_TryPermOpt( word * pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose );
650 extern Gia_Man_t * Gia_TryPermOptCare( word * pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose );
651 extern int Kit_TruthToGia2( Gia_Man_t * p, unsigned * pTruth0, unsigned * pTruth1, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
652 abctime clk = Abc_Clock();
653 Gia_Man_t * pNew; Gia_Obj_t * pObj;
654 Vec_Int_t * vMemory = Vec_IntAlloc( 1 << 18 );
655 Vec_Int_t * vLeaves = Vec_IntAlloc( nIns );
656 Vec_Wrd_t * vSimI = pFileName ? Vec_WrdReadBin( pFileName, fVerbose ) : NULL;
657 word * pTruth0 = ABC_CALLOC( word, Abc_Truth6WordNum(nIns) );
658 word * pTruth1 = ABC_CALLOC( word, Abc_Truth6WordNum(nIns) ); int g, k; float CareAve = 0;
659 word * pTruthsTry = ABC_CALLOC( word, 2*nOuts*Abc_Truth6WordNum(nIns) );
660 if ( vSimI && fVerbose )
661 {
662 //int nPats = 64*Vec_WrdSize(vSimI)/Gia_ManCiNum(p);
663 printf( "Density of input patterns %8.4f.\n", (float)Abc_TtCountOnesVec(Vec_WrdArray(vSimI), Vec_WrdSize(vSimI))/(64*Vec_WrdSize(vSimI)) );
664 printf( "Using patterns with count %d and higher as cares.\n", Thresh );
665 }
668 pNew = Gia_ManStart( Gia_ManObjNum(p) );
669 pNew->pName = Abc_UtilStrsav( p->pName );
670 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
671 Gia_ManConst0(p)->Value = 0;
672 Gia_ManForEachCi( p, pObj, k )
673 pObj->Value = Gia_ManAppendCi(pNew);
675 Gia_ManHashStart( pNew );
676 for ( g = 0; g < Gia_ManCoNum(p); g += nOuts )
677 {
678 Vec_Int_t * vSupp = Gia_ManCollectSuppNew( p, g, nOuts );
679 int Care = 1 << Vec_IntSize(vSupp), Temp = fVerbose ? printf( "Group %3d / %3d / %3d : Supp = %3d %s", g, nOuts, Gia_ManCoNum(p), Vec_IntSize(vSupp), vSimI ? "":"\n" ) : 0;
680 word * pCare = vSimI ? Gia_ManCountFraction( p, vSimI, vSupp, Thresh, fVerbose, &Care ) : ABC_FALLOC( word, Abc_Truth6WordNum(Vec_IntSize(vSupp)) );
681 int nWords = Abc_Truth6WordNum( Vec_IntSize(vSupp) );
682 CareAve += 100.0*Care/(1 << Vec_IntSize(vSupp));
683 assert( Vec_IntSize(vSupp) <= nIns );
684 Vec_IntClear( vLeaves );
685 Gia_ManForEachObjVec( vSupp, p, pObj, k )
686 Vec_IntPush( vLeaves, pObj->Value );
687 for ( k = 0; k < nOuts; k++ )
688 {
689 Gia_Obj_t * pObj = Gia_ManCo( p, g+k );
690 word * pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ObjFanin0(pObj), vSupp );
691 Abc_TtSharp( pTruth0, pCare, pTruth, nWords );
692 Abc_TtAnd( pTruth1, pCare, pTruth, nWords, 0 );
693 if ( vSimI )
694 {
695 Abc_TtCopy( pTruthsTry + (2*k+0)*nWords, pTruth1, nWords, 0 );
696 Abc_TtCopy( pTruthsTry + (2*k+1)*nWords, pTruth0, nWords, 0 );
697 }
698 else
699 Abc_TtCopy( pTruthsTry + k*nWords, pTruth1, nWords, 0 );
700 if ( !fTryNew )
701 {
702 pObj->Value = Kit_TruthToGia2( pNew, (unsigned *)pTruth0, (unsigned *)pTruth1, Vec_IntSize(vLeaves), vMemory, vLeaves, 1 );
703 pObj->Value ^= Gia_ObjFaninC0(pObj);
704 }
705 }
706 if ( fTryNew )
707 {
708 Gia_Man_t * pMin;
709 if ( vSimI )
710 pMin = Gia_TryPermOpt( pTruthsTry, Vec_IntSize(vSupp), 2*nOuts, nWords, nRounds, fVerbose );
711 else
712 pMin = Gia_TryPermOptCare( pTruthsTry, Vec_IntSize(vSupp), nOuts, nWords, nRounds, fVerbose );
713 Gia_ManFillValue( pMin );
714 Gia_ManConst0(pMin)->Value = 0;
715 Gia_ManForEachCi( pMin, pObj, k )
716 pObj->Value = Vec_IntEntry( vLeaves, k );
717 for ( k = 0; k < nOuts; k++ )
718 {
719 Gia_Obj_t * pObj = Gia_ManCo( p, g+k );
720 Gia_Obj_t * pObj2 = Gia_ManCo( pMin, k );
721 pObj->Value = Gia_ManPerformLNetOpt_rec( pNew, pMin, Gia_ObjFanin0(pObj2) );
722 pObj->Value ^= Gia_ObjFaninC0(pObj2);
723 pObj->Value ^= Gia_ObjFaninC0(pObj);
724 }
725 Gia_ManStop( pMin );
726 }
727 ABC_FREE( pCare );
728 Vec_IntFree( vSupp );
729 Temp = 0;
730 }
731 CareAve /= Gia_ManCoNum(p)/nOuts;
732 Gia_ManHashStop( pNew );
733 Gia_ManForEachCo( p, pObj, k )
734 pObj->Value = Gia_ManAppendCo( pNew, pObj->Value );
736 ABC_FREE( pTruth0 );
737 ABC_FREE( pTruth1 );
738 Vec_IntFree( vLeaves );
739 Vec_IntFree( vMemory );
740 Vec_WrdFreeP( &vSimI );
741 Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
742 printf( "Using patterns with count %d and higher as cares. Average care set is %8.4f %%. ", Thresh, CareAve );
743 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
744 if ( 0 )
745 {
746 FILE * pTable = fopen( "stats.txt", "a+" );
747 fprintf( pTable, "%0.2f ", CareAve );
748 fclose( pTable );
749 }
750 ABC_FREE( pTruthsTry );
751 return pNew;
752}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_FALLOC(type, num)
Definition abc_global.h:266
Gia_Man_t * Gia_TryPermOpt(word *pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose)
Gia_Man_t * Gia_TryPermOptCare(word *pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose)
Vec_Int_t * Gia_ManCollectSuppNew(Gia_Man_t *p, int iOut, int nOuts)
Definition giaMinLut.c:632
word * Gia_ManCountFraction(Gia_Man_t *p, Vec_Wrd_t *vSimI, Vec_Int_t *vSupp, int Thresh, int fVerbose, int *pCare)
Definition giaMinLut.c:531
int Gia_ManPerformLNetOpt_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj)
Definition giaMinLut.c:638
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
word * Gia_ObjComputeTruthTableCut(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vLeaves)
Definition giaTruth.c:628
void Gia_ManHashStart(Gia_Man_t *p)
Definition giaHash.c:125
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition giaMan.c:764
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
void Gia_ManFillValue(Gia_Man_t *p)
Definition giaUtil.c:369
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
void Gia_ObjComputeTruthTableStart(Gia_Man_t *p, int nVarsMax)
Definition giaTruth.c:552
void Gia_ObjComputeTruthTableStop(Gia_Man_t *p)
Definition giaTruth.c:568
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
#define Gia_ManForEachCi(p, pObj, i)
Definition gia.h:1228
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
int Gia_ManLevelNum(Gia_Man_t *p)
Definition giaUtil.c:546
int Kit_TruthToGia2(Gia_Man_t *pMan, unsigned *pTruth0, unsigned *pTruth1, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
Definition kitHop.c:103
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
unsigned Value
Definition gia.h:89
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition vecWrd.h:42
Here is the call graph for this function:

◆ Gia_ManPerformLNetOpt_rec()

int Gia_ManPerformLNetOpt_rec ( Gia_Man_t * pNew,
Gia_Man_t * p,
Gia_Obj_t * pObj )

Definition at line 638 of file giaMinLut.c.

639{
640 if ( ~pObj->Value )
641 return pObj->Value;
642 assert( Gia_ObjIsAnd(pObj) );
643 Gia_ManPerformLNetOpt_rec( pNew, p, Gia_ObjFanin0(pObj) );
644 Gia_ManPerformLNetOpt_rec( pNew, p, Gia_ObjFanin1(pObj) );
645 return pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
646}
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManPerformLNetOptNew()

Gia_Man_t * Gia_ManPerformLNetOptNew ( Gia_Man_t * p,
char * pFileName,
int nIns,
int nOuts,
int Thresh,
int nRounds,
int fVerbose )

Definition at line 753 of file giaMinLut.c.

754{
755 extern Gia_Man_t * Gia_TryPermOptNew( word * pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose );
756 abctime clk = Abc_Clock();
757 Gia_Man_t * pNew, * pMin; Gia_Obj_t * pObj;
758 Vec_Int_t * vLeaves = Vec_IntAlloc( nIns );
759 Vec_Wrd_t * vSimI = pFileName ? Vec_WrdReadBin( pFileName, fVerbose ) : NULL;
760 word * pTruthsTry = ABC_CALLOC( word, (nOuts+1)*Abc_Truth6WordNum(nIns) );
761 int k, g; float CareAve = 0;
762 if ( vSimI && fVerbose )
763 {
764 //int nPats = 64*Vec_WrdSize(vSimI)/Gia_ManCiNum(p);
765 printf( "Density of input patterns %8.4f.\n", (float)Abc_TtCountOnesVec(Vec_WrdArray(vSimI), Vec_WrdSize(vSimI))/(64*Vec_WrdSize(vSimI)) );
766 printf( "Using patterns with count %d and higher as cares.\n", Thresh );
767 }
770 pNew = Gia_ManStart( Gia_ManObjNum(p) );
771 pNew->pName = Abc_UtilStrsav( p->pName );
772 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
773 Gia_ManConst0(p)->Value = 0;
774 Gia_ManForEachCi( p, pObj, k )
775 pObj->Value = Gia_ManAppendCi(pNew);
777 Gia_ManHashStart( pNew );
778 for ( g = 0; g < Gia_ManCoNum(p); g += nOuts )
779 {
780 for ( k = 0; k < nOuts; k++ )
781 if ( Gia_ObjIsAnd(Gia_ObjFanin0(Gia_ManCo( p, g+k ))) )
782 break;
783 if ( k == nOuts )
784 {
785 for ( k = 0; k < nOuts; k++ )
786 {
787 Gia_Obj_t * pObj = Gia_ManCo( p, g+k );
788 pObj->Value = Gia_ObjFanin0Copy(pObj);
789 }
790 continue;
791 }
792 else
793 {
794
795 Vec_Int_t * vSupp = Gia_ManCollectSuppNew( p, g, nOuts );
796 int Care = 1 << Vec_IntSize(vSupp), Temp = fVerbose ? printf( "Group %3d / %3d / %3d : Supp = %3d %s", g, nOuts, Gia_ManCoNum(p), Vec_IntSize(vSupp), vSimI ? "":"\n" ) : 0;
797 word * pCare = vSimI ? Gia_ManCountFraction( p, vSimI, vSupp, Thresh, fVerbose, &Care ) : ABC_FALLOC( word, Abc_Truth6WordNum(Vec_IntSize(vSupp)) );
798 int nWords = Abc_Truth6WordNum( Vec_IntSize(vSupp) );
799 CareAve += 100.0*Care/(1 << Vec_IntSize(vSupp));
800 assert( Vec_IntSize(vSupp) <= nIns );
801 Vec_IntClear( vLeaves );
802 Gia_ManForEachObjVec( vSupp, p, pObj, k )
803 Vec_IntPush( vLeaves, pObj->Value );
804 for ( k = 0; k < nOuts; k++ )
805 {
806 Gia_Obj_t * pObj = Gia_ManCo( p, g+k );
807 word * pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ObjFanin0(pObj), vSupp );
808 Abc_TtCopy( pTruthsTry + k*nWords, pTruth, nWords, Gia_ObjFaninC0(pObj) );
809 }
810 Abc_TtCopy( pTruthsTry + nOuts*nWords, pCare, nWords, 0 );
811 ABC_FREE( pCare );
812 pMin = Gia_TryPermOptNew( pTruthsTry, Vec_IntSize(vSupp), nOuts, nWords, nRounds, fVerbose );
813 Gia_ManFillValue( pMin );
814 Gia_ManConst0(pMin)->Value = 0;
815 Gia_ManForEachCi( pMin, pObj, k )
816 pObj->Value = Vec_IntEntry( vLeaves, k );
817 Gia_ManForEachCo( pMin, pObj, k )
818 {
819 Gia_Obj_t * pObj0 = Gia_ManCo( p, g+k );
820 pObj0->Value = Gia_ManPerformLNetOpt_rec( pNew, pMin, Gia_ObjFanin0(pObj) );
821 pObj0->Value ^= Gia_ObjFaninC0(pObj);
822 }
823 Gia_ManStop( pMin );
824 Vec_IntFree( vSupp );
825 Temp = 0;
826
827 }
828 }
829 CareAve /= Gia_ManCoNum(p)/nOuts;
830 Gia_ManHashStop( pNew );
831 Gia_ManForEachCo( p, pObj, k )
832 pObj->Value = Gia_ManAppendCo( pNew, pObj->Value );
834 Vec_IntFree( vLeaves );
835 Vec_WrdFreeP( &vSimI );
836 Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
837 printf( "Using patterns with count %d and higher as cares. Average care set is %8.4f %%. ", Thresh, CareAve );
838 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
839 if ( 0 )
840 {
841 FILE * pTable = fopen( "stats.txt", "a+" );
842 fprintf( pTable, "%0.2f ", CareAve );
843 fclose( pTable );
844 }
845 ABC_FREE( pTruthsTry );
846 return pNew;
847}
Gia_Man_t * Gia_TryPermOptNew(word *pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose)
Here is the call graph for this function:

◆ Gia_ManPermuteSupp()

void Gia_ManPermuteSupp ( Gia_Man_t * p,
int iOut,
int nOuts,
Vec_Int_t * vSupp )

Definition at line 590 of file giaMinLut.c.

591{
592 Vec_Int_t * vLevels = Vec_IntStart( Gia_ManCiNum(p) );
593 Vec_Int_t * vCounts = Vec_IntStart( Gia_ManCiNum(p) );
594 int i, * pCost = ABC_CALLOC( int, Gia_ManCiNum(p) );
595 Gia_Obj_t * pObj;
597 for ( i = 0; i < nOuts; i++ )
598 Gia_ManPermuteSupp_rec( p, Gia_ObjFaninId0p(p, Gia_ManCo(p, iOut+i)), vLevels, vCounts );
599 Gia_ManForEachObjVec( vSupp, p, pObj, i )
600 pCost[i] = 10000 * Vec_IntEntry(vLevels, Gia_ObjCioId(pObj)) / Abc_MaxInt(1, Vec_IntEntry(vCounts, Gia_ObjCioId(pObj)));
601 Vec_IntFree( vCounts );
602 Vec_IntFree( vLevels );
603 Vec_IntSelectSortCost2( Vec_IntArray(vSupp), Vec_IntSize(vSupp), pCost );
604 assert( Vec_IntSize(vSupp) < 2 || pCost[0] <= pCost[1] );
605 ABC_FREE( pCost );
606}
void Gia_ManPermuteSupp_rec(Gia_Man_t *p, int iObj, Vec_Int_t *vLevels, Vec_Int_t *vCounts)
Definition giaMinLut.c:569
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManPermuteSupp_rec()

void Gia_ManPermuteSupp_rec ( Gia_Man_t * p,
int iObj,
Vec_Int_t * vLevels,
Vec_Int_t * vCounts )

Definition at line 569 of file giaMinLut.c.

570{
571 Gia_Obj_t * pObj; int n;
572 if ( !iObj || Gia_ObjIsTravIdCurrentId(p, iObj) )
573 return;
574 Gia_ObjSetTravIdCurrentId(p, iObj);
575 pObj = Gia_ManObj( p, iObj );
576 if ( Gia_ObjIsCi(pObj) )
577 return;
578 assert( Gia_ObjIsAnd(pObj) );
579 Gia_ManPermuteSupp_rec( p, Gia_ObjFaninId0(pObj, iObj), vLevels, vCounts );
580 Gia_ManPermuteSupp_rec( p, Gia_ObjFaninId1(pObj, iObj), vLevels, vCounts );
581 for ( n = 0; n < 2; n++ )
582 {
583 Gia_Obj_t * pFanin = n ? Gia_ObjFanin1(pObj) : Gia_ObjFanin0(pObj);
584 if ( !Gia_ObjIsCi(pFanin) )
585 continue;
586 Vec_IntAddToEntry( vLevels, Gia_ObjCioId(pFanin), Gia_ObjLevel(p, pObj) );
587 Vec_IntAddToEntry( vCounts, Gia_ObjCioId(pFanin), 1 );
588 }
589}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManReadSimInfoInputs()

void Gia_ManReadSimInfoInputs ( char * pFileName,
char * pFileOut1,
int fVerbose )

Definition at line 308 of file giaMinLut.c.

309{
310 Vec_Wrd_t * vSimI;
311 Vec_WrdReadText2( pFileName, &vSimI );
312 Vec_WrdDumpBin( pFileOut1, vSimI, fVerbose );
313 Vec_WrdFree( vSimI );
314}
int Vec_WrdReadText2(char *pFileName, Vec_Wrd_t **pvSimI)
Definition giaMinLut.c:233
Here is the call graph for this function:

◆ Gia_ManReadSimInfoOutputs()

void Gia_ManReadSimInfoOutputs ( char * pFileName,
char * pFileOut,
int nOuts )

Definition at line 315 of file giaMinLut.c.

316{
317 Vec_Wrd_t * vSimO = Vec_WrdReadTextOut( pFileName, nOuts );
318 Vec_WrdDumpBin( pFileOut, vSimO, 1 );
319 Vec_WrdFree( vSimO );
320}
Vec_Wrd_t * Vec_WrdReadTextOut(char *pFileName, int nOuts)
Definition giaMinLut.c:292
Here is the call graph for this function:

◆ Gia_ManSimEvalMaxValue()

int Gia_ManSimEvalMaxValue ( Vec_Wrd_t * vSimO,
int nWords,
int nOuts,
int nBits,
int iPat )

Definition at line 422 of file giaMinLut.c.

423{
424 int o, ValueMax = -1, OutMax = -1;
425 for ( o = 0; o < nOuts; o++ )
426 {
427 int i, Value = 0;
428 for ( i = 0; i < nBits; i++ )
429 {
430 word * pSim = Vec_WrdEntryP( vSimO, (o*nBits+i) * nWords );
431 if ( Abc_TtGetBit(pSim, iPat) )
432 Value |= 1 << i;
433 }
434 if ( ValueMax <= Value )
435 {
436 ValueMax = Value;
437 OutMax = o;
438 }
439 }
440 return OutMax;
441}
Here is the caller graph for this function:

◆ Gia_ManSimEvalOne()

int Gia_ManSimEvalOne ( Gia_Man_t * p,
Vec_Wrd_t * vSimO,
Vec_Wrd_t * vSimO_new )

Definition at line 388 of file giaMinLut.c.

389{
390 int i, Count = 0, nWords = Vec_WrdSize(vSimO) / Gia_ManCoNum(p);
391 word * pSim0 = ABC_CALLOC( word, nWords );
392 assert( Vec_WrdSize(vSimO) == Vec_WrdSize(vSimO_new) );
393 for ( i = 0; i < Gia_ManCoNum(p); i++ )
394 {
395 word * pSimGold = Vec_WrdEntryP( vSimO, i * nWords );
396 word * pSimImpl = Vec_WrdEntryP( vSimO_new, i * nWords );
397 Abc_TtOrXor( pSim0, pSimImpl, pSimGold, nWords );
398 }
399 Count = Abc_TtCountOnesVec( pSim0, nWords );
400 printf( "Number of failed patterns is %d (%8.4f %% of %d). The first one is %d.\n",
401 Count, 100.0*Count/(64*nWords), 64*nWords, Abc_TtFindFirstBit2(pSim0, nWords) );
402 ABC_FREE( pSim0 );
403 return Count;
404}

◆ Gia_ManSimEvalOne2()

int Gia_ManSimEvalOne2 ( Gia_Man_t * p,
Vec_Wrd_t * vSimO,
Vec_Wrd_t * vSimO_new )

Definition at line 405 of file giaMinLut.c.

406{
407 int i, Count = 0, nWords = Vec_WrdSize(vSimO) / Gia_ManCoNum(p);
408 word * pSim0 = ABC_CALLOC( word, nWords );
409 assert( Vec_WrdSize(vSimO) == Vec_WrdSize(vSimO_new) );
410 for ( i = 0; i < Gia_ManCoNum(p); i++ )
411 {
412 word * pSimGold = Vec_WrdEntryP( vSimO, i * nWords );
413 word * pSimImpl = Vec_WrdEntryP( vSimO_new, i * nWords );
414 Abc_TtXor( pSim0, pSimImpl, pSimGold, nWords, 0 );
415 Count += Abc_TtCountOnesVec( pSim0, nWords );
416 }
417 printf( "Number of failed patterns is %d (%8.4f %% of %d). The first one is %d.\n",
418 Count, 100.0*Count/(64*nWords*Gia_ManCoNum(p)), 64*nWords*Gia_ManCoNum(p), Abc_TtFindFirstBit2(pSim0, nWords) );
419 ABC_FREE( pSim0 );
420 return Count;
421}
Here is the caller graph for this function:

◆ Gia_ManSimEvalOne3()

int Gia_ManSimEvalOne3 ( Gia_Man_t * p,
Vec_Wrd_t * vSimO,
Vec_Int_t * vValues,
int nBits )

Definition at line 442 of file giaMinLut.c.

443{
444 int i, Value, nOuts = Gia_ManCoNum(p) / nBits;
445 int First = -1, Count = 0, nWords = Vec_WrdSize(vSimO) / Gia_ManCoNum(p);
446 assert( Gia_ManCoNum(p) % nBits == 0 );
447 assert( 64*(nWords-1) < Vec_IntSize(vValues) && Vec_IntSize(vValues) <= 64*nWords );
448 Vec_IntForEachEntry( vValues, Value, i )
449 if ( Value == Gia_ManSimEvalMaxValue(vSimO, nWords, nOuts, nBits, i) )
450 {
451 Count++;
452 if ( First == -1 )
453 First = i;
454 }
455 printf( "The accuracy is %8.4f %% (%d out of %d output are correct, for example, output number %d).\n",
456 100.0*Count/Vec_IntSize(vValues), Count, Vec_IntSize(vValues), First );
457 if ( 0 )
458 {
459 FILE * pTable = fopen( "stats.txt", "a+" );
460 fprintf( pTable, "%0.2f \n", 100.0*Count/Vec_IntSize(vValues) );
461 fclose( pTable );
462 }
463 return Count;
464}
int Gia_ManSimEvalMaxValue(Vec_Wrd_t *vSimO, int nWords, int nOuts, int nBits, int iPat)
Definition giaMinLut.c:422
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSimInfoEval()

void Gia_ManSimInfoEval ( Gia_Man_t * p,
char * pFileName,
char * pFileName2,
int nOuts,
int fVerbose )

Definition at line 505 of file giaMinLut.c.

506{
507 abctime clk = Abc_Clock();
508 Vec_Wrd_t * vSim1 = Vec_WrdReadBin( pFileName, fVerbose );
509 Vec_Int_t * vNums = Vec_WrdReadNumsOut( pFileName2, fVerbose );
510 assert( nOuts > 0 );
511 if ( fVerbose )
512 printf( "Density of input patterns %8.4f.\n", (float)Abc_TtCountOnesVec(Vec_WrdArray(vSim1), Vec_WrdSize(vSim1))/(64*Vec_WrdSize(vSim1)) );
513 Gia_ManSimEvalOne3( p, vSim1, vNums, nOuts );
514 Vec_WrdFree( vSim1 );
515 Vec_IntFree( vNums );
516 if ( fVerbose )
517 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
518}
Vec_Int_t * Vec_WrdReadNumsOut(char *pFileName, int fVerbose)
Definition giaMinLut.c:274
int Gia_ManSimEvalOne3(Gia_Man_t *p, Vec_Wrd_t *vSimO, Vec_Int_t *vValues, int nBits)
Definition giaMinLut.c:442
Here is the call graph for this function:

◆ Gia_ManSimInfoEval_old()

int Gia_ManSimInfoEval_old ( Gia_Man_t * p,
Vec_Wrd_t * vSimO,
Vec_Wrd_t * vSimO_new )

Definition at line 482 of file giaMinLut.c.

483{
484 int nResult = Gia_ManSimEvalOne2(p, vSimO, vSimO_new);
485 //Vec_WrdDumpBin( "temp.simo", vSimO_new, 1 );
486 printf( "Total errors = %d. ", nResult );
487 printf( "Density of output patterns %8.4f.\n", (float)Abc_TtCountOnesVec(Vec_WrdArray(vSimO_new), Vec_WrdSize(vSimO_new))/(64*Vec_WrdSize(vSimO_new)) );
488 return nResult;
489}
int Gia_ManSimEvalOne2(Gia_Man_t *p, Vec_Wrd_t *vSimO, Vec_Wrd_t *vSimO_new)
Definition giaMinLut.c:405
Here is the call graph for this function:

◆ Gia_ManSimInfoPassTest()

void Gia_ManSimInfoPassTest ( Gia_Man_t * p,
char * pFileName,
char * pFileName2,
int fVerbose )

Definition at line 490 of file giaMinLut.c.

491{
492 abctime clk = Abc_Clock();
493 Vec_Wrd_t * vSimI = Vec_WrdReadBin( pFileName, fVerbose );
494 Vec_Wrd_t * vSimO = Gia_ManSimInfoTry( p, vSimI );
495 if ( fVerbose )
496 printf( "Density of input patterns %8.4f.\n", (float)Abc_TtCountOnesVec(Vec_WrdArray(vSimI), Vec_WrdSize(vSimI))/(64*Vec_WrdSize(vSimI)) );
497 if ( fVerbose )
498 printf( "Density of output patterns %8.4f.\n", (float)Abc_TtCountOnesVec(Vec_WrdArray(vSimO), Vec_WrdSize(vSimO))/(64*Vec_WrdSize(vSimO)) );
499 Vec_WrdDumpBin( pFileName2, vSimO, fVerbose );
500 Vec_WrdFree( vSimI );
501 Vec_WrdFree( vSimO );
502 if ( fVerbose )
503 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
504}
Vec_Wrd_t * Gia_ManSimInfoTry(Gia_Man_t *p, Vec_Wrd_t *vSimI)
Definition giaMinLut.c:465
Here is the call graph for this function:

◆ Gia_ManSimInfoPrintOne()

void Gia_ManSimInfoPrintOne ( Gia_Man_t * p,
Vec_Wrd_t * vSimsIn,
Vec_Wrd_t * vSimsOut,
int nWords,
int nPats )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 363 of file giaMinLut.c.

364{
365 int Id, i, k;
366 for ( k = 0; k < nPats; k++ )
367 {
368 Gia_ManForEachCiId( p, Id, i )
369 // printf( "%d", Vec_WrdEntry(p->vSims, p->nSimWords*Id) & 1 );
370 printf( "%d", (int)(Vec_WrdEntry(vSimsIn, nWords*i) >> k) & 1 );
371 printf( " " );
372 Gia_ManForEachCoId( p, Id, i )
373 // printf( "%d", Vec_WrdEntry(p->vSims, p->nSimWords*Id) & 1 );
374 printf( "%d", (int)(Vec_WrdEntry(vSimsOut, nWords*i) >> k) & 1 );
375 printf( "\n" );
376 }
377}
#define Gia_ManForEachCoId(p, Id, i)
Definition gia.h:1240
#define Gia_ManForEachCiId(p, Id, i)
Definition gia.h:1230
Here is the caller graph for this function:

◆ Gia_ManSimInfoTry()

Vec_Wrd_t * Gia_ManSimInfoTry ( Gia_Man_t * p,
Vec_Wrd_t * vSimI )

Definition at line 465 of file giaMinLut.c.

466{
467 int nWords = Vec_WrdSize(vSimI) / Gia_ManCiNum(p);
468 int w, nWordsOne = 200, nWordBatches = (nWords + nWordsOne - 1)/nWordsOne;
469 Vec_Wrd_t * vSimO_new = Vec_WrdStart( nWords * Gia_ManCoNum(p) );
470 for ( w = 0; w < nWordBatches; w++ )
471 {
472 //int Value = printf( "%3d / %3d : ", w, nWordBatches );
473 Vec_Wrd_t * vSimI_ = Vec_WrdZoneExtract( nWords, vSimI, w*nWordsOne, nWordsOne );
474 Vec_Wrd_t * vSimO_ = Gia_ManSimInfoTryOne( p, vSimI_, 0 );
475 Vec_WrdZoneInsert( vSimO_new, nWords, vSimO_, w*nWordsOne, nWordsOne );
476 Vec_WrdFree( vSimI_ );
477 Vec_WrdFree( vSimO_ );
478 //Value = 0;
479 }
480 return vSimO_new;
481}
void Vec_WrdZoneInsert(Vec_Wrd_t *pNew, int ZoneSize, Vec_Wrd_t *p, int iWord, int nWords)
Definition giaMinLut.c:343
Vec_Wrd_t * Gia_ManSimInfoTryOne(Gia_Man_t *p, Vec_Wrd_t *vSimI, int fPrint)
Definition giaMinLut.c:378
Vec_Wrd_t * Vec_WrdZoneExtract(int ZoneSize, Vec_Wrd_t *p, int iWord, int nWords)
Definition giaMinLut.c:333
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSimInfoTryOne()

Vec_Wrd_t * Gia_ManSimInfoTryOne ( Gia_Man_t * p,
Vec_Wrd_t * vSimI,
int fPrint )

Definition at line 378 of file giaMinLut.c.

379{
380 extern Vec_Wrd_t * Gia_ManSimulateWordsOut( Gia_Man_t * p, Vec_Wrd_t * vSimsIn );
381 Vec_Wrd_t * vSimsOut = Gia_ManSimulateWordsOut( p, vSimI );
382 int nWords = Vec_WrdSize(vSimI) / Gia_ManCiNum(p);
383 assert( Vec_WrdSize(vSimI) % Gia_ManCiNum(p) == 0 );
384 if ( fPrint )
385 Gia_ManSimInfoPrintOne( p, vSimI, vSimsOut, nWords, 6 );
386 return vSimsOut;
387}
Vec_Wrd_t * Gia_ManSimulateWordsOut(Gia_Man_t *p, Vec_Wrd_t *vSimsIn)
Definition giaGen.c:198
void Gia_ManSimInfoPrintOne(Gia_Man_t *p, Vec_Wrd_t *vSimsIn, Vec_Wrd_t *vSimsOut, int nWords, int nPats)
Definition giaMinLut.c:363
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Vec_WrdReadLayerText()

Vec_Wec_t * Vec_WrdReadLayerText ( char * pFileName,
int * pnIns,
int * pnOuts )

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 54 of file giaMinLut.c.

55{
56 char * pThis, pLine[1000];
57 Vec_Wec_t * vRes; int iLine;
58 FILE * pFile = fopen( pFileName, "rb" );
59 if ( pFile == NULL )
60 {
61 printf( "Cannot open file \"%s\" for reading.\n", pFileName );
62 return NULL;
63 }
64 vRes = Vec_WecAlloc(100);
65 for ( iLine = 0; fgets( pLine, 1000, pFile ); iLine++ )
66 {
67 if ( iLine == 0 )
68 {
69 pThis = strstr( pLine, "[" );
70 *pnIns = atoi( pThis+1 ) + 1;
71 pThis = strstr( pThis+1, "[" );
72 *pnOuts = atoi( pThis+1 ) + 1;
73 }
74 else
75 {
76 Vec_Int_t * vLevel = NULL;
77 for ( pThis = pLine; (pThis = strstr(pThis, "M0[")); pThis++ )
78 {
79 if ( vLevel == NULL )
80 vLevel = Vec_WecPushLevel( vRes );
81 Vec_IntPush( vLevel, atoi( pThis+3 ) );
82 }
83 if ( vLevel )
84 Vec_IntReverseOrder( vLevel );
85 }
86 }
87 fclose( pFile );
88 //Vec_WecPrint( vRes, 0 );
89 return vRes;
90}
char * strstr()
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Vec_WrdReadNumsOut()

Vec_Int_t * Vec_WrdReadNumsOut ( char * pFileName,
int fVerbose )

Definition at line 274 of file giaMinLut.c.

275{
276 char pLine[1000];
277 Vec_Int_t * vNums; int iLine;
278 FILE * pFile = fopen( pFileName, "rb" );
279 if ( pFile == NULL )
280 {
281 printf( "Cannot open file \"%s\" for reading.\n", pFileName );
282 return NULL;
283 }
284 vNums = Vec_IntAlloc( 1000 );
285 for ( iLine = 0; fgets( pLine, 1000, pFile ); iLine++ )
286 Vec_IntPush( vNums, atoi(pLine) );
287 fclose( pFile );
288 if ( fVerbose )
289 printf( "Finished reading %d output values from file \"%s\".\n", Vec_IntSize(vNums), pFileName );
290 return vNums;
291}
Here is the caller graph for this function:

◆ Vec_WrdReadTest()

Gia_Man_t * Vec_WrdReadTest ( char * pFileName)

Definition at line 132 of file giaMinLut.c.

133{
134 extern int Gia_ManPerformLNetOpt_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj );
135 extern Gia_Man_t * Gia_TryPermOptCare( word * pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose );
136 Gia_Man_t * pPart, * pNew = NULL; Gia_Obj_t * pObj;
137 int i, k, nIns, nOuts, iLit;
138 Vec_Wec_t * vRes = Vec_WrdReadLayerText( pFileName, &nIns, &nOuts );
139 int nBitsI = vRes ? Vec_WecMaxLevelSize(vRes) : 0;
140 int nBitsO = vRes ? nOuts / Vec_WecSize(vRes) : 0;
141 int nWords = Abc_TtWordNum(nBitsI);
142 word * pFuncs = vRes ? Vec_WrdReadTruthText( pFileName, nBitsI, nBitsO, Vec_WecSize(vRes) ) : NULL;
143 Vec_Int_t * vPart, * vLits = Vec_IntAlloc( nOuts );
144 if ( vRes == NULL || pFuncs == NULL )
145 {
146 Vec_WecFreeP( &vRes );
147 Vec_IntFreeP( &vLits );
148 ABC_FREE( pFuncs );
149 return NULL;
150 }
151 assert( nOuts % Vec_WecSize(vRes) == 0 );
152 pNew = Gia_ManStart( 10000 );
153 pNew->pName = Abc_UtilStrsav( pFileName );
154 pNew->pSpec = NULL;
155 for ( i = 0; i < nIns; i++ )
156 Gia_ManAppendCi(pNew);
157 Gia_ManHashStart( pNew );
158 Vec_WecForEachLevel( vRes, vPart, i )
159 {
160 assert( Vec_IntSize(vPart) <= nBitsI );
161 pPart = Gia_TryPermOptCare( pFuncs + i * nBitsO * nWords, nBitsI, nBitsO, nWords, 20, 0 );
162 Gia_ManFillValue( pPart );
163 Gia_ManConst0(pPart)->Value = 0;
164 Gia_ManForEachCi( pPart, pObj, k )
165 pObj->Value = Abc_Var2Lit( 1+Vec_IntEntry(vPart, k), 0 );
166 Gia_ManForEachCo( pPart, pObj, k )
167 {
168 Gia_ManPerformLNetOpt_rec( pNew, pPart, Gia_ObjFanin0(pObj) );
169 Vec_IntPush( vLits, Gia_ObjFanin0Copy(pObj) );
170 }
171 Gia_ManStop( pPart );
172 }
173 Gia_ManHashStop( pNew );
174 Vec_IntForEachEntry( vLits, iLit, i )
175 Gia_ManAppendCo( pNew, iLit );
176 ABC_FREE( pFuncs );
177 Vec_WecFree( vRes );
178 Vec_IntFree( vLits );
179 return pNew;
180}
Vec_Wec_t * Vec_WrdReadLayerText(char *pFileName, int *pnIns, int *pnOuts)
FUNCTION DEFINITIONS ///.
Definition giaMinLut.c:54
word * Vec_WrdReadTruthText(char *pFileName, int nIns, int nOuts, int nFiles)
Definition giaMinLut.c:114
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
Here is the call graph for this function:

◆ Vec_WrdReadText()

void Vec_WrdReadText ( char * pFileName,
Vec_Wrd_t ** pvSimI,
Vec_Wrd_t ** pvSimO,
int nIns,
int nOuts )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 193 of file giaMinLut.c.

194{
195 int i, nSize, iLine, nLines, nWords;
196 char pLine[2000];
197 Vec_Wrd_t * vSimI, * vSimO;
198 FILE * pFile = fopen( pFileName, "rb" );
199 if ( pFile == NULL )
200 {
201 printf( "Cannot open file \"%s\" for reading.\n", pFileName );
202 return;
203 }
204 fseek( pFile, 0, SEEK_END );
205 nSize = ftell( pFile );
206 if ( nSize % (nIns + nOuts + 1) > 0 )
207 {
208 printf( "Cannot read file with simulation data that is not aligned at 8 bytes (remainder = %d).\n", nSize % (nIns + nOuts + 1) );
209 fclose( pFile );
210 return;
211 }
212 rewind( pFile );
213 nLines = nSize / (nIns + nOuts + 1);
214 nWords = (nLines + 63)/64;
215 vSimI = Vec_WrdStart( nIns *nWords );
216 vSimO = Vec_WrdStart( nOuts*nWords );
217 for ( iLine = 0; fgets( pLine, 2000, pFile ); iLine++ )
218 {
219 for ( i = 0; i < nIns; i++ )
220 if ( pLine[nIns-1-i] == '1' )
221 Abc_TtXorBit( Vec_WrdArray(vSimI) + i*nWords, iLine );
222 else assert( pLine[nIns-1-i] == '0' );
223 for ( i = 0; i < nOuts; i++ )
224 if ( pLine[nIns+nOuts-1-i] == '1' )
225 Abc_TtXorBit( Vec_WrdArray(vSimO) + i*nWords, iLine );
226 else assert( pLine[nIns+nOuts-1-i] == '0' );
227 }
228 fclose( pFile );
229 *pvSimI = vSimI;
230 *pvSimO = vSimO;
231 printf( "Read %d words of simulation data for %d inputs and %d outputs (padded %d zero-patterns).\n", nWords, nIns, nOuts, nWords*64-nLines );
232}
VOID_HACK rewind()
#define SEEK_END
Definition zconf.h:392
Here is the call graph for this function:

◆ Vec_WrdReadText2()

int Vec_WrdReadText2 ( char * pFileName,
Vec_Wrd_t ** pvSimI )

Definition at line 233 of file giaMinLut.c.

234{
235 int i, nSize, iLine, nLines, nWords, nIns;
236 char pLine[2000];
237 Vec_Wrd_t * vSimI;
238 FILE * pFile = fopen( pFileName, "rb" );
239 if ( pFile == NULL )
240 {
241 printf( "Cannot open file \"%s\" for reading.\n", pFileName );
242 return 0;
243 }
244 if ( !fgets(pLine, 2000, pFile) || (nIns = strlen(pLine)-1) < 1 )
245 {
246 printf( "Cannot find the number of inputs in file \"%s\".\n", pFileName );
247 fclose( pFile );
248 return 0;
249 }
250 fseek( pFile, 0, SEEK_END );
251 nSize = ftell( pFile );
252 if ( nSize % (nIns + 1) > 0 )
253 {
254 printf( "Cannot read file with simulation data that is not aligned at 8 bytes (remainder = %d).\n", nSize % (nIns + 1) );
255 fclose( pFile );
256 return 0;
257 }
258 rewind( pFile );
259 nLines = nSize / (nIns + 1);
260 nWords = (nLines + 63)/64;
261 vSimI = Vec_WrdStart( nIns *nWords );
262 for ( iLine = 0; fgets( pLine, 2000, pFile ); iLine++ )
263 {
264 for ( i = 0; i < nIns; i++ )
265 if ( pLine[nIns-1-i] == '1' )
266 Abc_TtXorBit( Vec_WrdArray(vSimI) + i*nWords, iLine );
267 else assert( pLine[nIns-1-i] == '0' );
268 }
269 fclose( pFile );
270 *pvSimI = vSimI;
271 printf( "Read %d words of simulation data for %d inputs (padded to 64-bit boundary with %d zero-patterns).\n", nWords, nIns, nWords*64-nLines );
272 return nIns;
273}
int strlen()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Vec_WrdReadTextOut()

Vec_Wrd_t * Vec_WrdReadTextOut ( char * pFileName,
int nOuts )

Definition at line 292 of file giaMinLut.c.

293{
294 int i, iLine, nLines, nWords;
295 Vec_Wrd_t * vSimO;
296 Vec_Int_t * vNums = Vec_WrdReadNumsOut( pFileName, 1 );
297 if ( vNums == NULL )
298 return NULL;
299 nLines = Vec_IntSize(vNums);
300 nWords = (nLines + 63)/64;
301 vSimO = Vec_WrdStart( nOuts*nWords );
302 Vec_IntForEachEntry( vNums, i, iLine )
303 Abc_TtXorBit( Vec_WrdArray(vSimO) + i*nWords, iLine );
304 Vec_IntFree( vNums );
305 printf( "Read %d words of simulation data for %d outputs (padded %d zero-patterns).\n", nWords, nOuts, nWords*64-nLines );
306 return vSimO;
307}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Vec_WrdReadTruthText()

word * Vec_WrdReadTruthText ( char * pFileName,
int nIns,
int nOuts,
int nFiles )

Definition at line 114 of file giaMinLut.c.

115{
116 char FileName[1000];
117 int i, nWords = Abc_TtWordNum( nIns );
118 word * pRes = ABC_CALLOC( word, nOuts*nFiles*nWords );
119 for ( i = 0; i < nFiles; i++ )
120 {
121 assert( strlen(pFileName) < 900 );
122 strcpy( FileName, pFileName );
123 sprintf( FileName + strlen(FileName) - 2, "_N%d.bench", i );
124 if ( !Vec_WrdReadTruthTextOne( FileName, nIns, nOuts, pRes + i*nOuts*nWords ) )
125 {
126 ABC_FREE( pRes );
127 return NULL;
128 }
129 }
130 return pRes;
131}
int Vec_WrdReadTruthTextOne(char *pFileName, int nIns, int nOuts, word *pRes)
Definition giaMinLut.c:91
char * sprintf()
char * strcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Vec_WrdReadTruthTextOne()

int Vec_WrdReadTruthTextOne ( char * pFileName,
int nIns,
int nOuts,
word * pRes )

Definition at line 91 of file giaMinLut.c.

92{
93 int i, nWords = Abc_TtWordNum( nIns );
94 char * pStart, * pBuffer = Extra_FileReadContents( pFileName );
95 if ( pBuffer == NULL )
96 {
97 printf( "Cannot read file \"%s\".\n", pFileName );
98 return 0;
99 }
100 pStart = pBuffer;
101 for ( i = 0; i < nOuts; i++ )
102 {
103 pStart = strstr( pStart + 1, "0x" );
104 if ( !Extra_ReadHex( (unsigned *)(pRes + i*nWords), pStart + 2, nWords*16 ) )
105 {
106 printf( "Cannot read truth table %d (out of %d) in file \"%s\".\n", i, nOuts, pFileName );
107 ABC_FREE( pBuffer );
108 return 0;
109 }
110 }
111 ABC_FREE( pBuffer );
112 return 1;
113}
int Extra_ReadHex(unsigned Sign[], char *pString, int nDigits)
char * Extra_FileReadContents(char *pFileName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Vec_WrdZoneExtract()

Vec_Wrd_t * Vec_WrdZoneExtract ( int ZoneSize,
Vec_Wrd_t * p,
int iWord,
int nWords )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 333 of file giaMinLut.c.

334{
335 int z, nZones = Vec_WrdSize(p)/ZoneSize;
336 int w, Limit = Abc_MinInt( nWords, ZoneSize-iWord );
337 Vec_Wrd_t * pNew = Vec_WrdStart( nZones*nWords );
338 for ( z = 0; z < nZones; z++ )
339 for ( w = 0; w < Limit; w++ )
340 Vec_WrdWriteEntry( pNew, z*nWords + w, Vec_WrdEntry(p, z*ZoneSize + iWord + w) );
341 return pNew;
342}
Here is the caller graph for this function:

◆ Vec_WrdZoneInsert()

void Vec_WrdZoneInsert ( Vec_Wrd_t * pNew,
int ZoneSize,
Vec_Wrd_t * p,
int iWord,
int nWords )

Definition at line 343 of file giaMinLut.c.

344{
345 int z, nZones = Vec_WrdSize(pNew)/ZoneSize;
346 int w, Limit = Abc_MinInt( nWords, ZoneSize-iWord );
347 for ( z = 0; z < nZones; z++ )
348 for ( w = 0; w < Limit; w++ )
349 Vec_WrdWriteEntry( pNew, z*ZoneSize + iWord + w, Vec_WrdEntry(p, z*nWords + w) );
350}
Here is the caller graph for this function: