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

Go to the source code of this file.

Classes

struct  Tree_Sto_t_
 

Macros

#define TREE_MAX_VARS   16
 DECLARATIONS ///.
 
#define TT_UNDEF   ABC_CONST(0x1234567887654321)
 

Typedefs

typedef struct Tree_Sto_t_ Tree_Sto_t
 

Functions

Tree_Sto_tGia_ManTreeDup (Tree_Sto_t *p)
 FUNCTION DEFINITIONS ///.
 
void Gia_ManTreeFree (Tree_Sto_t *p)
 
int Gia_ManTreeCountNodes (Tree_Sto_t *p)
 
void Gia_ManTreePrint (Tree_Sto_t *p)
 
int Gia_ManFindOrAddNode (Tree_Sto_t *pSto, int iVar, int Truth, word *pCof)
 
int Gia_ManProcessLevel (Tree_Sto_t *pSto, int iVar)
 
Tree_Sto_tGia_ManContructTree (word *pTruths, int nIns, int nOuts, int nWords)
 
void Gia_ManContructTreeTest (word *pTruths, int nIns, int nOuts, int nWords)
 
int Gia_ManSwapTree (Tree_Sto_t *pSto, int i)
 
int Gia_ManFindBestPosition (word *pTruths, int nIns, int nOuts, int nWords, word *pStore, int fMoveMore, int *pnNodesMin, int fVerbose)
 
void Gia_ManPermStats (int nIns, int *pIPerm, int *pTried)
 
int Gia_ManPermuteTreeOne (word *pTruths, int nIns, int nOuts, int nWords, int fRandom, int *pIPermOut, int fVeryVerbose, int fVerbose)
 
void Gia_ManPermuteTree (word *pTruths, int nIns, int nOuts, int nWords, int fRandom, int fVerbose)
 
wordAbc_TtMin_rec (word *pF, word *pR, int nVars, Vec_Wrd_t *vMemory, Vec_Wrd_t *vNodes, Vec_Wec_t *vNodes2)
 
wordAbc_TtMin (word *pF, word *pR, int nVars, Vec_Wrd_t *vMemory, Vec_Wrd_t *vNodes, Vec_Wec_t *vNodes2)
 
wordAbc_TtMinArray (word *p, int nOuts, int nVars, int *pnNodes, int fVerbose)
 
wordAbc_TtSimpleMin_rec (Gia_Man_t *p, word *pF, word *pC, int nVars, Vec_Wrd_t *vMemory, Vec_Wrd_t *vNodes, Vec_Wec_t *vNodes2, int *piLit, int *pPerm)
 
Gia_Man_tAbc_TtSimpleMinArrayNew (word *p, int nVars, int nOuts, int *pnNodes, int fVerbose, int *pIPerm)
 
wordAbc_TtGiaMin_rec (Gia_Man_t *p, word *pF, word *pR, int nVars, Vec_Wrd_t *vMemory, Vec_Wrd_t *vNodes, Vec_Wec_t *vNodes2, int *piLit, int *pPerm)
 
Gia_Man_tAbc_TtGiaMinArray (word *p, int nVars, int nOuts, int *pnNodes, int fVerbose, int *pIPerm)
 
Gia_Man_tAbc_TtGiaMinArrayNew (word *p, int nVars, int nOuts, int *pnNodes, int fVerbose, int *pIPerm)
 
int Gia_ManBuildMuxes6_rec (Gia_Man_t *p, word t, int nVars, int *pPerm)
 
int Gia_ManBuildMuxes_rec (Gia_Man_t *p, word *pTruth, int nVars, int *pPerm)
 
Gia_Man_tGia_ManBuildMuxesTest (word *pTruth, int nIns, int nOuts, int *pPerm)
 
Gia_Man_tGia_ManBuildMuxes (Tree_Sto_t *p, int *pIPerm)
 
void Gia_ManDumpMuxes (Tree_Sto_t *p, char *pFileName, int *pIPerm)
 
Gia_Man_tGia_ManCreateMuxGia (word *pTruths, int nIns, int nOuts, int nWords, int *pIPerm)
 
void Gia_ManDumpMuxGia (word *pTruths, int nIns, int nOuts, int nWords, int *pIPerm, char *pFileName)
 
Gia_Man_tGia_TryPermOptCare (word *pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose)
 
Gia_Man_tGia_TryPermOpt2 (word *pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose)
 
Gia_Man_tGia_TryPermOpt (word *pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose)
 
Gia_Man_tGia_TryPermOptNew (word *pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose)
 
void Abc_Tt6MinTest3 (Gia_Man_t *p)
 
void Abc_Tt6MinTest2 (Gia_Man_t *p)
 

Macro Definition Documentation

◆ TREE_MAX_VARS

#define TREE_MAX_VARS   16

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

]

Definition at line 32 of file giaMinLut2.c.

◆ TT_UNDEF

#define TT_UNDEF   ABC_CONST(0x1234567887654321)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 338 of file giaMinLut2.c.

Typedef Documentation

◆ Tree_Sto_t

typedef struct Tree_Sto_t_ Tree_Sto_t

Definition at line 34 of file giaMinLut2.c.

Function Documentation

◆ Abc_Tt6MinTest2()

void Abc_Tt6MinTest2 ( Gia_Man_t * p)

Definition at line 1300 of file giaMinLut2.c.

1301{
1302 int fVerbose = 0;
1303 int i, nWords = Abc_TtWordNum(Gia_ManCiNum(p));
1304 word * pTruth = ABC_ALLOC( word, 3*nWords );
1305 word * pRes = NULL, * pTruths[3] = { pTruth, pTruth+nWords, pTruth+2*nWords };
1306
1307 Vec_Int_t * vSupp = Vec_IntAlloc( 100 );
1308 Vec_Wrd_t * vNodes = Vec_WrdAlloc( 100 );
1309 Vec_Wec_t * vNodes2 = Vec_WecAlloc( 100 );
1310 Vec_Wrd_t * vMemory = Vec_WrdAlloc( 0 );
1311
1312 Gia_Obj_t * pObj;
1313 Gia_ManForEachCi( p, pObj, i )
1314 Vec_IntPush( vSupp, Gia_ObjId(p, pObj) );
1315
1316 Gia_ObjComputeTruthTableStart( p, Gia_ManCiNum(p) );
1317 assert( Gia_ManCoNum(p) == 3 );
1318 Gia_ManForEachCo( p, pObj, i )
1319 {
1320 word * pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ObjFanin0(pObj), vSupp );
1321 Abc_TtCopy( pTruths[i], pTruth, nWords, Gia_ObjFaninC0(pObj) );
1322 }
1324
1325
1326 //Abc_TtSharp( pTruths[0], pTruths[0], pTruths[1], nWords );
1327 Abc_TtReverseVars( pTruths[0], Gia_ManCiNum(p) );
1328 Abc_TtCopy( pTruths[1], pTruths[0], nWords, 1 );
1329
1330 pRes = Abc_TtMin( pTruths[0], pTruths[1], Gia_ManCiNum(p), vMemory, vNodes, vNodes2 );
1331 printf( "Nodes = %d.\n", Vec_WrdSize(vNodes) );
1332 printf( "Nodes2 = %d.\n", Vec_WecSizeSize(vNodes2) );
1333 if ( Abc_TtEqual(pRes, pTruths[0], nWords) )
1334 printf( "Verification successful.\n" );
1335 else
1336 printf( "Verification FAILED.\n" );
1337
1338 //printf( "Printing the tree:\n" );
1339// Gia_ManPermuteTree( pTruths[0], Gia_ManCiNum(p), 1, nWords, fVerbose );
1340 Gia_ManPermuteTree( pTruth, Gia_ManCiNum(p), 3, nWords, 0, fVerbose );
1341
1342
1343/*
1344 Abc_TtReverseVars( pTruths[0], Gia_ManCiNum(p) );
1345 Abc_TtReverseVars( pTruths[1], Gia_ManCiNum(p) );
1346 Abc_TtReverseVars( pTruths[2], Gia_ManCiNum(p) );
1347 printf( "Printing the tree:\n" );
1348 Gia_ManContructTree( pTruth, Gia_ManCiNum(p), 3, nWords );
1349*/
1350
1351/*
1352 pNew = Gia_ManBuildMuxesTest( pTruth, Gia_ManCiNum(p), Gia_ManCoNum(p), NULL );
1353 Gia_AigerWrite( pNew, "from_tt.aig", 0, 0, 0 );
1354 printf( "Dumping file \"%s\".\n", "from_tt.aig" );
1355 Gia_ManStop( pNew );
1356*/
1357
1358 Vec_WrdFree( vMemory );
1359 Vec_WrdFree( vNodes );
1360 Vec_WecFree( vNodes2 );
1361 Vec_IntFree( vSupp );
1362 ABC_FREE( pTruth );
1363}
int nWords
Definition abcNpn.c:127
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
void Gia_ManPermuteTree(word *pTruths, int nIns, int nOuts, int nWords, int fRandom, int fVerbose)
Definition giaMinLut2.c:311
word * Abc_TtMin(word *pF, word *pR, int nVars, Vec_Wrd_t *vMemory, Vec_Wrd_t *vNodes, Vec_Wec_t *vNodes2)
Definition giaMinLut2.c:455
word * Gia_ObjComputeTruthTableCut(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vLeaves)
Definition giaTruth.c:628
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
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
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition vecWrd.h:42
Here is the call graph for this function:

◆ Abc_Tt6MinTest3()

void Abc_Tt6MinTest3 ( Gia_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1286 of file giaMinLut2.c.

1287{
1288 word f = ABC_CONST(0x513B00000819050F);
1289 //word r = ABC_CONST(0xA000571507200000);
1290 word r = ~f;
1291 Vec_Wrd_t * vNodes = Vec_WrdAlloc( 100 );
1292 word Res = Abc_Tt6Min_rec( f, r, 6, vNodes );
1293 printf( "Nodes = %d.\n", Vec_WrdSize(vNodes) );
1294 if ( Res == f )
1295 printf( "Verification successful.\n" );
1296 else
1297 printf( "Verification FAILED.\n" );
1298 Vec_WrdFree( vNodes );
1299}
#define ABC_CONST(number)
PARAMETERS ///.
Definition abc_global.h:240

◆ Abc_TtGiaMin_rec()

word * Abc_TtGiaMin_rec ( Gia_Man_t * p,
word * pF,
word * pR,
int nVars,
Vec_Wrd_t * vMemory,
Vec_Wrd_t * vNodes,
Vec_Wec_t * vNodes2,
int * piLit,
int * pPerm )

Definition at line 796 of file giaMinLut2.c.

797{
798 int i, Entry, Var, iLit0, iLit1, nWords = Abc_TtWordNum(nVars);
799 word * pRes0, * pRes1, * pRes2 = Vec_WrdFetch( vMemory, nWords );
800 *piLit = 0;
801 if ( nVars <= 6 )
802 {
803 pRes2[0] = Abc_TtGia6Min_rec( p, pF[0], pR[0], nVars, vNodes, piLit, pPerm );
804 return pRes2;
805 }
806 assert( !Abc_TtIntersect(pF, pR, nWords, 0) );
807 if ( Abc_TtIsConst0(pF, nWords) && Abc_TtIsConst0(pR, nWords) )
808 return NULL;
809 if ( Abc_TtIsConst0(pF, nWords) && Abc_TtIsConst1(pR, nWords) )
810 {
811 *piLit = 0;
812 Abc_TtClear( pRes2, nWords );
813 return pRes2;
814 }
815 if ( Abc_TtIsConst1(pF, nWords) && Abc_TtIsConst0(pR, nWords) )
816 {
817 *piLit = 1;
818 Abc_TtFill( pRes2, nWords );
819 return pRes2;
820 }
821 nWords >>= 1;
822 if ( !Abc_TtHasVar( pF, nVars, nVars-1 ) && !Abc_TtHasVar( pR, nVars, nVars-1 ) )
823 {
824 pRes0 = Abc_TtGiaMin_rec( p, pF, pR, nVars-1, vMemory, vNodes, vNodes2, piLit, pPerm );
825 Abc_TtCopy( pRes2, pRes0, nWords, 0 );
826 Abc_TtCopy( pRes2 + nWords, pRes0, nWords, 0 );
827 return pRes2;
828 }
829 if ( 1 && vNodes2 )
830 {
831 Vec_Int_t * vLayer = Vec_WecEntry( vNodes2, nVars ); int iLit;
832 Vec_IntForEachEntryDouble( vLayer, Entry, iLit, i )
833 {
834 word * pTemp = Vec_WrdEntryP( vMemory, Entry );
835 if ( !Abc_TtIntersect(pTemp, pF, 2*nWords, 1) && !Abc_TtIntersect(pTemp, pR, 2*nWords, 0) )
836 {
837 *piLit = iLit;
838 return pTemp;
839 }
840 else if ( !Abc_TtIntersect(pTemp, pF, 2*nWords, 0) && !Abc_TtIntersect(pTemp, pR, 2*nWords, 1) )
841 {
842 *piLit = Abc_LitNot(iLit);
843 Abc_TtCopy( pRes2, pTemp, 2*nWords, 1 );
844 return pRes2;
845 }
846 }
847/*
848 if ( nVars > 7 )
849 {
850 vLayer = Vec_WecEntry( vNodes2, nVars-1 );
851 Vec_IntForEachEntryDouble( vLayer, Entry, iLit, i )
852 {
853 word * pTemp = Vec_WrdEntryP( vMemory, Entry );
854 if ( !Abc_TtIntersect(pTemp, pF, 2*nWords, 1) && !Abc_TtIntersect(pTemp, pR, 2*nWords, 0) )
855 {
856 *piLit = iLit;
857 return pTemp;
858 }
859 else if ( !Abc_TtIntersect(pTemp, pF, 2*nWords, 0) && !Abc_TtIntersect(pTemp, pR, 2*nWords, 1) )
860 {
861 *piLit = Abc_LitNot(iLit);
862 Abc_TtCopy( pRes2, pTemp, 2*nWords, 1 );
863 return pRes2;
864 }
865 }
866 }
867*/
868 }
869 assert( nVars > 6 );
870 pRes0 = Abc_TtGiaMin_rec( p, pF, pR, nVars-1, vMemory, vNodes, vNodes2, &iLit0, pPerm );
871 pRes1 = Abc_TtGiaMin_rec( p, pF + nWords, pR + nWords, nVars-1, vMemory, vNodes, vNodes2, &iLit1, pPerm );
872 if ( pRes0 == NULL && pRes1 == NULL )
873 return NULL;
874 if ( pRes0 == NULL || pRes1 == NULL || Abc_TtEqual(pRes0, pRes1, nWords) )
875 {
876 *piLit = pRes0 ? iLit0 : iLit1;
877 Abc_TtCopy( pRes2, pRes0 ? pRes0 : pRes1, nWords, 0 );
878 Abc_TtCopy( pRes2 + nWords, pRes0 ? pRes0 : pRes1, nWords, 0 );
879 return pRes2;
880 }
881 Abc_TtCopy( pRes2, pRes0, nWords, 0 );
882 Abc_TtCopy( pRes2 + nWords, pRes1, nWords, 0 );
883 Var = pPerm ? pPerm[nVars-1] : nVars-1;
884 if ( !Abc_TtIntersect(pRes1, pRes0, nWords, 1) )
885 *piLit = Gia_ManHashOr( p, Gia_ManHashAnd(p, Abc_Var2Lit(1+Var, 0), iLit1), iLit0 );
886 else if ( !Abc_TtIntersect(pRes0, pRes1, nWords, 1) )
887 *piLit = Gia_ManHashOr( p, Gia_ManHashAnd(p, Abc_Var2Lit(1+Var, 1), iLit0), iLit1 );
888 else
889 *piLit = Gia_ManHashMux( p, Abc_Var2Lit(1+Var, 0), iLit1, iLit0 );
890 assert( !Abc_TtIntersect(pRes2, pF, 2*nWords, 1) ); // assert( !(uF & ~uRes2) );
891 assert( !Abc_TtIntersect(pRes2, pR, 2*nWords, 0) ); // assert( !(uRes2 & uR) );
892 if ( vNodes2 )
893 {
894 Vec_Int_t * vLayer = Vec_WecEntry( vNodes2, nVars );
895 Vec_IntPushTwo( vLayer, pRes2 - Vec_WrdArray(vMemory), *piLit );
896 }
897 return pRes2;
898}
int Var
Definition exorList.c:228
word * Abc_TtGiaMin_rec(Gia_Man_t *p, word *pF, word *pR, int nVars, Vec_Wrd_t *vMemory, Vec_Wrd_t *vNodes, Vec_Wec_t *vNodes2, int *piLit, int *pPerm)
Definition giaMinLut2.c:796
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:621
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition giaHash.c:692
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition vecInt.h:72
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGiaMinArray()

Gia_Man_t * Abc_TtGiaMinArray ( word * p,
int nVars,
int nOuts,
int * pnNodes,
int fVerbose,
int * pIPerm )

Definition at line 899 of file giaMinLut2.c.

900{
901 Gia_Man_t * pNew, * pTemp;
902 int o, i, iLit, nWords = Abc_TtWordNum(nVars);
903 word * pRes, * pResult = ABC_ALLOC( word, nOuts*nWords/2 );
904 Vec_Wrd_t * vMemory = Vec_WrdAlloc( 100 );
905 Vec_Wrd_t * vNodes = Vec_WrdAlloc( 100 );
906 Vec_Wec_t * vNodes2 = Vec_WecStart( nVars+1 );
907 Vec_WrdGrow( vMemory, 1 << 20 );
908 pNew = Gia_ManStart( 1000 );
909 pNew->pName = Abc_UtilStrsav( "muxes" );
910 for ( i = 0; i < nVars; i++ )
911 Gia_ManAppendCi(pNew);
912 Gia_ManHashAlloc( pNew );
913
914 for ( o = 0; o < nOuts/2; o++ )
915 {
916 word * pF = p + (2*o+0)*nWords;
917 word * pR = p + (2*o+1)*nWords;
918 for ( i = nVars; i < 6; i++ )
919 assert( !Abc_Tt6HasVar(pF[0], i) && !Abc_Tt6HasVar(pR[0], i) );
920 pRes = Abc_TtGiaMin_rec( pNew, pF, pR, nVars, vMemory, vNodes, vNodes2, &iLit, pIPerm );
921 if ( pResult == NULL )
922 {
923 Abc_TtClear( pResult + o*nWords, nWords );
924 Gia_ManAppendCo( pNew, 0 );
925 }
926 else
927 {
928 Abc_TtCopy( pResult + o*nWords, pRes, nWords, 0 );
929 Gia_ManAppendCo( pNew, iLit );
930 }
931 }
932 if ( fVerbose )
933 printf( "Nodes = %5d. Nodes2 = %5d. Total = %5d. ",
934 Vec_WrdSize(vNodes), Vec_WecSizeSize(vNodes2), Vec_WrdSize(vNodes) + Vec_WecSizeSize(vNodes2) );
935 //printf( "Memory %d (Truth table %d)\n", Vec_WrdSize(vMemory), nWords );
936 if ( pnNodes )
937 *pnNodes = Vec_WrdSize(vNodes) + Vec_WecSizeSize(vNodes2);
938 Vec_WrdFree( vMemory );
939 Vec_WrdFree( vNodes );
940 Vec_WecFree( vNodes2 );
941 ABC_FREE( pResult );
942
943 Gia_ManHashStop( pNew );
944 pNew = Gia_ManCleanup( pTemp = pNew );
945 Gia_ManStop( pTemp );
946 return pNew;
947}
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
char * pName
Definition gia.h:99
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGiaMinArrayNew()

Gia_Man_t * Abc_TtGiaMinArrayNew ( word * p,
int nVars,
int nOuts,
int * pnNodes,
int fVerbose,
int * pIPerm )

Definition at line 948 of file giaMinLut2.c.

949{
950 Gia_Man_t * pNew, * pTemp;
951 int o, i, iLit, nWords = Abc_TtWordNum(nVars);
952 word * pF = ABC_ALLOC( word, nWords );
953 word * pR = ABC_ALLOC( word, nWords );
954 Vec_Wrd_t * vMemory = Vec_WrdAlloc( 100 );
955 Vec_Wrd_t * vNodes = Vec_WrdAlloc( 100 );
956 Vec_Wec_t * vNodes2 = Vec_WecStart( nVars+1 );
957 Vec_WrdGrow( vMemory, 1 << 20 );
958 pNew = Gia_ManStart( 1000 );
959 pNew->pName = Abc_UtilStrsav( "muxes" );
960 for ( i = 0; i < nVars; i++ )
961 Gia_ManAppendCi(pNew);
962 Gia_ManHashAlloc( pNew );
963
964 for ( o = 0; o < nOuts; o++ )
965 {
966 word * pCare = p + nOuts*nWords;
967 word * pTruth = p + o*nWords;
968 Abc_TtAnd( pF, pCare, pTruth, nWords, 0 );
969 Abc_TtSharp( pR, pCare, pTruth, nWords );
970 for ( i = nVars; i < 6; i++ )
971 assert( !Abc_Tt6HasVar(pF[0], i) && !Abc_Tt6HasVar(pR[0], i) );
972 Abc_TtGiaMin_rec( pNew, pF, pR, nVars, vMemory, vNodes, vNodes2, &iLit, pIPerm );
973 Gia_ManAppendCo( pNew, iLit );
974 }
975 if ( fVerbose )
976 printf( "Nodes = %5d. Nodes2 = %5d. Total = %5d. ",
977 Vec_WrdSize(vNodes), Vec_WecSizeSize(vNodes2), Vec_WrdSize(vNodes) + Vec_WecSizeSize(vNodes2) );
978 //printf( "Memory %d (Truth table %d)\n", Vec_WrdSize(vMemory), nWords );
979 if ( pnNodes )
980 *pnNodes = Vec_WrdSize(vNodes) + Vec_WecSizeSize(vNodes2);
981 Vec_WrdFree( vMemory );
982 Vec_WrdFree( vNodes );
983 Vec_WecFree( vNodes2 );
984 ABC_FREE( pF );
985 ABC_FREE( pR );
986
987 Gia_ManHashStop( pNew );
988 pNew = Gia_ManCleanup( pTemp = pNew );
989 Gia_ManStop( pTemp );
990 return pNew;
991}
Here is the call graph for this function:

◆ Abc_TtMin()

word * Abc_TtMin ( word * pF,
word * pR,
int nVars,
Vec_Wrd_t * vMemory,
Vec_Wrd_t * vNodes,
Vec_Wec_t * vNodes2 )

Definition at line 455 of file giaMinLut2.c.

456{
457 word * pResult;
458 int i, nWords = Abc_TtWordNum(nVars);
459 assert( nVars >= 0 && nVars <= 16 );
460 for ( i = nVars; i < 6; i++ )
461 assert( !Abc_Tt6HasVar(pF[0], i) && !Abc_Tt6HasVar(pR[0], i) );
462 Vec_WrdClear( vMemory );
463 Vec_WrdGrow( vMemory, 1 << 20 );
464 pResult = Abc_TtMin_rec( pF, pR, nVars, vMemory, vNodes, vNodes2 );
465 if ( pResult == NULL )
466 {
467 Vec_WrdFill( vMemory, nWords, 0 );
468 return Vec_WrdArray( vMemory );
469 }
470 //printf( "Memory %d (Truth table %d)\n", Vec_WrdSize(vMemory), nWords );
471 Abc_TtCopy( Vec_WrdArray(vMemory), pResult, nWords, 0 );
472 Vec_WrdShrink( vMemory, nWords );
473 return Vec_WrdArray(vMemory);
474}
word * Abc_TtMin_rec(word *pF, word *pR, int nVars, Vec_Wrd_t *vMemory, Vec_Wrd_t *vNodes, Vec_Wec_t *vNodes2)
Definition giaMinLut2.c:389
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtMin_rec()

word * Abc_TtMin_rec ( word * pF,
word * pR,
int nVars,
Vec_Wrd_t * vMemory,
Vec_Wrd_t * vNodes,
Vec_Wec_t * vNodes2 )

Definition at line 389 of file giaMinLut2.c.

390{
391 int i, Entry, nWords = Abc_TtWordNum(nVars);
392 word * pRes0, * pRes1, * pRes2 = Vec_WrdFetch( vMemory, nWords );
393 if ( nVars <= 6 )
394 {
395 pRes2[0] = Abc_Tt6Min_rec( pF[0], pR[0], nVars, vNodes );
396 return pRes2;
397 }
398 assert( !Abc_TtIntersect(pF, pR, nWords, 0) );
399 if ( Abc_TtIsConst0(pF, nWords) && Abc_TtIsConst0(pR, nWords) )
400 return NULL;
401 if ( Abc_TtIsConst0(pF, nWords) && Abc_TtIsConst1(pR, nWords) )
402 {
403 Abc_TtClear( pRes2, nWords );
404 return pRes2;
405 }
406 if ( Abc_TtIsConst1(pF, nWords) && Abc_TtIsConst0(pR, nWords) )
407 {
408 Abc_TtFill( pRes2, nWords );
409 return pRes2;
410 }
411 nWords >>= 1;
412 if ( !Abc_TtHasVar( pF, nVars, nVars-1 ) && !Abc_TtHasVar( pR, nVars, nVars-1 ) )
413 {
414 pRes0 = Abc_TtMin_rec( pF, pR, nVars-1, vMemory, vNodes, vNodes2 );
415 Abc_TtCopy( pRes2, pRes0, nWords, 0 );
416 Abc_TtCopy( pRes2 + nWords, pRes0, nWords, 0 );
417 return pRes2;
418 }
419 if ( 1 && vNodes2 )
420 {
421 Vec_Int_t * vLayer = Vec_WecEntry( vNodes2, nVars );
422 Vec_IntForEachEntry( vLayer, Entry, i )
423 {
424 word * pTemp = Vec_WrdEntryP( vMemory, Entry );
425 if ( !Abc_TtIntersect(pTemp, pF, 2*nWords, 1) && !Abc_TtIntersect(pTemp, pR, 2*nWords, 0) )
426 return pTemp;
427/*
428 if ( !Abc_TtIntersect(pTemp, pF, 2*nWords, 0) && !Abc_TtIntersect(pTemp, pR, 2*nWords, 1) )
429 {
430 Abc_TtCopy( pRes2, pTemp, 2*nWords, 1 );
431 return pRes2;
432 }
433*/
434 }
435 }
436 assert( nVars > 6 );
437 pRes0 = Abc_TtMin_rec( pF, pR, nVars-1, vMemory, vNodes, vNodes2 );
438 pRes1 = Abc_TtMin_rec( pF + nWords, pR + nWords, nVars-1, vMemory, vNodes, vNodes2 );
439 if ( pRes0 == NULL && pRes1 == NULL )
440 return NULL;
441 if ( pRes0 == NULL || pRes1 == NULL || Abc_TtEqual(pRes0, pRes1, nWords) )
442 {
443 Abc_TtCopy( pRes2, pRes0 ? pRes0 : pRes1, nWords, 0 );
444 Abc_TtCopy( pRes2 + nWords, pRes0 ? pRes0 : pRes1, nWords, 0 );
445 return pRes2;
446 }
447 Abc_TtCopy( pRes2, pRes0, nWords, 0 );
448 Abc_TtCopy( pRes2 + nWords, pRes1, nWords, 0 );
449 assert( !Abc_TtIntersect(pRes2, pF, 2*nWords, 1) ); // assert( !(uF & ~uRes2) );
450 assert( !Abc_TtIntersect(pRes2, pR, 2*nWords, 0) ); // assert( !(uRes2 & uR) );
451 if ( vNodes2 )
452 Vec_WecPush( vNodes2, nVars, pRes2 - Vec_WrdArray(vMemory) );
453 return pRes2;
454}
#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:

◆ Abc_TtMinArray()

word * Abc_TtMinArray ( word * p,
int nOuts,
int nVars,
int * pnNodes,
int fVerbose )

Definition at line 475 of file giaMinLut2.c.

476{
477 int o, i, nWords = Abc_TtWordNum(nVars);
478 word * pRes, * pResult = ABC_ALLOC( word, nOuts*nWords/2 );
479 Vec_Wrd_t * vMemory = Vec_WrdAlloc( 100 );
480 Vec_Wrd_t * vNodes = Vec_WrdAlloc( 100 );
481 Vec_Wec_t * vNodes2 = Vec_WecStart( nVars+1 );
482 Vec_WrdGrow( vMemory, 1 << 20 );
483 for ( o = 0; o < nOuts/2; o++ )
484 {
485 word * pF = p + (2*o+0)*nWords;
486 word * pR = p + (2*o+1)*nWords;
487 for ( i = nVars; i < 6; i++ )
488 assert( !Abc_Tt6HasVar(pF[0], i) && !Abc_Tt6HasVar(pR[0], i) );
489 pRes = Abc_TtMin_rec( pF, pR, nVars, vMemory, vNodes, vNodes2 );
490 if ( pResult == NULL )
491 Abc_TtClear( pResult + o*nWords, nWords );
492 else
493 Abc_TtCopy( pResult + o*nWords, pRes, nWords, 0 );
494 }
495 if ( fVerbose )
496 printf( "Nodes = %5d. Nodes2 = %5d. Total = %5d. ",
497 Vec_WrdSize(vNodes), Vec_WecSizeSize(vNodes2), Vec_WrdSize(vNodes) + Vec_WecSizeSize(vNodes2) );
498 //printf( "Memory %d (Truth table %d)\n", Vec_WrdSize(vMemory), nWords );
499 if ( pnNodes )
500 *pnNodes = Vec_WrdSize(vNodes) + Vec_WecSizeSize(vNodes2);
501 Vec_WrdFree( vMemory );
502 Vec_WrdFree( vNodes );
503 Vec_WecFree( vNodes2 );
504 return pResult;
505}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtSimpleMin_rec()

word * Abc_TtSimpleMin_rec ( Gia_Man_t * p,
word * pF,
word * pC,
int nVars,
Vec_Wrd_t * vMemory,
Vec_Wrd_t * vNodes,
Vec_Wec_t * vNodes2,
int * piLit,
int * pPerm )

Definition at line 584 of file giaMinLut2.c.

585{
586 int i, Entry, Var, iLit0, iLit1, nWords = Abc_TtWordNum(nVars);
587 word * pRes0, * pRes1, * pRes2 = Vec_WrdFetch( vMemory, nWords );
588 *piLit = 0;
589 if ( nVars <= 6 )
590 {
591 pRes2[0] = Abc_TtSimple6Min_rec( p, pF[0], pC[0], nVars, vNodes, piLit, pPerm );
592 return pRes2;
593 }
594 if ( !Abc_TtIntersect(pF, pC, nWords, 0) )
595 {
596 *piLit = 0;
597 Abc_TtClear( pRes2, nWords );
598 return pRes2;
599 }
600 if ( !Abc_TtIntersect(pF, pC, nWords, 1) )
601 {
602 *piLit = 1;
603 Abc_TtFill( pRes2, nWords );
604 return pRes2;
605 }
606 nWords >>= 1;
607 if ( !Abc_TtHasVar( pF, nVars, nVars-1 ) )
608 {
609 word * pCn = Vec_WrdFetch( vMemory, nWords );
610 Abc_TtOr( pCn, pC, pC + nWords, nWords );
611 pRes0 = Abc_TtSimpleMin_rec( p, pF, pCn, nVars-1, vMemory, vNodes, vNodes2, piLit, pPerm );
612 Abc_TtCopy( pRes2, pRes0, nWords, 0 );
613 Abc_TtCopy( pRes2 + nWords, pRes0, nWords, 0 );
614 return pRes2;
615 }
616 if ( 1 && vNodes2 )
617 {
618 Vec_Int_t * vLayer = Vec_WecEntry( vNodes2, nVars ); int iLit;
619 Vec_IntForEachEntryDouble( vLayer, Entry, iLit, i )
620 {
621 word * pTemp = Vec_WrdEntryP( vMemory, Entry );
622 if ( Abc_TtEqualCare(pTemp, pF, pC, 0, 2*nWords) )
623 {
624 *piLit = iLit;
625 return pTemp;
626 }
627 else if ( Abc_TtEqualCare(pTemp, pF, pC, 1, 2*nWords) )
628 {
629 *piLit = Abc_LitNot(iLit);
630 Abc_TtCopy( pRes2, pTemp, 2*nWords, 1 );
631 return pRes2;
632 }
633 }
634 }
635 assert( nVars > 6 );
636 pRes0 = Abc_TtSimpleMin_rec( p, pF, pC, nVars-1, vMemory, vNodes, vNodes2, &iLit0, pPerm );
637 pRes1 = Abc_TtSimpleMin_rec( p, pF + nWords, pC + nWords, nVars-1, vMemory, vNodes, vNodes2, &iLit1, pPerm );
638 if ( Abc_TtEqual(pRes0, pRes1, nWords) )
639 {
640 *piLit = iLit0;
641 Abc_TtCopy( pRes2, pRes0, nWords, 0 );
642 Abc_TtCopy( pRes2 + nWords, pRes0, nWords, 0 );
643 return pRes2;
644 }
645 Abc_TtCopy( pRes2, pRes0, nWords, 0 );
646 Abc_TtCopy( pRes2 + nWords, pRes1, nWords, 0 );
647 Var = pPerm ? pPerm[nVars-1] : nVars-1;
648 //if ( !Abc_TtIntersectCare(pRes1, pRes0, pC + nWords, nWords, 1) )
649 if ( !Abc_TtIntersect(pRes1, pRes0, nWords, 1) )
650 *piLit = Gia_ManHashOr( p, Gia_ManHashAnd(p, Abc_Var2Lit(1+Var, 0), iLit1), iLit0 );
651 //else if ( !Abc_TtIntersectCare(pRes0, pRes1, pC, nWords, 1) )
652 else if ( !Abc_TtIntersect(pRes0, pRes1, nWords, 1) )
653 *piLit = Gia_ManHashOr( p, Gia_ManHashAnd(p, Abc_Var2Lit(1+Var, 1), iLit0), iLit1 );
654 else
655 *piLit = Gia_ManHashMux( p, Abc_Var2Lit(1+Var, 0), iLit1, iLit0 );
656 assert( Abc_TtEqualCare(pRes2, pF, pC, 0, 2*nWords) );
657 if ( vNodes2 )
658 {
659 Vec_Int_t * vLayer = Vec_WecEntry( vNodes2, nVars );
660 Vec_IntPushTwo( vLayer, pRes2 - Vec_WrdArray(vMemory), *piLit );
661 }
662 return pRes2;
663}
word * Abc_TtSimpleMin_rec(Gia_Man_t *p, word *pF, word *pC, int nVars, Vec_Wrd_t *vMemory, Vec_Wrd_t *vNodes, Vec_Wec_t *vNodes2, int *piLit, int *pPerm)
Definition giaMinLut2.c:584
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtSimpleMinArrayNew()

Gia_Man_t * Abc_TtSimpleMinArrayNew ( word * p,
int nVars,
int nOuts,
int * pnNodes,
int fVerbose,
int * pIPerm )

Definition at line 664 of file giaMinLut2.c.

665{
666 Gia_Man_t * pNew, * pTemp;
667 int o, i, iLit, nWords = Abc_TtWordNum(nVars);
668 word * pF = ABC_ALLOC( word, nWords );
669 word * pR = ABC_ALLOC( word, nWords );
670 Vec_Wrd_t * vMemory = Vec_WrdAlloc( 100 );
671 Vec_Wrd_t * vNodes = Vec_WrdAlloc( 100 );
672 Vec_Wec_t * vNodes2 = Vec_WecStart( nVars+1 );
673 Vec_WrdGrow( vMemory, 1 << 20 );
674 pNew = Gia_ManStart( 1000 );
675 pNew->pName = Abc_UtilStrsav( "muxes" );
676 for ( i = 0; i < nVars; i++ )
677 Gia_ManAppendCi(pNew);
678 Gia_ManHashAlloc( pNew );
679
680 for ( o = 0; o < nOuts; o++ )
681 {
682 word * pCare = p + nOuts*nWords;
683 word * pTruth = p + o*nWords;
684 for ( i = nVars; i < 6; i++ )
685 assert( !Abc_Tt6HasVar(pTruth[0], i) && !Abc_Tt6HasVar(pCare[0], i) );
686 Abc_TtSimpleMin_rec( pNew, pTruth, pCare, nVars, vMemory, vNodes, vNodes2, &iLit, pIPerm );
687 Gia_ManAppendCo( pNew, iLit );
688 }
689 if ( fVerbose )
690 printf( "Nodes = %5d. Nodes2 = %5d. Total = %5d. ",
691 Vec_WrdSize(vNodes), Vec_WecSizeSize(vNodes2), Vec_WrdSize(vNodes) + Vec_WecSizeSize(vNodes2) );
692 //printf( "Memory %d (Truth table %d)\n", Vec_WrdSize(vMemory), nWords );
693 if ( pnNodes )
694 *pnNodes = Vec_WrdSize(vNodes) + Vec_WecSizeSize(vNodes2);
695 Vec_WrdFree( vMemory );
696 Vec_WrdFree( vNodes );
697 Vec_WecFree( vNodes2 );
698 ABC_FREE( pF );
699 ABC_FREE( pR );
700
701 Gia_ManHashStop( pNew );
702 pNew = Gia_ManCleanup( pTemp = pNew );
703 Gia_ManStop( pTemp );
704 return pNew;
705}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManBuildMuxes()

Gia_Man_t * Gia_ManBuildMuxes ( Tree_Sto_t * p,
int * pIPerm )

Definition at line 1068 of file giaMinLut2.c.

1069{
1070 return Gia_ManBuildMuxesTest( p->pMem, p->nIns, p->nOuts, pIPerm ? pIPerm : p->pIPerm );
1071}
Gia_Man_t * Gia_ManBuildMuxesTest(word *pTruth, int nIns, int nOuts, int *pPerm)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManBuildMuxes6_rec()

int Gia_ManBuildMuxes6_rec ( Gia_Man_t * p,
word t,
int nVars,
int * pPerm )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1005 of file giaMinLut2.c.

1006{
1007 int iLit0, iLit1, Var;
1008 assert( nVars <= 6 );
1009 if ( t == 0 )
1010 return 0;
1011 if ( ~t == 0 )
1012 return 1;
1013 assert( nVars > 0 );
1014 for ( Var = nVars-1; Var >= 0; Var-- )
1015 if ( Abc_Tt6HasVar( t, Var ) )
1016 break;
1017 assert( Var >= 0 );
1018 iLit0 = Gia_ManBuildMuxes6_rec( p, Abc_Tt6Cofactor0(t, Var), Var, pPerm );
1019 iLit1 = Gia_ManBuildMuxes6_rec( p, Abc_Tt6Cofactor1(t, Var), Var, pPerm );
1020 Var = pPerm ? pPerm[Var] : Var;
1021 return Gia_ManAppendMux( p, Abc_Var2Lit(1+Var, 0), iLit1, iLit0 );
1022}
int Gia_ManBuildMuxes6_rec(Gia_Man_t *p, word t, int nVars, int *pPerm)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManBuildMuxes_rec()

int Gia_ManBuildMuxes_rec ( Gia_Man_t * p,
word * pTruth,
int nVars,
int * pPerm )

Definition at line 1023 of file giaMinLut2.c.

1024{
1025 int iLit0, iLit1, Var, nWords = Abc_TtWordNum(nVars);
1026 if ( nVars <= 6 )
1027 return Gia_ManBuildMuxes6_rec( p, pTruth[0], nVars, pPerm );
1028 if ( Abc_TtIsConst0(pTruth, nWords) )
1029 return 0;
1030 if ( Abc_TtIsConst1(pTruth, nWords) )
1031 return 1;
1032/*
1033 assert( nVars > 0 );
1034 if ( !Abc_TtHasVar( pTruth, nVars, nVars-1 ) )
1035 return Gia_ManBuildMuxes_rec( p, pTruth, nVars-1 );
1036 assert( nVars > 6 );
1037 iLit0 = Gia_ManBuildMuxes_rec( p, pTruth, nVars-1 );
1038 iLit1 = Gia_ManBuildMuxes_rec( p, pTruth+nWords/2, nVars-1 );
1039*/
1040 assert( nVars > 0 );
1041 for ( Var = nVars-1; Var >= 0; Var-- )
1042 if ( Abc_TtHasVar( pTruth, nVars, Var ) )
1043 break;
1044 assert( Var >= 0 );
1045 if ( Var < 6 )
1046 return Gia_ManBuildMuxes6_rec( p, pTruth[0], Var+1, pPerm );
1047 iLit0 = Gia_ManBuildMuxes_rec( p, pTruth, Var, pPerm );
1048 iLit1 = Gia_ManBuildMuxes_rec( p, pTruth+Abc_TtWordNum(Var), Var, pPerm );
1049 Var = pPerm ? pPerm[Var] : Var;
1050 return Gia_ManAppendMux( p, Abc_Var2Lit(1+Var, 0), iLit1, iLit0 );
1051}
int Gia_ManBuildMuxes_rec(Gia_Man_t *p, word *pTruth, int nVars, int *pPerm)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManBuildMuxesTest()

Gia_Man_t * Gia_ManBuildMuxesTest ( word * pTruth,
int nIns,
int nOuts,
int * pPerm )

Definition at line 1052 of file giaMinLut2.c.

1053{
1054 Gia_Man_t * pNew, * pTemp;
1055 int i, nWords = Abc_TtWordNum(nIns);
1056 pNew = Gia_ManStart( 1000 );
1057 pNew->pName = Abc_UtilStrsav( "muxes" );
1058 for ( i = 0; i < nIns; i++ )
1059 Gia_ManAppendCi(pNew);
1060 Gia_ManHashAlloc( pNew );
1061 for ( i = 0; i < nOuts; i++ )
1062 Gia_ManAppendCo( pNew, Gia_ManBuildMuxes_rec( pNew, pTruth+i*nWords, nIns, pPerm ) );
1063 Gia_ManHashStop( pNew );
1064 pNew = Gia_ManCleanup( pTemp = pNew );
1065 Gia_ManStop( pTemp );
1066 return pNew;
1067}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManContructTree()

Tree_Sto_t * Gia_ManContructTree ( word * pTruths,
int nIns,
int nOuts,
int nWords )

Definition at line 168 of file giaMinLut2.c.

169{
170 Tree_Sto_t * pSto = ABC_CALLOC( Tree_Sto_t, 1 ); int i;
171 assert( Abc_TtWordNum(nIns) == nWords );
172 assert( nIns+1 <= TREE_MAX_VARS );
173 pSto->pMem = Abc_TtDup(pTruths, nOuts*nWords, 0);
174 pSto->nIns = nIns;
175 pSto->nOuts = nOuts;
176 for ( i = 0; i < nIns; i++ )
177 pSto->pPerm[i] = pSto->pIPerm[i] = i;
178 for ( i = 0; i < nOuts; i++ )
179 Gia_ManFindOrAddNode( pSto, nIns, (unsigned)pSto->pMem[i], pSto->pMem + i*nWords );
180 for ( i = nIns-1; i >= 0; i-- )
181 pSto->nNodes[i] = Gia_ManProcessLevel( pSto, i );
182 return pSto;
183}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
int Gia_ManProcessLevel(Tree_Sto_t *pSto, int iVar)
Definition giaMinLut2.c:131
int Gia_ManFindOrAddNode(Tree_Sto_t *pSto, int iVar, int Truth, word *pCof)
Definition giaMinLut2.c:111
struct Tree_Sto_t_ Tree_Sto_t
Definition giaMinLut2.c:34
#define TREE_MAX_VARS
DECLARATIONS ///.
Definition giaMinLut2.c:32
word * pMem
Definition giaMinLut2.c:44
int pIPerm[TREE_MAX_VARS]
Definition giaMinLut2.c:41
int nNodes[TREE_MAX_VARS]
Definition giaMinLut2.c:42
int pPerm[TREE_MAX_VARS]
Definition giaMinLut2.c:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManContructTreeTest()

void Gia_ManContructTreeTest ( word * pTruths,
int nIns,
int nOuts,
int nWords )

Definition at line 184 of file giaMinLut2.c.

185{
186 Tree_Sto_t * pSto = Gia_ManContructTree( pTruths, nIns, nOuts, nWords );
187 printf( "Total nodes = %d.\n", Gia_ManTreeCountNodes(pSto) );
188 Gia_ManTreeFree( pSto );
189}
void Gia_ManTreeFree(Tree_Sto_t *p)
Definition giaMinLut2.c:74
Tree_Sto_t * Gia_ManContructTree(word *pTruths, int nIns, int nOuts, int nWords)
Definition giaMinLut2.c:168
int Gia_ManTreeCountNodes(Tree_Sto_t *p)
Definition giaMinLut2.c:82
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCreateMuxGia()

Gia_Man_t * Gia_ManCreateMuxGia ( word * pTruths,
int nIns,
int nOuts,
int nWords,
int * pIPerm )

Definition at line 1079 of file giaMinLut2.c.

1080{
1081 Tree_Sto_t * pSto = Gia_ManContructTree( pTruths, nIns, nOuts, nWords );
1082 Gia_Man_t * pNew = Gia_ManBuildMuxes( pSto, pIPerm );
1083 //printf( "Internal nodes = %5d.\n", Gia_ManTreeCountNodes(pSto) );
1084 Gia_ManTreeFree( pSto );
1085 return pNew;
1086}
Gia_Man_t * Gia_ManBuildMuxes(Tree_Sto_t *p, int *pIPerm)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDumpMuxes()

void Gia_ManDumpMuxes ( Tree_Sto_t * p,
char * pFileName,
int * pIPerm )

Definition at line 1072 of file giaMinLut2.c.

1073{
1074 Gia_Man_t * pNew = Gia_ManBuildMuxes( p, pIPerm );
1075 Gia_AigerWrite( pNew, pFileName, 0, 0, 0 );
1076 Gia_ManStop( pNew );
1077 printf( "Finished dumping tree into AIG file \"%s\".\n", pFileName );
1078}
void Gia_AigerWrite(Gia_Man_t *p, char *pFileName, int fWriteSymbols, int fCompact, int fWriteNewLine)
Definition giaAiger.c:1595
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDumpMuxGia()

void Gia_ManDumpMuxGia ( word * pTruths,
int nIns,
int nOuts,
int nWords,
int * pIPerm,
char * pFileName )

Definition at line 1087 of file giaMinLut2.c.

1088{
1089 Tree_Sto_t * pSto = Gia_ManContructTree( pTruths, nIns, nOuts, nWords );
1090 Gia_ManDumpMuxes( pSto, pFileName, pIPerm );
1091 Gia_ManTreeFree( pSto );
1092}
void Gia_ManDumpMuxes(Tree_Sto_t *p, char *pFileName, int *pIPerm)
Here is the call graph for this function:

◆ Gia_ManFindBestPosition()

int Gia_ManFindBestPosition ( word * pTruths,
int nIns,
int nOuts,
int nWords,
word * pStore,
int fMoveMore,
int * pnNodesMin,
int fVerbose )

Definition at line 220 of file giaMinLut2.c.

221{
222 Tree_Sto_t * pSto = Gia_ManContructTree( pTruths, nIns, nOuts, nWords );
223 //int v, vBest = nIns-1, nNodesCur = Gia_ManTreeCountNodes(pSto), nNodesMin = nNodesCur;
224 int v, vBest = -1, nNodesCur = Gia_ManTreeCountNodes(pSto), nNodesMin = ABC_INFINITY;
225 if ( fVerbose )
226 Gia_ManTreePrint( pSto );
227 Abc_TtCopy( pStore+(nIns-1)*nOuts*nWords, pSto->pMem, nOuts*nWords, 0 );
228 for ( v = nIns-2; v >= 0; v-- )
229 {
230 nNodesCur += Gia_ManSwapTree( pSto, v );
231 if ( fMoveMore ? nNodesMin >= nNodesCur : nNodesMin > nNodesCur )
232 {
233 nNodesMin = nNodesCur;
234 vBest = v;
235 }
236 if ( fVerbose )
237 printf( "Level %2d -> %2d : Nodes = %4d. ", v+1, v, nNodesCur );
238 Abc_TtCopy( pStore+v*nOuts*nWords, pSto->pMem, nOuts*nWords, 0 );
239 if ( fVerbose )
240 Gia_ManContructTreeTest( pSto->pMem, nIns, nOuts, nWords );
241 }
242 assert( vBest != nIns-1 );
243 Gia_ManTreeFree( pSto );
244 if ( fVerbose )
245 printf( "Best level = %d. Best nodes = %d.\n", vBest, nNodesMin );
246 if ( pnNodesMin )
247 *pnNodesMin = nNodesMin;
248 return vBest;
249}
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
void Gia_ManContructTreeTest(word *pTruths, int nIns, int nOuts, int nWords)
Definition giaMinLut2.c:184
int Gia_ManSwapTree(Tree_Sto_t *pSto, int i)
Definition giaMinLut2.c:202
void Gia_ManTreePrint(Tree_Sto_t *p)
Definition giaMinLut2.c:89
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManFindOrAddNode()

int Gia_ManFindOrAddNode ( Tree_Sto_t * pSto,
int iVar,
int Truth,
word * pCof )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file giaMinLut2.c.

112{
113 int k, Obj;
114 if ( iVar > 5 )
115 {
116 int nWords = Abc_TtWordNum(iVar);
117 Vec_IntForEachEntry( pSto->vCofs+iVar, Obj, k )
118 if ( Abc_TtEqual( pSto->pMem + Obj, pCof, nWords ) )
119 return 1;
120 Vec_IntPush( pSto->vCofs+iVar, pCof - pSto->pMem );
121 }
122 else
123 {
124 Vec_IntForEachEntry( pSto->vCofs+iVar, Obj, k )
125 if ( Obj == Truth )
126 return 1;
127 Vec_IntPush( pSto->vCofs+iVar, Truth );
128 }
129 return 0;
130}
Vec_Int_t vCofs[TREE_MAX_VARS]
Definition giaMinLut2.c:43
Here is the caller graph for this function:

◆ Gia_ManPermStats()

void Gia_ManPermStats ( int nIns,
int * pIPerm,
int * pTried )

Definition at line 250 of file giaMinLut2.c.

251{
252 int v;
253 for ( v = nIns-1; v >= 0; v-- )
254 printf( "Level = %2d : Var = %2d Tried = %2d\n", v, pIPerm[v], pTried[v] );
255 printf( "\n" );
256}
Here is the caller graph for this function:

◆ Gia_ManPermuteTree()

void Gia_ManPermuteTree ( word * pTruths,
int nIns,
int nOuts,
int nWords,
int fRandom,
int fVerbose )

Definition at line 311 of file giaMinLut2.c.

312{
313 abctime clk = Abc_Clock();
314 word * pTruthDup = Abc_TtDup( pTruths, nOuts*nWords, 0 );
315 int r;
316 //srand( time(NULL) );
317 Gia_ManRandom(1);
318 for ( r = 0; r < 100; r++ )
319 {
320 Gia_ManPermuteTreeOne( pTruthDup, nIns, nOuts, nWords, fRandom, NULL, 0, fVerbose );
321 Abc_TtCopy( pTruthDup, pTruths, nOuts*nWords, 0 );
322 }
323 ABC_FREE( pTruthDup );
324 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
325}
ABC_INT64_T abctime
Definition abc_global.h:332
int Gia_ManPermuteTreeOne(word *pTruths, int nIns, int nOuts, int nWords, int fRandom, int *pIPermOut, int fVeryVerbose, int fVerbose)
Definition giaMinLut2.c:257
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
Definition giaUtil.c:49
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManPermuteTreeOne()

int Gia_ManPermuteTreeOne ( word * pTruths,
int nIns,
int nOuts,
int nWords,
int fRandom,
int * pIPermOut,
int fVeryVerbose,
int fVerbose )

Definition at line 257 of file giaMinLut2.c.

258{
259 extern void Gia_ManDumpMuxes( Tree_Sto_t * p, char * pFileName, int * pIPerm );
260 word * pStore = ABC_ALLOC( word, nIns*nOuts*nWords );
261 int pTried[TREE_MAX_VARS] = {0};
262 int pIPerm[TREE_MAX_VARS] = {0};
263 int v, r, Pos, nNodesPrev = -1, nNodesMin = 0, nNoChange = 0;
264 int nNodesBeg, nNodesEnd;
265 Tree_Sto_t * pSto;
266 for ( v = 0; v < nIns; v++ )
267 pIPerm[v] = v;
268 pSto = Gia_ManContructTree( pTruths, nIns, nOuts, nWords );
269 nNodesBeg = Gia_ManTreeCountNodes(pSto);
270 //Gia_ManDumpMuxes( pSto, "from_tt1.aig", pIPerm );
271 Gia_ManTreeFree( pSto );
272 if ( fRandom )
273 for ( v = 0; v < nIns; v++ )
274 {
275 //int o, vRand = rand() % nIns;
276 int o, vRand = Gia_ManRandom(0) % nIns;
277 for ( o = 0; o < nOuts; o++ )
278 Abc_TtSwapVars( pTruths + o*nWords, nIns, v, vRand );
279 ABC_SWAP( int, pIPerm[vRand], pIPerm[v] );
280 }
281 for ( r = 0; r < 10*nIns; r++ )
282 {
283 nNodesPrev = nNodesMin;
284 if ( fVeryVerbose )
285 printf( "\nRound %d:\n", r );
286 Pos = Gia_ManFindBestPosition( pTruths, nIns, nOuts, nWords, pStore, r&1, &nNodesMin, fVeryVerbose );
287 Abc_TtCopy( pTruths, pStore+Pos*nOuts*nWords, nOuts*nWords, 0 );
288 pTried[nIns-1]++;
289 for ( v = nIns-2; v >= Pos; v-- )
290 {
291 ABC_SWAP( int, pTried[v+1], pTried[v] );
292 ABC_SWAP( int, pIPerm[v+1], pIPerm[v] );
293 }
294 if ( fVeryVerbose )
295 Gia_ManPermStats( nIns, pIPerm, pTried );
296 nNoChange = nNodesPrev == nNodesMin ? nNoChange + 1 : 0;
297 if ( nNoChange == 4 )
298 break;
299 }
300 pSto = Gia_ManContructTree( pTruths, nIns, nOuts, nWords );
301 nNodesEnd = Gia_ManTreeCountNodes(pSto);
302 //Gia_ManDumpMuxes( pSto, "from_tt2.aig", pIPerm );
303 if ( fVerbose )
304 printf( "Nodes %5d -> %5d. ", nNodesBeg, nNodesEnd );
305 Gia_ManTreeFree( pSto );
306 ABC_FREE( pStore );
307 if ( pIPermOut )
308 memcpy( pIPermOut, pIPerm, sizeof(int)*nIns );
309 return nNodesEnd;
310}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
ush Pos
Definition deflate.h:88
int Gia_ManFindBestPosition(word *pTruths, int nIns, int nOuts, int nWords, word *pStore, int fMoveMore, int *pnNodesMin, int fVerbose)
Definition giaMinLut2.c:220
void Gia_ManPermStats(int nIns, int *pIPerm, int *pTried)
Definition giaMinLut2.c:250
char * memcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManProcessLevel()

int Gia_ManProcessLevel ( Tree_Sto_t * pSto,
int iVar )

Definition at line 131 of file giaMinLut2.c.

132{
133 int k, Obj, nNodes = 0;
134 //Vec_IntPrint( pSto->vCofs+iVar );
135 Vec_IntClear( pSto->vCofs+iVar );
136 if ( iVar > 5 )
137 {
138 int nWords = Abc_TtWordNum(iVar);
139 Vec_IntForEachEntry( pSto->vCofs+iVar+1, Obj, k )
140 {
141 word * pCof0 = pSto->pMem + Obj;
142 word * pCof1 = pCof0 + nWords;
143 Gia_ManFindOrAddNode( pSto, iVar, -1, pCof0 );
144 if ( Abc_TtEqual( pCof0, pCof1, nWords ) )
145 continue;
146 Gia_ManFindOrAddNode( pSto, iVar, -1, pCof1 );
147 nNodes++;
148 }
149 }
150 else
151 {
152 Vec_IntForEachEntry( pSto->vCofs+iVar+1, Obj, k )
153 {
154 unsigned Cof0 = iVar < 5 ? Abc_Tt5Cofactor0( Obj, iVar ) : (unsigned) pSto->pMem[Obj];
155 unsigned Cof1 = iVar < 5 ? Abc_Tt5Cofactor1( Obj, iVar ) : (unsigned)(pSto->pMem[Obj] >> 32);
156 Gia_ManFindOrAddNode( pSto, iVar, Cof0, NULL );
157 if ( Cof0 == Cof1 )
158 continue;
159 Gia_ManFindOrAddNode( pSto, iVar, Cof1, NULL );
160 nNodes++;
161 }
162 }
163 //printf( "Level %2d : Nodes = %3d Cofs = %3d\n", iVar, nNodes, Vec_IntSize(pSto->vCofs+iVar) );
164 //Vec_IntPrint( pSto->vCofs+iVar );
165 //printf( "\n" );
166 return nNodes;
167}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSwapTree()

int Gia_ManSwapTree ( Tree_Sto_t * pSto,
int i )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 202 of file giaMinLut2.c.

203{
204 int nNodes = pSto->nNodes[i+1] + pSto->nNodes[i];
205 int v, o, nWords = Abc_TtWordNum(pSto->nIns);
206 //printf( "Swapping %2d and %2d ", i, i+1 );
207 assert( i >= 0 && i < pSto->nIns-1 );
208 for ( o = 0; o < pSto->nOuts; o++ )
209 Abc_TtSwapAdjacent( pSto->pMem + o*nWords, nWords, i );
210 for ( v = 5; v > i+1; v-- )
211 pSto->nNodes[v] = Gia_ManProcessLevel( pSto, v );
212 pSto->nNodes[i+1] = Gia_ManProcessLevel( pSto, i+1 );
213 pSto->nNodes[i] = Gia_ManProcessLevel( pSto, i );
214 ABC_SWAP( int, pSto->pTried[i], pSto->pTried[i+1] );
215 ABC_SWAP( int, pSto->pIPerm[i], pSto->pIPerm[i+1] );
216 pSto->pPerm[pSto->pIPerm[i+1]] = i+1;
217 pSto->pPerm[pSto->pIPerm[i]] = i;
218 return pSto->nNodes[i+1] + pSto->nNodes[i] - nNodes;
219}
int pTried[TREE_MAX_VARS]
Definition giaMinLut2.c:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManTreeCountNodes()

int Gia_ManTreeCountNodes ( Tree_Sto_t * p)

Definition at line 82 of file giaMinLut2.c.

83{
84 int i, nNodes = 0;
85 for ( i = 0; i < TREE_MAX_VARS; i++ )
86 nNodes += p->nNodes[i];
87 return nNodes;
88}
Here is the caller graph for this function:

◆ Gia_ManTreeDup()

Tree_Sto_t * Gia_ManTreeDup ( Tree_Sto_t * p)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 62 of file giaMinLut2.c.

63{
64 Tree_Sto_t * pSto = ABC_CALLOC( Tree_Sto_t, 1 );
65 int i, k, Obj;
66 *pSto = *p;
67 pSto->pMem = Abc_TtDup( pSto->pMem, p->nOuts*Abc_TtWordNum(p->nIns), 0 );
68 memset( pSto->vCofs, 0, sizeof(Vec_Int_t)*TREE_MAX_VARS );
69 for ( i = 0; i < TREE_MAX_VARS; i++ )
70 Vec_IntForEachEntry( p->vCofs+i, Obj, k )
71 Vec_IntPush( pSto->vCofs+i, Obj );
72 return pSto;
73}
char * memset()
Here is the call graph for this function:

◆ Gia_ManTreeFree()

void Gia_ManTreeFree ( Tree_Sto_t * p)

Definition at line 74 of file giaMinLut2.c.

75{
76 int i;
77 for ( i = 0; i < TREE_MAX_VARS; i++ )
78 ABC_FREE( p->vCofs[i].pArray );
79 ABC_FREE( p->pMem );
80 ABC_FREE( p );
81}
Here is the caller graph for this function:

◆ Gia_ManTreePrint()

void Gia_ManTreePrint ( Tree_Sto_t * p)

Definition at line 89 of file giaMinLut2.c.

90{
91 int i;
92 printf( "Tree with %d nodes:\n", Gia_ManTreeCountNodes(p) );
93 for ( i = p->nIns-1; i >= 0; i-- )
94 printf( "Level %2d Var %2d : %s Nodes = %3d Cofs = %3d\n",
95 i, p->pIPerm[i], p->pTried[i]?"*":" ", p->nNodes[i], Vec_IntSize(p->vCofs+i) );
96// for ( i = p->nIns-1; i >= 0; i-- )
97// printf( "Var %2d Level %2d\n", i, p->pPerm[i] );
98}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_TryPermOpt()

Gia_Man_t * Gia_TryPermOpt ( word * pTruths,
int nIns,
int nOuts,
int nWords,
int nRounds,
int fVerbose )

Definition at line 1186 of file giaMinLut2.c.

1187{
1188 abctime clk = Abc_Clock();
1189 Gia_Man_t * pBest = NULL;
1190 word * pTruthDup = Abc_TtDup( pTruths, nOuts*nWords, 0 );
1191 int pIPermBest[TREE_MAX_VARS] = {0};
1192 int pIPerm[TREE_MAX_VARS] = {0};
1193 int r, rBest = -1, nNodes2 = -1, nNodesBest = ABC_INFINITY;
1194 assert( nOuts % 2 == 0 );
1195 //srand( time(NULL) );
1196 Gia_ManRandom(1);
1197 for ( r = 0; r < nRounds; r++ )
1198 {
1199 int nNodesAll = Gia_ManPermuteTreeOne( pTruthDup, nIns, nOuts, nWords, r>0, pIPerm, 0, fVerbose );
1200 Gia_Man_t * pTemp = Abc_TtGiaMinArray( pTruthDup, nIns, nOuts, NULL, 0, pIPerm );
1201 nNodes2 = Gia_ManAndNum(pTemp);
1202 if ( nNodesBest > nNodes2 )
1203 {
1204 nNodesBest = nNodes2;
1205 memcpy( pIPermBest, pIPerm, sizeof(int)*nIns );
1206 rBest = r;
1207
1208 Gia_ManStopP( &pBest );
1209 pBest = pTemp;
1210 pTemp = NULL;
1211 }
1212 Gia_ManStopP( &pTemp );
1213 Abc_TtCopy( pTruthDup, pTruths, nOuts*nWords, 0 );
1214 if ( fVerbose )
1215 printf( "Permuted = %5d. AIG = %5d.\n", nNodesAll, nNodes2 );
1216 nNodesAll = 0;
1217 }
1218 if ( fVerbose )
1219 printf( "Best round %3d. Best nodes %5d. ", rBest, nNodesBest );
1220 ABC_FREE( pTruthDup );
1221 if ( fVerbose )
1222 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1223 return pBest;
1224}
Gia_Man_t * Abc_TtGiaMinArray(word *p, int nVars, int nOuts, int *pnNodes, int fVerbose, int *pIPerm)
Definition giaMinLut2.c:899
void Gia_ManStopP(Gia_Man_t **p)
Definition giaMan.c:224
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_TryPermOpt2()

Gia_Man_t * Gia_TryPermOpt2 ( word * pTruths,
int nIns,
int nOuts,
int nWords,
int nRounds,
int fVerbose )

Definition at line 1143 of file giaMinLut2.c.

1144{
1145 abctime clk = Abc_Clock();
1146 Gia_Man_t * pNew;
1147 word * pRes, * pTruthDup = Abc_TtDup( pTruths, nOuts*nWords, 0 );
1148 word * pTruthBest = ABC_ALLOC( word, nOuts*nWords/2 );
1149 int pIPermBest[TREE_MAX_VARS] = {0};
1150 int pIPerm[TREE_MAX_VARS] = {0};
1151 int r, rBest = -1, nNodes = -1, nNodesBest = ABC_INFINITY;
1152 assert( nOuts % 2 == 0 );
1153 // collect onsets
1154 //for ( r = 0; r < nOuts/2; r++ )
1155 // Abc_TtCopy( pTruthBest+r*nWords, pTruths+2*r*nWords, nWords, 0 );
1156 //Gia_ManDumpMuxGia( pTruthBest, nIns, nOuts/2, nWords, NULL, "tt_beg.aig" );
1157 //srand( time(NULL) );
1158 Gia_ManRandom(1);
1159 for ( r = 0; r < nRounds; r++ )
1160 {
1161 int nNodesAll = Gia_ManPermuteTreeOne( pTruthDup, nIns, nOuts, nWords, r>0, pIPerm, 0, fVerbose );
1162 pRes = Abc_TtMinArray( pTruthDup, nOuts, nIns, &nNodes, fVerbose );
1163 if ( nNodesBest > nNodes )
1164 {
1165 nNodesBest = nNodes;
1166 memcpy( pIPermBest, pIPerm, sizeof(int)*nIns );
1167 Abc_TtCopy( pTruthBest, pRes, nOuts*nWords/2, 0 );
1168 rBest = r;
1169 }
1170 ABC_FREE( pRes );
1171 Abc_TtCopy( pTruthDup, pTruths, nOuts*nWords, 0 );
1172 if ( fVerbose )
1173 printf( "\n" );
1174 nNodesAll = 0;
1175 }
1176 if ( fVerbose )
1177 printf( "Best round %3d. Best nodes %5d. ", rBest, nNodesBest );
1178 ABC_FREE( pTruthDup );
1179 if ( fVerbose )
1180 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1181 pNew = Gia_ManCreateMuxGia( pTruthBest, nIns, nOuts/2, nWords, pIPermBest );
1182 //Gia_ManDumpMuxGia( pTruthBest, nIns, nOuts/2, nWords, pIPermBest, "tt_end.aig" );
1183 ABC_FREE( pTruthBest );
1184 return pNew;
1185}
word * Abc_TtMinArray(word *p, int nOuts, int nVars, int *pnNodes, int fVerbose)
Definition giaMinLut2.c:475
Gia_Man_t * Gia_ManCreateMuxGia(word *pTruths, int nIns, int nOuts, int nWords, int *pIPerm)
Here is the call graph for this function:

◆ Gia_TryPermOptCare()

Gia_Man_t * Gia_TryPermOptCare ( word * pTruths,
int nIns,
int nOuts,
int nWords,
int nRounds,
int fVerbose )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1106 of file giaMinLut2.c.

1107{
1108 abctime clk = Abc_Clock();
1109 Gia_Man_t * pNew;
1110 word * pTruthDup = Abc_TtDup( pTruths, nOuts*nWords, 0 );
1111 word * pTruthBest = ABC_FALLOC( word, (nOuts+1)*nWords );
1112 int pIPermBest[TREE_MAX_VARS] = {0};
1113 int pIPerm[TREE_MAX_VARS] = {0};
1114 int r, rBest = -1, nNodes = -1, nNodesBest = ABC_INFINITY;
1115 //Gia_ManDumpMuxGia( pTruths, nIns, nOuts, nWords, NULL, "tt_beg.aig" );
1116 //srand( time(NULL) );
1117 Gia_ManRandom(1);
1118 for ( r = 0; r < nRounds; r++ )
1119 {
1120 nNodes = Gia_ManPermuteTreeOne( pTruthDup, nIns, nOuts, nWords, r>0, pIPerm, 0, fVerbose );
1121 if ( nNodesBest > nNodes )
1122 {
1123 nNodesBest = nNodes;
1124 memcpy( pIPermBest, pIPerm, sizeof(int)*nIns );
1125 Abc_TtCopy( pTruthBest, pTruthDup, nOuts*nWords, 0 );
1126 rBest = r;
1127 }
1128 Abc_TtCopy( pTruthDup, pTruths, nOuts*nWords, 0 );
1129 if ( fVerbose )
1130 printf( "\n" );
1131 }
1132 if ( fVerbose )
1133 printf( "Best round %3d. Best nodes %5d. ", rBest, nNodesBest );
1134 ABC_FREE( pTruthDup );
1135 if ( fVerbose )
1136 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1137 //pNew = Gia_ManCreateMuxGia( pTruthBest, nIns, nOuts, nWords, pIPermBest );
1138 pNew = Abc_TtSimpleMinArrayNew( pTruthBest, nIns, nOuts, NULL, 0, pIPermBest );
1139 //Gia_ManDumpMuxGia( pTruthBest, nIns, nOuts, nWords, pIPermBest, "tt_end.aig" );
1140 ABC_FREE( pTruthBest );
1141 return pNew;
1142}
#define ABC_FALLOC(type, num)
Definition abc_global.h:266
Gia_Man_t * Abc_TtSimpleMinArrayNew(word *p, int nVars, int nOuts, int *pnNodes, int fVerbose, int *pIPerm)
Definition giaMinLut2.c:664
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_TryPermOptNew()

Gia_Man_t * Gia_TryPermOptNew ( word * pTruths,
int nIns,
int nOuts,
int nWords,
int nRounds,
int fVerbose )

Definition at line 1225 of file giaMinLut2.c.

1226{
1227 abctime clk = Abc_Clock();
1228 Gia_Man_t * pTemp, * pBest = NULL;
1229 word * pTruthDup = Abc_TtDup( pTruths, (nOuts+1)*nWords, 0 );
1230 int pIPermBest[TREE_MAX_VARS] = {0};
1231 int pIPerm[TREE_MAX_VARS] = {0};
1232 int r, rBest = -1, nNodes2 = -1, nNodesBest = ABC_INFINITY;
1233 //srand( time(NULL) );
1234 Gia_ManRandom(1);
1235 for ( r = 0; r < nRounds; r++ )
1236 {
1237 int nNodesAll = Gia_ManPermuteTreeOne( pTruthDup, nIns, nOuts, nWords, r>0, pIPerm, 0, fVerbose );
1238 Abc_TtPermute( pTruthDup + nOuts*nWords, pIPerm, nIns );
1239 //pTemp = Abc_TtGiaMinArrayNew( pTruthDup, nIns, nOuts, NULL, 0, pIPerm );
1240 pTemp = Abc_TtSimpleMinArrayNew( pTruthDup, nIns, nOuts, NULL, 0, pIPerm );
1241 nNodes2 = Gia_ManAndNum(pTemp);
1242 if ( nNodesBest > nNodes2 )
1243 {
1244 nNodesBest = nNodes2;
1245 memcpy( pIPermBest, pIPerm, sizeof(int)*nIns );
1246 rBest = r;
1247
1248 Gia_ManStopP( &pBest );
1249 pBest = pTemp;
1250 pTemp = NULL;
1251 }
1252 Gia_ManStopP( &pTemp );
1253/*
1254 for ( i = 0; i <= nOuts; i++ )
1255 {
1256 Abc_TtUnpermute( pTruthDup + i*nWords, pIPerm, nIns );
1257 if ( !Abc_TtEqual(pTruthDup + i*nWords, pTruths + i*nWords, nWords) )
1258 printf( "Verification failed for output %d (out of %d).\n", i, nOuts );
1259 }
1260*/
1261 Abc_TtCopy( pTruthDup, pTruths, (nOuts+1)*nWords, 0 );
1262 if ( fVerbose )
1263 printf( "Permuted = %5d. AIG = %5d.\n", nNodesAll, nNodes2 );
1264 nNodesAll = 0;
1265 }
1266 if ( fVerbose )
1267 printf( "Best round %3d. Best nodes %5d. ", rBest, nNodesBest );
1268 ABC_FREE( pTruthDup );
1269 if ( fVerbose )
1270 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1271 return pBest;
1272}
Here is the call graph for this function:
Here is the caller graph for this function: