ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaTruth.c File Reference
#include "gia.h"
#include "misc/vec/vecMem.h"
#include "misc/vec/vecWec.h"
#include "misc/util/utilTruth.h"
#include "opt/dau/dau.h"
Include dependency graph for giaTruth.c:

Go to the source code of this file.

Functions

word Gia_LutComputeTruth6Simple_rec (Gia_Man_t *p, int iObj)
 FUNCTION DEFINITIONS ///.
 
word Gia_LutComputeTruth6Simple (Gia_Man_t *p, int iPo)
 
word Gia_LutComputeTruth6Map_rec (Gia_Man_t *p, int iObj, Vec_Int_t *vMap)
 
word Gia_LutComputeTruth6Map (Gia_Man_t *p, int iPo, Vec_Int_t *vMap)
 
int Gia_Truth5ToGia (Gia_Man_t *p, int *pVarLits, int nVars, unsigned Truth, int fHash)
 
int Gia_Truth6ToGia (Gia_Man_t *p, int *pVarLits, int nVars, word Truth, int fHash)
 
void Gia_Truth6ToGiaTest (Gia_Man_t *p)
 
word Gia_LutComputeTruth6_rec (Gia_Man_t *p, int iNode, Vec_Wrd_t *vTruths)
 
word Gia_LutComputeTruth6 (Gia_Man_t *p, int iObj, Vec_Wrd_t *vTruths)
 
void Gia_ObjComputeTruthTable6Lut_rec (Gia_Man_t *p, int iObj, Vec_Wrd_t *vTemp)
 
word Gia_ObjComputeTruthTable6Lut (Gia_Man_t *p, int iObj, Vec_Wrd_t *vTemp)
 
word Gia_ObjComputeTruth6 (Gia_Man_t *p, int iObj, Vec_Int_t *vSupp, Vec_Wrd_t *vTemp)
 
void Gia_ObjComputeTruth6CisSupport_rec (Gia_Man_t *p, int iObj, Vec_Int_t *vSupp)
 
word Gia_ObjComputeTruth6Cis (Gia_Man_t *p, int iLit, Vec_Int_t *vSupp, Vec_Wrd_t *vTemp)
 
void Gia_ObjComputeTruthTable6_rec (Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Wrd_t *vTruths)
 
word Gia_ObjComputeTruthTable6 (Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSupp, Vec_Wrd_t *vTruths)
 
void Gia_ObjCollectInternal_rec (Gia_Man_t *p, Gia_Obj_t *pObj)
 
void Gia_ObjCollectInternal (Gia_Man_t *p, Gia_Obj_t *pObj)
 
wordGia_ObjComputeTruthTable (Gia_Man_t *p, Gia_Obj_t *pObj)
 
void Gia_ObjComputeTruthTableTest (Gia_Man_t *p)
 
void Gia_ObjComputeTruthTableStart (Gia_Man_t *p, int nVarsMax)
 
void Gia_ObjComputeTruthTableStop (Gia_Man_t *p)
 
void Gia_ObjCollectInternalCut_rec (Gia_Man_t *p, int iObj)
 
void Gia_ObjCollectInternalCut (Gia_Man_t *p, int iRoot, Vec_Int_t *vLeaves)
 
wordGia_ObjComputeTruthTableCut (Gia_Man_t *p, Gia_Obj_t *pRoot, Vec_Int_t *vLeaves)
 
Gia_Man_tGia_ManIsoNpnReduce (Gia_Man_t *p, Vec_Ptr_t **pvPosEquivs, int fVerbose)
 

Function Documentation

◆ Gia_LutComputeTruth6()

word Gia_LutComputeTruth6 ( Gia_Man_t * p,
int iObj,
Vec_Wrd_t * vTruths )

Definition at line 249 of file giaTruth.c.

250{
251 int k, iFan;
252 assert( Gia_ObjIsLut(p, iObj) );
254 Gia_LutForEachFanin( p, iObj, iFan, k )
255 {
256 Vec_WrdWriteEntry( vTruths, iFan, s_Truths6[k] );
257 Gia_ObjSetTravIdCurrentId( p, iFan );
258 }
259 return Gia_LutComputeTruth6_rec( p, iObj, vTruths );
260}
Cube * p
Definition exorList.c:222
word Gia_LutComputeTruth6_rec(Gia_Man_t *p, int iNode, Vec_Wrd_t *vTruths)
Definition giaTruth.c:231
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition gia.h:1161
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_LutComputeTruth6_rec()

word Gia_LutComputeTruth6_rec ( Gia_Man_t * p,
int iNode,
Vec_Wrd_t * vTruths )

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

Synopsis [Compute truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 231 of file giaTruth.c.

232{
233 Gia_Obj_t * pObj;
234 word Truth0, Truth1;
235 if ( Gia_ObjIsTravIdCurrentId(p, iNode) )
236 return Vec_WrdEntry(vTruths, iNode);
237 Gia_ObjSetTravIdCurrentId(p, iNode);
238 pObj = Gia_ManObj( p, iNode );
239 assert( Gia_ObjIsAnd(pObj) );
240 Truth0 = Gia_LutComputeTruth6_rec( p, Gia_ObjFaninId0p(p, pObj), vTruths );
241 Truth1 = Gia_LutComputeTruth6_rec( p, Gia_ObjFaninId1p(p, pObj), vTruths );
242 if ( Gia_ObjFaninC0(pObj) )
243 Truth0 = ~Truth0;
244 if ( Gia_ObjFaninC1(pObj) )
245 Truth1 = ~Truth1;
246 Vec_WrdWriteEntry( vTruths, iNode, Truth0 & Truth1 );
247 return Truth0 & Truth1;
248}
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_LutComputeTruth6Map()

word Gia_LutComputeTruth6Map ( Gia_Man_t * p,
int iPo,
Vec_Int_t * vMap )

Definition at line 103 of file giaTruth.c.

104{
105 Gia_Obj_t * pObj = Gia_ManPo( p, iPo );
106 word Truth = Gia_LutComputeTruth6Map_rec( p, Gia_ObjFaninId0p(p, pObj), vMap );
107 return Gia_ObjFaninC0(pObj) ? ~Truth : Truth;
108}
word Gia_LutComputeTruth6Map_rec(Gia_Man_t *p, int iObj, Vec_Int_t *vMap)
Definition giaTruth.c:88
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_LutComputeTruth6Map_rec()

word Gia_LutComputeTruth6Map_rec ( Gia_Man_t * p,
int iObj,
Vec_Int_t * vMap )

Definition at line 88 of file giaTruth.c.

89{
90 word Truth0, Truth1, Truth;
91 Gia_Obj_t * pObj = Gia_ManObj(p, iObj);
92 if ( Gia_ObjIsConst0(pObj) )
93 return 0;
94 if ( Gia_ObjIsCi(pObj) )
95 return s_Truths6[Vec_IntEntry(vMap, Gia_ObjCioId(pObj))];
96 Truth0 = Gia_LutComputeTruth6Map_rec( p, Gia_ObjFaninId0(pObj, iObj), vMap );
97 Truth1 = Gia_LutComputeTruth6Map_rec( p, Gia_ObjFaninId1(pObj, iObj), vMap );
98 Truth0 = Gia_ObjFaninC0(pObj) ? ~Truth0 : Truth0;
99 Truth1 = Gia_ObjFaninC1(pObj) ? ~Truth1 : Truth1;
100 Truth = Gia_ObjIsXor(pObj) ? Truth0 ^ Truth1 : Truth0 & Truth1;
101 return Truth;
102}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_LutComputeTruth6Simple()

word Gia_LutComputeTruth6Simple ( Gia_Man_t * p,
int iPo )

Definition at line 81 of file giaTruth.c.

82{
83 Gia_Obj_t * pObj = Gia_ManPo( p, iPo );
84 word Truth = Gia_LutComputeTruth6Simple_rec( p, Gia_ObjFaninId0p(p, pObj) );
85 return Gia_ObjFaninC0(pObj) ? ~Truth : Truth;
86}
word Gia_LutComputeTruth6Simple_rec(Gia_Man_t *p, int iObj)
FUNCTION DEFINITIONS ///.
Definition giaTruth.c:66
Here is the call graph for this function:

◆ Gia_LutComputeTruth6Simple_rec()

word Gia_LutComputeTruth6Simple_rec ( Gia_Man_t * p,
int iObj )

FUNCTION DEFINITIONS ///.

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

Synopsis [Compute truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 66 of file giaTruth.c.

67{
68 word Truth0, Truth1, Truth;
69 Gia_Obj_t * pObj = Gia_ManObj(p, iObj);
70 if ( Gia_ObjIsConst0(pObj) )
71 return 0;
72 if ( Gia_ObjIsCi(pObj) )
73 return s_Truths6[Gia_ObjCioId(pObj)];
74 Truth0 = Gia_LutComputeTruth6Simple_rec( p, Gia_ObjFaninId0(pObj, iObj) );
75 Truth1 = Gia_LutComputeTruth6Simple_rec( p, Gia_ObjFaninId1(pObj, iObj) );
76 Truth0 = Gia_ObjFaninC0(pObj) ? ~Truth0 : Truth0;
77 Truth1 = Gia_ObjFaninC1(pObj) ? ~Truth1 : Truth1;
78 Truth = Gia_ObjIsXor(pObj) ? Truth0 ^ Truth1 : Truth0 & Truth1;
79 return Truth;
80}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManIsoNpnReduce()

Gia_Man_t * Gia_ManIsoNpnReduce ( Gia_Man_t * p,
Vec_Ptr_t ** pvPosEquivs,
int fVerbose )

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

Synopsis [Reduces GIA to contain isomorphic POs.]

Description [The root cannot be one of the leaves.]

SideEffects []

SeeAlso []

Definition at line 702 of file giaTruth.c.

703{
704 char pCanonPerm[16];
705 int i, iObj, uCanonPhase, nVars, lastId, truthId;
706 int IndexCon = -1, IndexVar = -1;
707 Vec_Wec_t * vPosEquivs = Vec_WecAlloc( 100 );
708 word * pTruth;
709 Gia_Obj_t * pObj;
710 Vec_Mem_t * vTtMem[17]; // truth table memory and hash table
711 Gia_Man_t * pNew = NULL;
712 Vec_Int_t * vLeaves = Vec_IntAlloc( 16 );
713 Vec_Int_t * vFirsts;
714 Vec_Int_t * vTt2Class[17];
715 for ( i = 0; i < 17; i++ )
716 {
717 vTtMem[i] = Vec_MemAlloc( Abc_TtWordNum(i), 10 );
718 Vec_MemHashAlloc( vTtMem[i], 1000 );
719 vTt2Class[i] = Vec_IntStartFull( Gia_ManCoNum(p)+1 );
720 }
722 Gia_ManForEachPo( p, pObj, i )
723 {
724 iObj = Gia_ObjId(p, pObj);
725 Gia_ManCollectCis( p, &iObj, 1, vLeaves );
726 if ( Vec_IntSize(vLeaves) > 16 )
727 {
728 Vec_IntPush( Vec_WecPushLevel(vPosEquivs), i );
729 continue;
730 }
731 pObj = Gia_ObjFanin0(pObj);
732 if ( Gia_ObjIsConst0(pObj) )
733 {
734 if ( IndexCon == -1 )
735 {
736 IndexCon = Vec_WecSize(vPosEquivs);
737 Vec_WecPushLevel(vPosEquivs);
738 }
739 Vec_WecPush( vPosEquivs, IndexCon, i );
740 continue;
741 }
742 if ( Gia_ObjIsCi(pObj) )
743 {
744 if ( IndexVar == -1 )
745 {
746 IndexVar = Vec_WecSize(vPosEquivs);
747 Vec_WecPushLevel(vPosEquivs);
748 }
749 Vec_WecPush( vPosEquivs, IndexVar, i );
750 continue;
751 }
752 assert( Gia_ObjIsAnd(pObj) );
753 pTruth = Gia_ObjComputeTruthTableCut( p, pObj, vLeaves );
754 Abc_TtMinimumBase( pTruth, NULL, Vec_IntSize(vLeaves), &nVars );
755 if ( nVars == 0 )
756 {
757 if ( IndexCon == -1 )
758 {
759 IndexCon = Vec_WecSize(vPosEquivs);
760 Vec_WecPushLevel(vPosEquivs);
761 }
762 Vec_WecPush( vPosEquivs, IndexCon, i );
763 continue;
764 }
765 if ( nVars == 1 )
766 {
767 if ( IndexVar == -1 )
768 {
769 IndexVar = Vec_WecSize(vPosEquivs);
770 Vec_WecPushLevel(vPosEquivs);
771 }
772 Vec_WecPush( vPosEquivs, IndexVar, i );
773 continue;
774 }
775 uCanonPhase = Abc_TtCanonicize( pTruth, nVars, pCanonPerm );
776 lastId = Vec_MemEntryNum( vTtMem[nVars] );
777 truthId = Vec_MemHashInsert( vTtMem[nVars], pTruth );
778 if ( lastId != Vec_MemEntryNum( vTtMem[nVars] ) ) // new one
779 {
780 assert( Vec_IntEntry(vTt2Class[nVars], truthId) == -1 );
781 Vec_IntWriteEntry( vTt2Class[nVars], truthId, Vec_WecSize(vPosEquivs) );
782 Vec_WecPushLevel(vPosEquivs);
783 }
784 assert( Vec_IntEntry(vTt2Class[nVars], truthId) >= 0 );
785 Vec_WecPush( vPosEquivs, Vec_IntEntry(vTt2Class[nVars], truthId), i );
786 }
788 Vec_IntFree( vLeaves );
789 for ( i = 0; i < 17; i++ )
790 {
791 Vec_MemHashFree( vTtMem[i] );
792 Vec_MemFree( vTtMem[i] );
793 Vec_IntFree( vTt2Class[i] );
794 }
795
796 // find the first outputs and derive GIA
797 vFirsts = Vec_WecCollectFirsts( vPosEquivs );
798 pNew = Gia_ManDupCones( p, Vec_IntArray(vFirsts), Vec_IntSize(vFirsts), 0 );
799 Vec_IntFree( vFirsts );
800 // report and return
801 if ( fVerbose )
802 {
803 printf( "Nontrivial classes:\n" );
804 Vec_WecPrint( vPosEquivs, 1 );
805 }
806 if ( pvPosEquivs )
807 *pvPosEquivs = Vec_WecConvertToVecPtr( vPosEquivs );
808 Vec_WecFree( vPosEquivs );
809 return pNew;
810}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
unsigned Abc_TtCanonicize(word *pTruth, int nVars, char *pCanonPerm)
FUNCTION DECLARATIONS ///.
Definition dauCanon.c:1036
void Gia_ObjComputeTruthTableStart(Gia_Man_t *p, int nVarsMax)
Definition giaTruth.c:552
word * Gia_ObjComputeTruthTableCut(Gia_Man_t *p, Gia_Obj_t *pRoot, Vec_Int_t *vLeaves)
Definition giaTruth.c:628
void Gia_ObjComputeTruthTableStop(Gia_Man_t *p)
Definition giaTruth.c:568
#define Gia_ManForEachPo(p, pObj, i)
Definition gia.h:1250
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManDupCones(Gia_Man_t *p, int *pPos, int nPos, int fTrimPis)
Definition giaDup.c:3880
void Gia_ManCollectCis(Gia_Man_t *p, int *pNodes, int nNodes, Vec_Int_t *vSupp)
Definition giaDfs.c:71
typedefABC_NAMESPACE_IMPL_START struct Vec_Mem_t_ Vec_Mem_t
DECLARATIONS ///.
Definition utilMem.c:35
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
Here is the call graph for this function:

◆ Gia_ObjCollectInternal()

void Gia_ObjCollectInternal ( Gia_Man_t * p,
Gia_Obj_t * pObj )

Definition at line 429 of file giaTruth.c.

430{
431 Vec_IntClear( p->vTtNodes );
433}
void Gia_ObjCollectInternal_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition giaTruth.c:417
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjCollectInternal_rec()

void Gia_ObjCollectInternal_rec ( Gia_Man_t * p,
Gia_Obj_t * pObj )

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

Synopsis [Collects internal nodes reachable from the given node.]

Description []

SideEffects []

SeeAlso []

Definition at line 417 of file giaTruth.c.

418{
419 if ( !Gia_ObjIsAnd(pObj) )
420 return;
421 if ( pObj->fMark0 )
422 return;
423 pObj->fMark0 = 1;
424 Gia_ObjCollectInternal_rec( p, Gia_ObjFanin0(pObj) );
425 Gia_ObjCollectInternal_rec( p, Gia_ObjFanin1(pObj) );
426 Gia_ObjSetNum( p, pObj, Vec_IntSize(p->vTtNodes) );
427 Vec_IntPush( p->vTtNodes, Gia_ObjId(p, pObj) );
428}
unsigned fMark0
Definition gia.h:81
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjCollectInternalCut()

void Gia_ObjCollectInternalCut ( Gia_Man_t * p,
int iRoot,
Vec_Int_t * vLeaves )

Definition at line 599 of file giaTruth.c.

600{
601 int i, iObj;
602 assert( !Gia_ObjHasNumId(p, iRoot) );
603 assert( Gia_ObjIsAnd(Gia_ManObj(p, iRoot)) );
604 Vec_IntForEachEntry( vLeaves, iObj, i )
605 {
606 if ( Gia_ObjHasNumId(p, iObj) ) // if cuts have repeated variables, skip
607 continue;
608 assert( !Gia_ObjHasNumId(p, iObj) );
609 Gia_ObjSetNumId( p, iObj, -i );
610 }
611 assert( !Gia_ObjHasNumId(p, iRoot) ); // the root cannot be one of the leaves
612 Vec_IntClear( p->vTtNodes );
613 Vec_IntPush( p->vTtNodes, -1 );
615}
void Gia_ObjCollectInternalCut_rec(Gia_Man_t *p, int iObj)
Definition giaTruth.c:589
#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_ObjCollectInternalCut_rec()

void Gia_ObjCollectInternalCut_rec ( Gia_Man_t * p,
int iObj )

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

Synopsis [Collects internal nodes reachable from the given node.]

Description []

SideEffects []

SeeAlso []

Definition at line 589 of file giaTruth.c.

590{
591 if ( Gia_ObjHasNumId(p, iObj) )
592 return;
593 assert( Gia_ObjIsAnd(Gia_ManObj(p, iObj)) );
594 Gia_ObjCollectInternalCut_rec( p, Gia_ObjFaninId0(Gia_ManObj(p, iObj), iObj) );
595 Gia_ObjCollectInternalCut_rec( p, Gia_ObjFaninId1(Gia_ManObj(p, iObj), iObj) );
596 Gia_ObjSetNumId( p, iObj, Vec_IntSize(p->vTtNodes) );
597 Vec_IntPush( p->vTtNodes, iObj );
598}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjComputeTruth6()

word Gia_ObjComputeTruth6 ( Gia_Man_t * p,
int iObj,
Vec_Int_t * vSupp,
Vec_Wrd_t * vTemp )

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

Synopsis [Computes truth table up to 6 inputs in terms of CIs.]

Description []

SideEffects []

SeeAlso []

Definition at line 316 of file giaTruth.c.

317{
318 int i, Fanin;
319 assert( Vec_WrdSize(vTemp) == Gia_ManObjNum(p) );
320 assert( Vec_IntSize(vSupp) <= 6 );
322 Vec_IntForEachEntry( vSupp, Fanin, i )
323 {
324 Gia_ObjSetTravIdCurrentId( p, Fanin );
325 Vec_WrdWriteEntry( vTemp, Fanin, s_Truth6[i] );
326 }
327 Gia_ObjComputeTruthTable6Lut_rec( p, iObj, vTemp );
328 return Vec_WrdEntry( vTemp, iObj );
329}
void Gia_ObjComputeTruthTable6Lut_rec(Gia_Man_t *p, int iObj, Vec_Wrd_t *vTemp)
Definition giaTruth.c:273
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjComputeTruth6Cis()

word Gia_ObjComputeTruth6Cis ( Gia_Man_t * p,
int iLit,
Vec_Int_t * vSupp,
Vec_Wrd_t * vTemp )

Definition at line 345 of file giaTruth.c.

346{
347 int iObj = Abc_Lit2Var(iLit);
348 Vec_IntClear( vSupp );
349 if ( !iObj ) return Abc_LitIsCompl(iLit) ? ~(word)0 : (word)0;
352 if ( Vec_IntSize(vSupp) > 6 )
353 return 0;
354 Gia_ObjComputeTruth6( p, iObj, vSupp, vTemp );
355 return Abc_LitIsCompl(iLit) ? ~Vec_WrdEntry(vTemp, iObj) : Vec_WrdEntry(vTemp, iObj);
356}
void Gia_ObjComputeTruth6CisSupport_rec(Gia_Man_t *p, int iObj, Vec_Int_t *vSupp)
Definition giaTruth.c:330
word Gia_ObjComputeTruth6(Gia_Man_t *p, int iObj, Vec_Int_t *vSupp, Vec_Wrd_t *vTemp)
Definition giaTruth.c:316
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjComputeTruth6CisSupport_rec()

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

Definition at line 330 of file giaTruth.c.

331{
332 Gia_Obj_t * pObj = Gia_ManObj( p, iObj );
333 if ( Gia_ObjIsTravIdCurrentId(p, iObj) )
334 return;
335 Gia_ObjSetTravIdCurrentId(p, iObj);
336 if ( Gia_ObjIsCi(pObj) )
337 {
338 Vec_IntPushOrder( vSupp, iObj );
339 return;
340 }
341 assert( Gia_ObjIsAnd(pObj) );
342 Gia_ObjComputeTruth6CisSupport_rec( p, Gia_ObjFaninId0p(p, pObj), vSupp );
343 Gia_ObjComputeTruth6CisSupport_rec( p, Gia_ObjFaninId1p(p, pObj), vSupp );
344}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjComputeTruthTable()

word * Gia_ObjComputeTruthTable ( Gia_Man_t * p,
Gia_Obj_t * pObj )

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

Synopsis [Computing the truth table for GIA object.]

Description [The truth table should be used by the calling application (or saved into the user's storage) before this procedure is called again.]

SideEffects []

SeeAlso []

Definition at line 447 of file giaTruth.c.

448{
449 Gia_Obj_t * pTemp, * pRoot;
450 word * pTruth, * pTruthL, * pTruth0, * pTruth1;
451 int i;
452 if ( p->vTtMemory == NULL )
453 {
454 p->nTtVars = Gia_ManPiNum( p );
455 p->nTtWords = Abc_Truth6WordNum( p->nTtVars );
456 p->vTtNums = Vec_IntStart( Gia_ManObjNum(p) + 1000 );
457 p->vTtNodes = Vec_IntAlloc( 256 );
458 p->vTtInputs = Vec_PtrAllocTruthTables( Abc_MaxInt(6, p->nTtVars) );
459 p->vTtMemory = Vec_WrdStart( p->nTtWords * 256 );
460 }
461 else
462 {
463 // make sure the number of primary inputs did not change
464 // since the truth table computation storage was prepared
465 assert( p->nTtVars == Gia_ManPiNum(p) );
466 }
467 // extend ID numbers
468 if ( Vec_IntSize(p->vTtNums) < Gia_ManObjNum(p) )
469 Vec_IntFillExtra( p->vTtNums, Gia_ManObjNum(p), 0 );
470 // collect internal nodes
471 pRoot = Gia_ObjIsCo(pObj) ? Gia_ObjFanin0(pObj) : pObj;
472 Gia_ObjCollectInternal( p, pRoot );
473 // extend TT storage
474 if ( Vec_WrdSize(p->vTtMemory) < p->nTtWords * (Vec_IntSize(p->vTtNodes) + 2) )
475 Vec_WrdFillExtra( p->vTtMemory, p->nTtWords * (Vec_IntSize(p->vTtNodes) + 2), 0 );
476 // compute the truth table for internal nodes
477 Gia_ManForEachObjVec( p->vTtNodes, p, pTemp, i )
478 {
479 pTemp->fMark0 = 0; // unmark nodes marked by Gia_ObjCollectInternal()
480 pTruth = Gla_ObjTruthNode(p, pTemp);
481 pTruthL = pTruth + p->nTtWords;
482 pTruth0 = Gia_ObjIsAnd(Gia_ObjFanin0(pTemp)) ? Gla_ObjTruthNode(p, Gia_ObjFanin0(pTemp)) : Gla_ObjTruthElem(p, Gia_ObjCioId(Gia_ObjFanin0(pTemp)) );
483 pTruth1 = Gia_ObjIsAnd(Gia_ObjFanin1(pTemp)) ? Gla_ObjTruthNode(p, Gia_ObjFanin1(pTemp)) : Gla_ObjTruthElem(p, Gia_ObjCioId(Gia_ObjFanin1(pTemp)) );
484 if ( Gia_ObjFaninC0(pTemp) )
485 {
486 if ( Gia_ObjFaninC1(pTemp) )
487 while ( pTruth < pTruthL )
488 *pTruth++ = ~*pTruth0++ & ~*pTruth1++;
489 else
490 while ( pTruth < pTruthL )
491 *pTruth++ = ~*pTruth0++ & *pTruth1++;
492 }
493 else
494 {
495 if ( Gia_ObjFaninC1(pTemp) )
496 while ( pTruth < pTruthL )
497 *pTruth++ = *pTruth0++ & ~*pTruth1++;
498 else
499 while ( pTruth < pTruthL )
500 *pTruth++ = *pTruth0++ & *pTruth1++;
501 }
502 }
503 // compute the final table
504 if ( Gia_ObjIsConst0(pRoot) )
505 pTruth = Gla_ObjTruthConst0( p, Gla_ObjTruthFree1(p) );
506 else if ( Gia_ObjIsPi(p, pRoot) )
507 pTruth = Gla_ObjTruthElem( p, Gia_ObjCioId(pRoot) );
508 else if ( Gia_ObjIsAnd(pRoot) )
509 pTruth = Gla_ObjTruthNode( p, pRoot );
510 else
511 pTruth = NULL;
512 return Gla_ObjTruthDup( p, Gla_ObjTruthFree2(p), pTruth, Gia_ObjIsCo(pObj) && Gia_ObjFaninC0(pObj) );
513}
void Gia_ObjCollectInternal(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition giaTruth.c:429
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition gia.h:1194
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjComputeTruthTable6()

word Gia_ObjComputeTruthTable6 ( Gia_Man_t * p,
Gia_Obj_t * pObj,
Vec_Int_t * vSupp,
Vec_Wrd_t * vTruths )

Definition at line 386 of file giaTruth.c.

387{
388 Gia_Obj_t * pLeaf;
389 int i;
390 assert( Vec_IntSize(vSupp) <= 6 );
391 assert( Gia_ObjIsAnd(pObj) );
392 assert( !pObj->fMark0 );
393 Vec_WrdClear( vTruths );
395 Gia_ManForEachObjVec( vSupp, p, pLeaf, i )
396 {
397 assert( pLeaf->fMark0 || Gia_ObjIsRo(p, pLeaf) );
398 pLeaf->Value = Vec_WrdSize(vTruths);
399 Vec_WrdPush( vTruths, s_Truth6[i] );
400 Gia_ObjSetTravIdCurrent(p, pLeaf);
401 }
402 Gia_ObjComputeTruthTable6_rec( p, pObj, vTruths );
403 return Vec_WrdEntryLast( vTruths );
404}
void Gia_ObjComputeTruthTable6_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Wrd_t *vTruths)
Definition giaTruth.c:369
unsigned Value
Definition gia.h:89
Here is the call graph for this function:

◆ Gia_ObjComputeTruthTable6_rec()

void Gia_ObjComputeTruthTable6_rec ( Gia_Man_t * p,
Gia_Obj_t * pObj,
Vec_Wrd_t * vTruths )

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

Synopsis [Computes truth table up to 6 inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 369 of file giaTruth.c.

370{
371 word uTruth0, uTruth1;
372 if ( Gia_ObjIsTravIdCurrent(p, pObj) )
373 return;
374 Gia_ObjSetTravIdCurrent(p, pObj);
375 assert( !pObj->fMark0 );
376 assert( Gia_ObjIsAnd(pObj) );
377 Gia_ObjComputeTruthTable6_rec( p, Gia_ObjFanin0(pObj), vTruths );
378 Gia_ObjComputeTruthTable6_rec( p, Gia_ObjFanin1(pObj), vTruths );
379 uTruth0 = Vec_WrdEntry( vTruths, Gia_ObjFanin0(pObj)->Value );
380 uTruth0 = Gia_ObjFaninC0(pObj) ? ~uTruth0 : uTruth0;
381 uTruth1 = Vec_WrdEntry( vTruths, Gia_ObjFanin1(pObj)->Value );
382 uTruth1 = Gia_ObjFaninC1(pObj) ? ~uTruth1 : uTruth1;
383 pObj->Value = Vec_WrdSize(vTruths);
384 Vec_WrdPush( vTruths, uTruth0 & uTruth1 );
385}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjComputeTruthTable6Lut()

word Gia_ObjComputeTruthTable6Lut ( Gia_Man_t * p,
int iObj,
Vec_Wrd_t * vTemp )

Definition at line 289 of file giaTruth.c.

290{
291 int i, Fanin;
292 assert( Vec_WrdSize(vTemp) == Gia_ManObjNum(p) );
293 assert( Gia_ObjIsLut(p, iObj) );
295 Gia_LutForEachFanin( p, iObj, Fanin, i )
296 {
297 Gia_ObjSetTravIdCurrentId( p, Fanin );
298 Vec_WrdWriteEntry( vTemp, Fanin, s_Truth6[i] );
299 }
300 assert( i <= 6 );
301 Gia_ObjComputeTruthTable6Lut_rec( p, iObj, vTemp );
302 return Vec_WrdEntry( vTemp, iObj );
303}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjComputeTruthTable6Lut_rec()

void Gia_ObjComputeTruthTable6Lut_rec ( Gia_Man_t * p,
int iObj,
Vec_Wrd_t * vTemp )

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

Synopsis [Computes truth table of a 6-LUT.]

Description []

SideEffects []

SeeAlso []

Definition at line 273 of file giaTruth.c.

274{
275 word uTruth0, uTruth1;
276 Gia_Obj_t * pObj = Gia_ManObj( p, iObj );
277 if ( Gia_ObjIsTravIdCurrentId(p, iObj) )
278 return;
279 Gia_ObjSetTravIdCurrentId(p, iObj);
280 assert( Gia_ObjIsAnd(pObj) );
281 Gia_ObjComputeTruthTable6Lut_rec( p, Gia_ObjFaninId0p(p, pObj), vTemp );
282 Gia_ObjComputeTruthTable6Lut_rec( p, Gia_ObjFaninId1p(p, pObj), vTemp );
283 uTruth0 = Vec_WrdEntry( vTemp, Gia_ObjFaninId0p(p, pObj) );
284 uTruth0 = Gia_ObjFaninC0(pObj) ? ~uTruth0 : uTruth0;
285 uTruth1 = Vec_WrdEntry( vTemp, Gia_ObjFaninId1p(p, pObj) );
286 uTruth1 = Gia_ObjFaninC1(pObj) ? ~uTruth1 : uTruth1;
287 Vec_WrdWriteEntry( vTemp, iObj, uTruth0 & uTruth1 );
288}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjComputeTruthTableCut()

word * Gia_ObjComputeTruthTableCut ( Gia_Man_t * p,
Gia_Obj_t * pRoot,
Vec_Int_t * vLeaves )

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

Synopsis [Computes the truth table of pRoot in terms of leaves.]

Description [The root cannot be one of the leaves.]

SideEffects []

SeeAlso []

Definition at line 628 of file giaTruth.c.

629{
630 Gia_Obj_t * pTemp;
631 word * pTruth, * pTruthL, * pTruth0, * pTruth1;
632 int i, iObj, Id0, Id1, Index = Vec_IntFind(vLeaves, Gia_ObjId(p, pRoot));
633 assert( p->vTtMemory != NULL );
634 assert( Vec_IntSize(vLeaves) <= p->nTtVars );
635 if ( Index >= 0 )
636 return Gla_ObjTruthElem( p, Index );
637 if ( Gia_ObjIsConst0(pRoot) )
638 {
639 if ( Vec_WrdSize(p->vTtMemory) < p->nTtWords )
640 Vec_WrdFillExtra( p->vTtMemory, p->nTtWords, 0 );
641 return Gla_ObjTruthConst0( p, Gla_ObjTruthFree1(p) );
642 }
643 assert( Gia_ObjIsAnd(pRoot) );
644 // extend ID numbers
645 if ( Vec_IntSize(p->vTtNums) < Gia_ManObjNum(p) )
646 Vec_IntFillExtra( p->vTtNums, Gia_ManObjNum(p), -ABC_INFINITY );
647 // collect internal nodes
648 Gia_ObjCollectInternalCut( p, Gia_ObjId(p, pRoot), vLeaves );
649 // extend TT storage
650 if ( Vec_WrdSize(p->vTtMemory) < p->nTtWords * (Vec_IntSize(p->vTtNodes) + 2) )
651 Vec_WrdFillExtra( p->vTtMemory, p->nTtWords * (Vec_IntSize(p->vTtNodes) + 2), 0 );
652 // compute the truth table for internal nodes
653 Vec_IntForEachEntryStart( p->vTtNodes, iObj, i, 1 )
654 {
655 assert( i == Gia_ObjNumId(p, iObj) );
656 pTemp = Gia_ManObj( p, iObj );
657 pTruth = Gla_ObjTruthNodeId( p, i );
658 pTruthL = pTruth + p->nTtWords;
659 Id0 = Gia_ObjNumId( p, Gia_ObjFaninId0(pTemp, iObj) );
660 Id1 = Gia_ObjNumId( p, Gia_ObjFaninId1(pTemp, iObj) );
661 pTruth0 = (Id0 > 0) ? Gla_ObjTruthNodeId(p, Id0) : Gla_ObjTruthElem(p, -Id0);
662 pTruth1 = (Id1 > 0) ? Gla_ObjTruthNodeId(p, Id1) : Gla_ObjTruthElem(p, -Id1);
663 if ( Gia_ObjFaninC0(pTemp) )
664 {
665 if ( Gia_ObjFaninC1(pTemp) )
666 while ( pTruth < pTruthL )
667 *pTruth++ = ~*pTruth0++ & ~*pTruth1++;
668 else
669 while ( pTruth < pTruthL )
670 *pTruth++ = ~*pTruth0++ & *pTruth1++;
671 }
672 else
673 {
674 if ( Gia_ObjFaninC1(pTemp) )
675 while ( pTruth < pTruthL )
676 *pTruth++ = *pTruth0++ & ~*pTruth1++;
677 else
678 while ( pTruth < pTruthL )
679 *pTruth++ = *pTruth0++ & *pTruth1++;
680 }
681 }
682 pTruth = Gla_ObjTruthNode( p, pRoot );
683 // unmark leaves marked by Gia_ObjCollectInternal()
684 Vec_IntForEachEntry( vLeaves, iObj, i )
685 Gia_ObjResetNumId( p, iObj );
686 Vec_IntForEachEntryStart( p->vTtNodes, iObj, i, 1 )
687 Gia_ObjResetNumId( p, iObj );
688 return pTruth;
689}
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
void Gia_ObjCollectInternalCut(Gia_Man_t *p, int iRoot, Vec_Int_t *vLeaves)
Definition giaTruth.c:599
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition vecInt.h:56
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjComputeTruthTableStart()

void Gia_ObjComputeTruthTableStart ( Gia_Man_t * p,
int nVarsMax )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 552 of file giaTruth.c.

553{
554 assert( p->vTtMemory == NULL );
555 p->nTtVars = nVarsMax;
556 p->nTtWords = Abc_Truth6WordNum( p->nTtVars );
557 p->vTtNodes = Vec_IntAlloc( 256 );
558 p->vTtInputs = Vec_PtrAllocTruthTables( Abc_MaxInt(6, p->nTtVars) );
559 p->vTtMemory = Vec_WrdStart( p->nTtWords * 64 );
560 p->vTtNums = Vec_IntAlloc( Gia_ManObjNum(p) + 1000 );
561 Vec_IntFill( p->vTtNums, Vec_IntCap(p->vTtNums), -ABC_INFINITY );
562 if ( nVarsMax >= 6 ) {
563 word * pTruth; int i;
564 Vec_PtrForEachEntry( word *, p->vTtInputs, pTruth, i )
565 Abc_TtFlipVar5( pTruth, nVarsMax );
566 }
567}
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the caller graph for this function:

◆ Gia_ObjComputeTruthTableStop()

void Gia_ObjComputeTruthTableStop ( Gia_Man_t * p)

Definition at line 568 of file giaTruth.c.

569{
570 p->nTtVars = 0;
571 p->nTtWords = 0;
572 Vec_IntFreeP( &p->vTtNums );
573 Vec_IntFreeP( &p->vTtNodes );
574 Vec_PtrFreeP( &p->vTtInputs );
575 Vec_WrdFreeP( &p->vTtMemory );
576}
Here is the caller graph for this function:

◆ Gia_ObjComputeTruthTableTest()

void Gia_ObjComputeTruthTableTest ( Gia_Man_t * p)

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

Synopsis [Testing truth table computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 526 of file giaTruth.c.

527{
528 Gia_Obj_t * pObj;
529 unsigned * pTruth;
530 abctime clk = Abc_Clock();
531 int i;
532 Gia_ManForEachPo( p, pObj, i )
533 {
534 pTruth = (unsigned *)Gia_ObjComputeTruthTable( p, pObj );
535// Extra_PrintHex( stdout, pTruth, Gia_ManPiNum(p) ); printf( "\n" );
536 }
537 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
538}
ABC_INT64_T abctime
Definition abc_global.h:332
word * Gia_ObjComputeTruthTable(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition giaTruth.c:447
Here is the call graph for this function:

◆ Gia_Truth5ToGia()

int Gia_Truth5ToGia ( Gia_Man_t * p,
int * pVarLits,
int nVars,
unsigned Truth,
int fHash )

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

Synopsis [Generate MUX tree of the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 121 of file giaTruth.c.

122{
123 int Var, Lit0, Lit1;
124 if ( Truth == 0 )
125 return 0;
126 if ( ~Truth == 0 )
127 return 1;
128 assert( nVars > 0 );
129 // find the topmost var
130 for ( Var = nVars-1; Var >= 0; Var-- )
131 if ( Abc_Tt5HasVar( Truth, Var ) )
132 break;
133 assert( Var >= 0 );
134 // cofactor
135 Lit0 = Gia_Truth5ToGia( p, pVarLits, Var, Abc_Tt5Cofactor0(Truth, Var), fHash );
136 Lit1 = Gia_Truth5ToGia( p, pVarLits, Var, Abc_Tt5Cofactor1(Truth, Var), fHash );
137 if ( fHash )
138 return Gia_ManHashMux( p, pVarLits[Var], Lit1, Lit0 );
139 else
140 return Gia_ManAppendMux( p, pVarLits[Var], Lit1, Lit0 );
141}
int Var
Definition exorList.c:228
int Gia_Truth5ToGia(Gia_Man_t *p, int *pVarLits, int nVars, unsigned Truth, int fHash)
Definition giaTruth.c:121
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition giaHash.c:692
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_Truth6ToGia()

int Gia_Truth6ToGia ( Gia_Man_t * p,
int * pVarLits,
int nVars,
word Truth,
int fHash )

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

Synopsis [Generate MUX tree of the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 154 of file giaTruth.c.

155{
156 int Var, Lit0, Lit1;
157 if ( Truth == 0 )
158 return 0;
159 if ( ~Truth == 0 )
160 return 1;
161 assert( nVars > 0 );
162 // find the topmost var
163 for ( Var = nVars-1; Var >= 0; Var-- )
164 if ( Abc_Tt6HasVar( Truth, Var ) )
165 break;
166 assert( Var >= 0 );
167 // cofactor
168 Lit0 = Gia_Truth6ToGia( p, pVarLits, Var, Abc_Tt6Cofactor0(Truth, Var), fHash );
169 Lit1 = Gia_Truth6ToGia( p, pVarLits, Var, Abc_Tt6Cofactor1(Truth, Var), fHash );
170 if ( fHash )
171 return Gia_ManHashMux( p, pVarLits[Var], Lit1, Lit0 );
172 else
173 return Gia_ManAppendMux( p, pVarLits[Var], Lit1, Lit0 );
174}
int Gia_Truth6ToGia(Gia_Man_t *p, int *pVarLits, int nVars, word Truth, int fHash)
Definition giaTruth.c:154
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_Truth6ToGiaTest()

void Gia_Truth6ToGiaTest ( Gia_Man_t * p)

Definition at line 175 of file giaTruth.c.

176{
177 int Size = 5;
178 word Truth, TruthNew;
179 Vec_Int_t * vMap = Vec_IntStartFull( Gia_ManCiNum(p) );
180 Vec_Int_t * vSupp = Vec_IntStart( 100 );
181 int nCos = Gia_ManCoNum(p), Count = 0;
182 int i, k, Id, ObjId, iLitNew;
184 Gia_ManForEachCoId( p, Id, i )
185 {
186 Gia_ManCollectCis( p, &Id, 1, vSupp ); // ObjIds
187 if ( Vec_IntSize(vSupp) <= Size && i < nCos )
188 {
189 int pVarLits[6];
190 Vec_IntForEachEntry( vSupp, ObjId, k )
191 {
192 int CioId = Gia_ObjCioId(Gia_ManObj(p, ObjId));
193 Vec_IntWriteEntry( vMap, CioId, k );
194 pVarLits[k] = Abc_Var2Lit( ObjId, 0 );
195 }
196 Truth = Gia_LutComputeTruth6Map( p, i, vMap );
197 if ( Size == 5 )
198 iLitNew = Gia_Truth5ToGia( p, pVarLits, Vec_IntSize(vSupp), (unsigned)Truth, 1 );
199 else
200 iLitNew = Gia_Truth6ToGia( p, pVarLits, Vec_IntSize(vSupp), Truth, 1 );
201 Gia_ManAppendCo( p, iLitNew );
202 TruthNew = Gia_LutComputeTruth6Map( p, Gia_ManCoNum(p)-1, vMap );
203 Vec_IntForEachEntry( vSupp, ObjId, k )
204 {
205 int CioId = Gia_ObjCioId(Gia_ManObj(p, ObjId));
206 Vec_IntWriteEntry( vMap, CioId, -1 );
207 }
208 if ( Truth != TruthNew )
209 printf( "Error for output %d.\n", i );
210 Count++;
211 //Dau_DsdPrintFromTruth( &Truth, Vec_IntSize(vSupp) );
212 }
213 }
215 printf( "Finished processing %d outputs.\n", Count );
216 Vec_IntFree( vSupp );
217 Vec_IntFree( vMap );
218}
word Gia_LutComputeTruth6Map(Gia_Man_t *p, int iPo, Vec_Int_t *vMap)
Definition giaTruth.c:103
#define Gia_ManForEachCoId(p, Id, i)
Definition gia.h:1240
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
Here is the call graph for this function: