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

Go to the source code of this file.

Classes

struct  Dss_Fun_t_
 
struct  Dss_Ent_t_
 
struct  Dss_Obj_t_
 
struct  Dss_Ntk_t_
 
struct  Dss_Man_t_
 

Macros

#define Dss_VecForEachObj(vVec, pObj, i)
 
#define Dss_VecForEachObjVec(vLits, vVec, pObj, i)
 
#define Dss_VecForEachNode(vVec, pObj, i)
 
#define Dss_ObjForEachFanin(vVec, pObj, pFanin, i)
 
#define Dss_ObjForEachChild(vVec, pObj, pFanin, i)
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Dss_Fun_t_ Dss_Fun_t
 DECLARATIONS ///.
 
typedef struct Dss_Ent_t_ Dss_Ent_t
 
typedef struct Dss_Obj_t_ Dss_Obj_t
 
typedef struct Dss_Ntk_t_ Dss_Ntk_t
 

Functions

Dss_Obj_tDss_ObjAllocNtk (Dss_Ntk_t *p, int Type, int nFans, int nTruthVars)
 
Dss_Obj_tDss_ObjCreateNtk (Dss_Ntk_t *p, int Type, Vec_Int_t *vFaninLits)
 
Dss_Ntk_tDss_NtkAlloc (int nVars)
 
void Dss_NtkFree (Dss_Ntk_t *p)
 
void Dss_NtkPrint_rec (Dss_Ntk_t *p, Dss_Obj_t *pObj)
 
void Dss_NtkPrint (Dss_Ntk_t *p)
 
int Dss_NtkCreate_rec (char *pStr, char **p, int *pMatches, Dss_Ntk_t *pNtk, word *pTruth)
 
Dss_Ntk_tDss_NtkCreate (char *pDsd, int nVars, word *pTruth)
 
int Dss_ObjCompare (Vec_Ptr_t *p, Dss_Obj_t *p0i, Dss_Obj_t *p1i)
 
void Dss_ObjSort (Vec_Ptr_t *p, Dss_Obj_t **pNodes, int nNodes, int *pPerm)
 
void Dss_NtkCheck (Dss_Ntk_t *p)
 
int Dss_NtkCollectPerm_rec (Dss_Ntk_t *p, Dss_Obj_t *pObj, int *pPermDsd, int *pnPerms)
 
void Dss_NtkTransform (Dss_Ntk_t *p, int *pPermDsd)
 
Dss_Obj_tDss_ObjAlloc (Dss_Man_t *p, int Type, int nFans, int nTruthVars)
 
Dss_Obj_tDss_ObjCreate (Dss_Man_t *p, int Type, Vec_Int_t *vFaninLits, word *pTruth)
 
void Dss_ManHashProfile (Dss_Man_t *p)
 
unsigned * Dss_ObjHashLookup (Dss_Man_t *p, int Type, Vec_Int_t *vFaninLits, word *pTruth)
 
Dss_Obj_tDss_ObjFindOrAdd (Dss_Man_t *p, int Type, Vec_Int_t *vFaninLits, word *pTruth)
 
void Dss_ManCacheAlloc (Dss_Man_t *p)
 
void Dss_ManCacheFree (Dss_Man_t *p)
 
void Dss_ManCacheProfile (Dss_Man_t *p)
 
Dss_Ent_t ** Dss_ManCacheLookup (Dss_Man_t *p, Dss_Ent_t *pEnt)
 
Dss_Ent_tDss_ManCacheCreate (Dss_Man_t *p, Dss_Ent_t *pEnt0, Dss_Fun_t *pFun0)
 
Dss_Man_tDss_ManAlloc (int nVars, int nNonDecLimit)
 
void Dss_ManFree (Dss_Man_t *p)
 
void Dss_ManPrint_rec (FILE *pFile, Dss_Man_t *p, Dss_Obj_t *pObj, int *pPermLits, int *pnSupp)
 
void Dss_ManPrintOne (FILE *pFile, Dss_Man_t *p, int iDsdLit, int *pPermLits)
 
int Dss_ManCheckNonDec_rec (Dss_Man_t *p, Dss_Obj_t *pObj)
 
void Dss_ManDump (Dss_Man_t *p)
 
void Dss_ManPrint (char *pFileName, Dss_Man_t *p)
 
void Dss_ManComputeTruth_rec (Dss_Man_t *p, Dss_Obj_t *pObj, int nVars, word *pRes, int *pPermLits, int *pnSupp)
 
wordDss_ManComputeTruth (Dss_Man_t *p, int iDsd, int nVars, int *pPermLits)
 
int Dss_NtkRebuild_rec (Dss_Man_t *p, Dss_Ntk_t *pNtk, Dss_Obj_t *pObj)
 
int Dss_NtkRebuild (Dss_Man_t *p, Dss_Ntk_t *pNtk)
 
int Dss_ManOperation (Dss_Man_t *p, int Type, int *pLits, int nLits, unsigned char *pPerm, word *pTruth)
 
Dss_Fun_tDss_ManOperationFun (Dss_Man_t *p, int *iDsd, int nFansTot)
 
void Dss_EntPrint (Dss_Ent_t *p, Dss_Fun_t *pFun)
 
Dss_Fun_tDss_ManBooleanAnd (Dss_Man_t *p, Dss_Ent_t *pEnt, int Counter)
 
Dss_Ent_tDss_ManSharedMap (Dss_Man_t *p, int *iDsd, int *nFans, int **pFans, unsigned uSharedMask)
 
int Dss_ManMerge (Dss_Man_t *p, int *iDsd, int *nFans, int **pFans, unsigned uSharedMask, int nKLutSize, unsigned char *pPermRes, word *pTruth)
 
Dss_Ent_tDss_ManSharedMapDerive (Dss_Man_t *p, int iDsd0, int iDsd1, Vec_Str_t *vShared)
 
int Mpm_FuncCompute (Dss_Man_t *p, int iDsd0, int iDsd1, Vec_Str_t *vShared, int *pPerm, int *pnLeaves)
 
int Dss_ObjCheckTransparent (Dss_Man_t *p, Dss_Obj_t *pObj)
 
void Dau_DsdTest__ ()
 
void Dau_DsdTest ()
 
void Dau_DsdTest444 ()
 

Macro Definition Documentation

◆ Dss_ObjForEachChild

#define Dss_ObjForEachChild ( vVec,
pObj,
pFanin,
i )
Value:
for ( i = 0; (i < Dss_ObjFaninNum(pObj)) && ((pFanin) = Dss_ObjChild(vVec, pObj, i)); i++ )

Definition at line 136 of file dauTree.c.

136#define Dss_ObjForEachChild( vVec, pObj, pFanin, i ) \
137 for ( i = 0; (i < Dss_ObjFaninNum(pObj)) && ((pFanin) = Dss_ObjChild(vVec, pObj, i)); i++ )

◆ Dss_ObjForEachFanin

#define Dss_ObjForEachFanin ( vVec,
pObj,
pFanin,
i )
Value:
for ( i = 0; (i < Dss_ObjFaninNum(pObj)) && ((pFanin) = Dss_ObjFanin(vVec, pObj, i)); i++ )

Definition at line 134 of file dauTree.c.

134#define Dss_ObjForEachFanin( vVec, pObj, pFanin, i ) \
135 for ( i = 0; (i < Dss_ObjFaninNum(pObj)) && ((pFanin) = Dss_ObjFanin(vVec, pObj, i)); i++ )

◆ Dss_VecForEachNode

#define Dss_VecForEachNode ( vVec,
pObj,
i )
Value:
Vec_PtrForEachEntry( Dss_Obj_t *, vVec, pObj, i ) \
if ( pObj->Type == DAU_DSD_CONST0 || pObj->Type == DAU_DSD_VAR ) {} else
struct Dss_Obj_t_ Dss_Obj_t
Definition dauTree.c:51
@ DAU_DSD_VAR
Definition dau.h:54
@ DAU_DSD_CONST0
Definition dau.h:53
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55

Definition at line 131 of file dauTree.c.

131#define Dss_VecForEachNode( vVec, pObj, i ) \
132 Vec_PtrForEachEntry( Dss_Obj_t *, vVec, pObj, i ) \
133 if ( pObj->Type == DAU_DSD_CONST0 || pObj->Type == DAU_DSD_VAR ) {} else

◆ Dss_VecForEachObj

#define Dss_VecForEachObj ( vVec,
pObj,
i )
Value:
Vec_PtrForEachEntry( Dss_Obj_t *, vVec, pObj, i )

Definition at line 127 of file dauTree.c.

127#define Dss_VecForEachObj( vVec, pObj, i ) \
128 Vec_PtrForEachEntry( Dss_Obj_t *, vVec, pObj, i )

◆ Dss_VecForEachObjVec

#define Dss_VecForEachObjVec ( vLits,
vVec,
pObj,
i )
Value:
for ( i = 0; (i < Vec_IntSize(vLits)) && ((pObj) = Dss_Lit2Obj(vVec, Vec_IntEntry(vLits,i))); i++ )

Definition at line 129 of file dauTree.c.

129#define Dss_VecForEachObjVec( vLits, vVec, pObj, i ) \
130 for ( i = 0; (i < Vec_IntSize(vLits)) && ((pObj) = Dss_Lit2Obj(vVec, Vec_IntEntry(vLits,i))); i++ )

Typedef Documentation

◆ Dss_Ent_t

typedef struct Dss_Ent_t_ Dss_Ent_t

Definition at line 39 of file dauTree.c.

◆ Dss_Fun_t

typedef typedefABC_NAMESPACE_IMPL_START struct Dss_Fun_t_ Dss_Fun_t

DECLARATIONS ///.

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

FileName [dauTree.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [DAG-aware unmapping.]

Synopsis [Canonical DSD package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 31 of file dauTree.c.

◆ Dss_Ntk_t

typedef struct Dss_Ntk_t_ Dss_Ntk_t

Definition at line 65 of file dauTree.c.

◆ Dss_Obj_t

typedef struct Dss_Obj_t_ Dss_Obj_t

Definition at line 51 of file dauTree.c.

Function Documentation

◆ Dau_DsdTest()

void Dau_DsdTest ( )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1841 of file dauTree.c.

1842{
1843 int nVars = 8;
1844 Vec_Vec_t * vFuncs;
1845 Vec_Int_t * vOne, * vTwo, * vRes;//, * vThree;
1846 Dss_Man_t * p;
1847 int pEntries[3];
1848 int iLit, e0, e1;//, e2;
1849 int i, k, s;//, j;
1850
1851 return;
1852
1853 vFuncs = Vec_VecStart( nVars+1 );
1854 assert( nVars < DAU_MAX_VAR );
1855 p = Dss_ManAlloc( nVars, 0 );
1856
1857 // init
1858 Vec_VecPushInt( vFuncs, 1, Dss_Obj2Lit(Dss_VecVar(p->vObjs,0)) );
1859
1860 // enumerate
1861 for ( s = 2; s <= nVars; s++ )
1862 {
1863 vRes = Vec_VecEntryInt( vFuncs, s );
1864 for ( i = 1; i < s; i++ )
1865 for ( k = i; k < s; k++ )
1866 if ( i + k == s )
1867 {
1868 vOne = Vec_VecEntryInt( vFuncs, i );
1869 vTwo = Vec_VecEntryInt( vFuncs, k );
1870 Vec_IntForEachEntry( vOne, pEntries[0], e0 )
1871 Vec_IntForEachEntry( vTwo, pEntries[1], e1 )
1872 {
1873 int fAddInv0 = !Dss_ObjCheckTransparent( p, Dss_VecObj(p->vObjs, Abc_Lit2Var(pEntries[0])) );
1874 int fAddInv1 = !Dss_ObjCheckTransparent( p, Dss_VecObj(p->vObjs, Abc_Lit2Var(pEntries[1])) );
1875
1876 iLit = Dss_ManOperation( p, DAU_DSD_AND, pEntries, 2, NULL, NULL );
1877 assert( !Abc_LitIsCompl(iLit) );
1878 Vec_IntPush( vRes, iLit );
1879
1880 if ( fAddInv0 )
1881 {
1882 pEntries[0] = Abc_LitNot( pEntries[0] );
1883 iLit = Dss_ManOperation( p, DAU_DSD_AND, pEntries, 2, NULL, NULL );
1884 pEntries[0] = Abc_LitNot( pEntries[0] );
1885 assert( !Abc_LitIsCompl(iLit) );
1886 Vec_IntPush( vRes, iLit );
1887 }
1888
1889 if ( fAddInv1 )
1890 {
1891 pEntries[1] = Abc_LitNot( pEntries[1] );
1892 iLit = Dss_ManOperation( p, DAU_DSD_AND, pEntries, 2, NULL, NULL );
1893 pEntries[1] = Abc_LitNot( pEntries[1] );
1894 assert( !Abc_LitIsCompl(iLit) );
1895 Vec_IntPush( vRes, iLit );
1896 }
1897
1898 if ( fAddInv0 && fAddInv1 )
1899 {
1900 pEntries[0] = Abc_LitNot( pEntries[0] );
1901 pEntries[1] = Abc_LitNot( pEntries[1] );
1902 iLit = Dss_ManOperation( p, DAU_DSD_AND, pEntries, 2, NULL, NULL );
1903 pEntries[0] = Abc_LitNot( pEntries[0] );
1904 pEntries[1] = Abc_LitNot( pEntries[1] );
1905 assert( !Abc_LitIsCompl(iLit) );
1906 Vec_IntPush( vRes, iLit );
1907 }
1908
1909 iLit = Dss_ManOperation( p, DAU_DSD_XOR, pEntries, 2, NULL, NULL );
1910 assert( !Abc_LitIsCompl(iLit) );
1911 Vec_IntPush( vRes, Abc_LitRegular(iLit) );
1912 }
1913 }
1914/*
1915 for ( i = 1; i < s; i++ )
1916 for ( k = 1; k < s; k++ )
1917 for ( j = 1; j < s; j++ )
1918 if ( i + k + j == s )
1919 {
1920 vOne = Vec_VecEntryInt( vFuncs, i );
1921 vTwo = Vec_VecEntryInt( vFuncs, k );
1922 vThree = Vec_VecEntryInt( vFuncs, j );
1923 Vec_IntForEachEntry( vOne, pEntries[0], e0 )
1924 Vec_IntForEachEntry( vTwo, pEntries[1], e1 )
1925 Vec_IntForEachEntry( vThree, pEntries[2], e2 )
1926 {
1927 int fAddInv0 = !Dss_ObjCheckTransparent( p, Dss_VecObj(p->vObjs, Abc_Lit2Var(pEntries[0])) );
1928 int fAddInv1 = !Dss_ObjCheckTransparent( p, Dss_VecObj(p->vObjs, Abc_Lit2Var(pEntries[1])) );
1929 int fAddInv2 = !Dss_ObjCheckTransparent( p, Dss_VecObj(p->vObjs, Abc_Lit2Var(pEntries[2])) );
1930
1931 if ( !fAddInv0 && k > j )
1932 continue;
1933
1934 iLit = Dss_ManOperation( p, DAU_DSD_MUX, pEntries, 3, NULL, NULL );
1935 assert( !Abc_LitIsCompl(iLit) );
1936 Vec_IntPush( vRes, iLit );
1937
1938 if ( fAddInv1 )
1939 {
1940 pEntries[1] = Abc_LitNot( pEntries[1] );
1941 iLit = Dss_ManOperation( p, DAU_DSD_MUX, pEntries, 3, NULL, NULL );
1942 pEntries[1] = Abc_LitNot( pEntries[1] );
1943 assert( !Abc_LitIsCompl(iLit) );
1944 Vec_IntPush( vRes, iLit );
1945 }
1946
1947 if ( fAddInv2 )
1948 {
1949 pEntries[2] = Abc_LitNot( pEntries[2] );
1950 iLit = Dss_ManOperation( p, DAU_DSD_MUX, pEntries, 3, NULL, NULL );
1951 pEntries[2] = Abc_LitNot( pEntries[2] );
1952 assert( !Abc_LitIsCompl(iLit) );
1953 Vec_IntPush( vRes, iLit );
1954 }
1955 }
1956 }
1957*/
1958 Vec_IntUniqify( vRes );
1959 }
1960 Dss_ManPrint( "_npn/npn/dsdcanon.txt", p );
1961
1962 Dss_ManFree( p );
1963 Vec_VecFree( vFuncs );
1964}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Dss_ManPrint(char *pFileName, Dss_Man_t *p)
Definition dauTree.c:1086
int Dss_ObjCheckTransparent(Dss_Man_t *p, Dss_Obj_t *pObj)
Definition dauTree.c:1776
Dss_Man_t * Dss_ManAlloc(int nVars, int nNonDecLimit)
Definition dauTree.c:967
int Dss_ManOperation(Dss_Man_t *p, int Type, int *pLits, int nLits, unsigned char *pPerm, word *pTruth)
Definition dauTree.c:1287
void Dss_ManFree(Dss_Man_t *p)
Definition dauTree.c:987
struct Dss_Man_t_ Dss_Man_t
Definition dau.h:61
@ DAU_DSD_XOR
Definition dau.h:56
@ DAU_DSD_AND
Definition dau.h:55
#define DAU_MAX_VAR
INCLUDES ///.
Definition dau.h:42
Cube * p
Definition exorList.c:222
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42
Here is the call graph for this function:

◆ Dau_DsdTest444()

void Dau_DsdTest444 ( )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1978 of file dauTree.c.

1979{
1980 Dss_Man_t * p = Dss_ManAlloc( 6, 0 );
1981 int iLit1[3] = { 2, 4 };
1982 int iLit2[3] = { 2, 4, 6 };
1983 int iRes[5];
1984 int nFans[2] = { 4, 3 };
1985 int pPermLits1[4] = { 0, 2, 5, 6 };
1986 int pPermLits2[5] = { 2, 9, 10 };
1987 int * pPermLits[2] = { pPermLits1, pPermLits2 };
1988 unsigned char pPermRes[6];
1989 int pPermResInt[6];
1990 unsigned uMaskShared = 2;
1991 int i;
1992
1993 iRes[0] = 1 ^ Dss_ManOperation( p, DAU_DSD_AND, iLit1, 2, NULL, NULL );
1994 iRes[1] = iRes[0];
1995 iRes[2] = 1 ^ Dss_ManOperation( p, DAU_DSD_AND, iRes, 2, NULL, NULL );
1996 iRes[3] = Dss_ManOperation( p, DAU_DSD_AND, iLit2, 3, NULL, NULL );
1997
1998 Dss_ManPrintOne( stdout, p, iRes[0], NULL );
1999 Dss_ManPrintOne( stdout, p, iRes[2], NULL );
2000 Dss_ManPrintOne( stdout, p, iRes[3], NULL );
2001
2002 Dss_ManPrintOne( stdout, p, iRes[2], pPermLits1 );
2003 Dss_ManPrintOne( stdout, p, iRes[3], pPermLits2 );
2004
2005 iRes[4] = Dss_ManMerge( p, iRes+2, nFans, pPermLits, uMaskShared, 6, pPermRes, NULL );
2006
2007 for ( i = 0; i < 6; i++ )
2008 pPermResInt[i] = pPermRes[i];
2009
2010 Dss_ManPrintOne( stdout, p, iRes[4], NULL );
2011 Dss_ManPrintOne( stdout, p, iRes[4], pPermResInt );
2012
2013 Dss_ManFree( p );
2014}
int Dss_ManMerge(Dss_Man_t *p, int *iDsd, int *nFans, int **pFans, unsigned uSharedMask, int nKLutSize, unsigned char *pPermRes, word *pTruth)
Definition dauTree.c:1539
void Dss_ManPrintOne(FILE *pFile, Dss_Man_t *p, int iDsdLit, int *pPermLits)
Definition dauTree.c:1030
Here is the call graph for this function:

◆ Dau_DsdTest__()

void Dau_DsdTest__ ( )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1816 of file dauTree.c.

1817{
1818 int nVars = 8;
1819// char * pDsd = "[(ab)(cd)]";
1820 char * pDsd = "(!(a!(bh))[cde]!(fg))";
1821 Dss_Ntk_t * pNtk = Dss_NtkCreate( pDsd, nVars, NULL );
1822// Dss_NtkPrint( pNtk );
1823// Dss_NtkCheck( pNtk );
1824// Dss_NtkTransform( pNtk );
1825// Dss_NtkPrint( pNtk );
1826 Dss_NtkFree( pNtk );
1827 nVars = 0;
1828}
Dss_Ntk_t * Dss_NtkCreate(char *pDsd, int nVars, word *pTruth)
Definition dauTree.c:601
struct Dss_Ntk_t_ Dss_Ntk_t
Definition dauTree.c:65
void Dss_NtkFree(Dss_Ntk_t *p)
Definition dauTree.c:472
Here is the call graph for this function:

◆ Dss_EntPrint()

void Dss_EntPrint ( Dss_Ent_t * p,
Dss_Fun_t * pFun )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1411 of file dauTree.c.

1412{
1413 int i;
1414 printf( "%d %d ", p->iDsd0, p->iDsd1 );
1415 for ( i = 0; i < (int)p->nShared; i++ )
1416 printf( "%d=%d ", p->pShared[2*i], p->pShared[2*i+1] );
1417 printf( "-> %d ", pFun->iDsd );
1418}

◆ Dss_ManAlloc()

Dss_Man_t * Dss_ManAlloc ( int nVars,
int nNonDecLimit )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 967 of file dauTree.c.

968{
969 Dss_Man_t * p;
970 p = ABC_CALLOC( Dss_Man_t, 1 );
971 p->nVars = nVars;
972 p->nNonDecLimit = nNonDecLimit;
973 p->nBins = Abc_PrimeCudd( 1000000 );
974 p->pBins = ABC_CALLOC( unsigned, p->nBins );
975 p->pMem = Mem_FlexStart();
976 p->vObjs = Vec_PtrAlloc( 10000 );
977 p->vNexts = Vec_IntAlloc( 10000 );
978 Dss_ObjAlloc( p, DAU_DSD_CONST0, 0, 0 );
979 Dss_ObjAlloc( p, DAU_DSD_VAR, 0, 0 )->nSupp = 1;
980 p->vLeaves = Vec_IntAlloc( 32 );
981 p->vCopies = Vec_IntAlloc( 32 );
982 p->pTtElems = Dss_ManTtElems();
983 p->pMemEnts = Mem_FlexStart();
984// Dss_ManCacheAlloc( p );
985 return p;
986}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Dss_Obj_t * Dss_ObjAlloc(Dss_Man_t *p, int Type, int nFans, int nTruthVars)
Definition dauTree.c:760
Mem_Flex_t * Mem_FlexStart()
Definition mem.c:327
unsigned nSupp
Definition dauTree.c:56
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManBooleanAnd()

Dss_Fun_t * Dss_ManBooleanAnd ( Dss_Man_t * p,
Dss_Ent_t * pEnt,
int Counter )

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

Synopsis [Performs AND on two DSD functions with support overlap.]

Description [Returns the perm of the resulting literals. The perm size is equal to the number of support variables. The perm variables are 0-based numbers of pLits[0] followed by nLits[0]-based numbers of pLits[1].]

SideEffects []

SeeAlso []

Definition at line 1433 of file dauTree.c.

1434{
1435 static char Buffer[100];
1436 Dss_Fun_t * pFun = (Dss_Fun_t *)Buffer;
1437 Dss_Ntk_t * pNtk;
1438 word * pTruthOne, pTruth[DAU_MAX_WORD];
1439 char pDsd[DAU_MAX_STR];
1440 int pMapDsd2Truth[DAU_MAX_VAR];
1441 int pPermLits[DAU_MAX_VAR];
1442 int pPermDsd[DAU_MAX_VAR];
1443 int i, nNonDec, nSuppSize = 0;
1444 int nFans[2];
1445 nFans[0] = Dss_VecLitSuppSize( p->vObjs, pEnt->iDsd0 );
1446 nFans[1] = Dss_VecLitSuppSize( p->vObjs, pEnt->iDsd1 );
1447 // create first truth table
1448 for ( i = 0; i < nFans[0]; i++ )
1449 {
1450 pMapDsd2Truth[nSuppSize] = i;
1451 pPermLits[i] = Abc_Var2Lit( nSuppSize++, 0 );
1452 }
1453 pTruthOne = Dss_ManComputeTruth( p, pEnt->iDsd0, p->nVars, pPermLits );
1454 Abc_TtCopy( pTruth, pTruthOne, Abc_TtWordNum(p->nVars), 0 );
1455if ( Counter )
1456{
1457//Kit_DsdPrintFromTruth( pTruthOne, p->nVars ); printf( "\n" );
1458}
1459 // create second truth table
1460 for ( i = 0; i < nFans[1]; i++ )
1461 pPermLits[i] = -1;
1462 for ( i = 0; i < (int)pEnt->nShared; i++ )
1463 pPermLits[pEnt->pShared[2*i+0]] = pEnt->pShared[2*i+1];
1464 for ( i = 0; i < nFans[1]; i++ )
1465 if ( pPermLits[i] == -1 )
1466 {
1467 pMapDsd2Truth[nSuppSize] = nFans[0] + i;
1468 pPermLits[i] = Abc_Var2Lit( nSuppSize++, 0 );
1469 }
1470 pTruthOne = Dss_ManComputeTruth( p, pEnt->iDsd1, p->nVars, pPermLits );
1471if ( Counter )
1472{
1473//Kit_DsdPrintFromTruth( pTruthOne, p->nVars ); printf( "\n" );
1474}
1475 Abc_TtAnd( pTruth, pTruth, pTruthOne, Abc_TtWordNum(p->nVars), 0 );
1476 // perform decomposition
1477 nNonDec = Dau_DsdDecompose( pTruth, nSuppSize, 0, 0, pDsd );
1478 if ( p->nNonDecLimit && nNonDec > p->nNonDecLimit )
1479 return NULL;
1480 // derive network and convert it into the manager
1481 pNtk = Dss_NtkCreate( pDsd, p->nVars, nNonDec ? pTruth : NULL );
1482//Dss_NtkPrint( pNtk );
1483 Dss_NtkCheck( pNtk );
1484 Dss_NtkTransform( pNtk, pPermDsd );
1485//Dss_NtkPrint( pNtk );
1486 pFun->iDsd = Dss_NtkRebuild( p, pNtk );
1487 Dss_NtkFree( pNtk );
1488 // pPermDsd maps vars of iDsdRes into literals of pTruth
1489 // translate this map into the one that maps vars of iDsdRes into literals of cut
1490 pFun->nFans = Dss_VecLitSuppSize( p->vObjs, pFun->iDsd );
1491 for ( i = 0; i < (int)pFun->nFans; i++ )
1492 pFun->pFans[i] = (unsigned char)Abc_Lit2LitV( pMapDsd2Truth, pPermDsd[i] );
1493
1494// Dss_EntPrint( pEnt, pFun );
1495 return pFun;
1496}
int Dss_NtkRebuild(Dss_Man_t *p, Dss_Ntk_t *pNtk)
Definition dauTree.c:1264
void Dss_NtkTransform(Dss_Ntk_t *p, int *pPermDsd)
Definition dauTree.c:725
void Dss_NtkCheck(Dss_Ntk_t *p)
Definition dauTree.c:692
typedefABC_NAMESPACE_IMPL_START struct Dss_Fun_t_ Dss_Fun_t
DECLARATIONS ///.
Definition dauTree.c:31
word * Dss_ManComputeTruth(Dss_Man_t *p, int iDsd, int nVars, int *pPermLits)
Definition dauTree.c:1192
#define DAU_MAX_WORD
Definition dau.h:44
int Dau_DsdDecompose(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
Definition dauDsd.c:1912
#define DAU_MAX_STR
Definition dau.h:43
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
unsigned iDsd1
Definition dauTree.c:46
unsigned nShared
Definition dauTree.c:47
unsigned char pShared[0]
Definition dauTree.c:48
unsigned iDsd0
Definition dauTree.c:44
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManCacheAlloc()

void Dss_ManCacheAlloc ( Dss_Man_t * p)

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

Synopsis [Cache for decomposition calls.]

Description []

SideEffects []

SeeAlso []

Definition at line 890 of file dauTree.c.

891{
892 assert( p->nCache == 0 );
893 p->nCache = Abc_PrimeCudd( 100000 );
894 p->pCache = ABC_CALLOC( Dss_Ent_t *, p->nCache );
895}
struct Dss_Ent_t_ Dss_Ent_t
Definition dauTree.c:39

◆ Dss_ManCacheCreate()

Dss_Ent_t * Dss_ManCacheCreate ( Dss_Man_t * p,
Dss_Ent_t * pEnt0,
Dss_Fun_t * pFun0 )

Definition at line 944 of file dauTree.c.

945{
946 Dss_Ent_t * pEnt = (Dss_Ent_t *)Mem_FlexEntryFetch( p->pMemEnts, sizeof(word) * pEnt0->nWords );
947 Dss_Fun_t * pFun = (Dss_Fun_t *)Mem_FlexEntryFetch( p->pMemEnts, sizeof(word) * Dss_FunWordNum(pFun0) );
948 memcpy( pEnt, pEnt0, sizeof(word) * pEnt0->nWords );
949 memcpy( pFun, pFun0, sizeof(word) * Dss_FunWordNum(pFun0) );
950 pEnt->pFunc = pFun;
951 pEnt->pNext = NULL;
952 p->nCacheEntries[pEnt->nShared!=0]++;
953 return pEnt;
954}
char * Mem_FlexEntryFetch(Mem_Flex_t *p, int nBytes)
Definition mem.c:388
unsigned nWords
Definition dauTree.c:45
Dss_Fun_t * pFunc
Definition dauTree.c:42
Dss_Ent_t * pNext
Definition dauTree.c:43
char * memcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManCacheFree()

void Dss_ManCacheFree ( Dss_Man_t * p)

Definition at line 896 of file dauTree.c.

897{
898 if ( p->pCache == NULL )
899 return;
900 assert( p->nCache != 0 );
901 p->nCache = 0;
902 ABC_FREE( p->pCache );
903}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Dss_ManCacheLookup()

Dss_Ent_t ** Dss_ManCacheLookup ( Dss_Man_t * p,
Dss_Ent_t * pEnt )

Definition at line 927 of file dauTree.c.

928{
929 Dss_Ent_t ** pSpot = p->pCache + Dss_ManCacheHashKey( p, pEnt );
930 for ( ; *pSpot; pSpot = &(*pSpot)->pNext )
931 {
932 if ( (*pSpot)->iDsd0 == pEnt->iDsd0 &&
933 (*pSpot)->iDsd1 == pEnt->iDsd1 &&
934 (*pSpot)->nShared == pEnt->nShared &&
935 !memcmp((*pSpot)->pShared, pEnt->pShared, sizeof(char)*2*pEnt->nShared) ) // equal
936 {
937 p->nCacheHits[pEnt->nShared!=0]++;
938 return pSpot;
939 }
940 }
941 p->nCacheMisses[pEnt->nShared!=0]++;
942 return pSpot;
943}
int memcmp()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManCacheProfile()

void Dss_ManCacheProfile ( Dss_Man_t * p)

Definition at line 913 of file dauTree.c.

914{
915 Dss_Ent_t ** pSpot;
916 int i, Counter;
917 for ( i = 0; i < p->nCache; i++ )
918 {
919 Counter = 0;
920 for ( pSpot = p->pCache + i; *pSpot; pSpot = &(*pSpot)->pNext, Counter++ )
921 ;
922 if ( Counter )
923 printf( "%d ", Counter );
924 }
925 printf( "\n" );
926}

◆ Dss_ManCheckNonDec_rec()

int Dss_ManCheckNonDec_rec ( Dss_Man_t * p,
Dss_Obj_t * pObj )

Definition at line 1040 of file dauTree.c.

1041{
1042 Dss_Obj_t * pFanin;
1043 int i;
1044 assert( !Dss_IsComplement(pObj) );
1045 if ( pObj->Type == DAU_DSD_CONST0 )
1046 return 0;
1047 if ( pObj->Type == DAU_DSD_VAR )
1048 return 0;
1049 if ( pObj->Type == DAU_DSD_PRIME )
1050 return 1;
1051 Dss_ObjForEachFanin( p->vObjs, pObj, pFanin, i )
1052 if ( Dss_ManCheckNonDec_rec( p, pFanin ) )
1053 return 1;
1054 return 0;
1055}
int Dss_ManCheckNonDec_rec(Dss_Man_t *p, Dss_Obj_t *pObj)
Definition dauTree.c:1040
#define Dss_ObjForEachFanin(vVec, pObj, pFanin, i)
Definition dauTree.c:134
@ DAU_DSD_PRIME
Definition dau.h:58
unsigned Type
Definition dauTree.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManComputeTruth()

word * Dss_ManComputeTruth ( Dss_Man_t * p,
int iDsd,
int nVars,
int * pPermLits )

Definition at line 1192 of file dauTree.c.

1193{
1194 Dss_Obj_t * pObj = Dss_Lit2Obj(p->vObjs, iDsd);
1195 word * pRes = p->pTtElems[DAU_MAX_VAR];
1196 int nWords = Abc_TtWordNum( nVars );
1197 int nSupp = 0;
1198 assert( nVars <= DAU_MAX_VAR );
1199 if ( iDsd == 0 )
1200 Abc_TtConst0( pRes, nWords );
1201 else if ( iDsd == 1 )
1202 Abc_TtConst1( pRes, nWords );
1203 else if ( Dss_Regular(pObj)->Type == DAU_DSD_VAR )
1204 {
1205 int iPermLit = pPermLits[nSupp++];
1206 Abc_TtCopy( pRes, p->pTtElems[Abc_Lit2Var(iPermLit)], nWords, Abc_LitIsCompl(iDsd) ^ Abc_LitIsCompl(iPermLit) );
1207 }
1208 else
1209 Dss_ManComputeTruth_rec( p, pObj, nVars, pRes, pPermLits, &nSupp );
1210 assert( nSupp == (int)Dss_Regular(pObj)->nSupp );
1211 return pRes;
1212}
int nWords
Definition abcNpn.c:127
void Dss_ManComputeTruth_rec(Dss_Man_t *p, Dss_Obj_t *pObj, int nVars, word *pRes, int *pPermLits, int *pnSupp)
Definition dauTree.c:1139
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManComputeTruth_rec()

void Dss_ManComputeTruth_rec ( Dss_Man_t * p,
Dss_Obj_t * pObj,
int nVars,
word * pRes,
int * pPermLits,
int * pnSupp )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1139 of file dauTree.c.

1140{
1141 Dss_Obj_t * pChild;
1142 int nWords = Abc_TtWordNum(nVars);
1143 int i, fCompl = Dss_IsComplement(pObj);
1144 pObj = Dss_Regular(pObj);
1145 if ( pObj->Type == DAU_DSD_VAR )
1146 {
1147 int iPermLit = pPermLits[(*pnSupp)++];
1148 assert( (*pnSupp) <= nVars );
1149 Abc_TtCopy( pRes, p->pTtElems[Abc_Lit2Var(iPermLit)], nWords, fCompl ^ Abc_LitIsCompl(iPermLit) );
1150 return;
1151 }
1152 if ( pObj->Type == DAU_DSD_AND || pObj->Type == DAU_DSD_XOR )
1153 {
1154 word pTtTemp[DAU_MAX_WORD];
1155 if ( pObj->Type == DAU_DSD_AND )
1156 Abc_TtConst1( pRes, nWords );
1157 else
1158 Abc_TtConst0( pRes, nWords );
1159 Dss_ObjForEachChild( p->vObjs, pObj, pChild, i )
1160 {
1161 Dss_ManComputeTruth_rec( p, pChild, nVars, pTtTemp, pPermLits, pnSupp );
1162 if ( pObj->Type == DAU_DSD_AND )
1163 Abc_TtAnd( pRes, pRes, pTtTemp, nWords, 0 );
1164 else
1165 Abc_TtXor( pRes, pRes, pTtTemp, nWords, 0 );
1166 }
1167 if ( fCompl ) Abc_TtNot( pRes, nWords );
1168 return;
1169 }
1170 if ( pObj->Type == DAU_DSD_MUX ) // mux
1171 {
1172 word pTtTemp[3][DAU_MAX_WORD];
1173 Dss_ObjForEachChild( p->vObjs, pObj, pChild, i )
1174 Dss_ManComputeTruth_rec( p, pChild, nVars, pTtTemp[i], pPermLits, pnSupp );
1175 assert( i == 3 );
1176 Abc_TtMux( pRes, pTtTemp[0], pTtTemp[1], pTtTemp[2], nWords );
1177 if ( fCompl ) Abc_TtNot( pRes, nWords );
1178 return;
1179 }
1180 if ( pObj->Type == DAU_DSD_PRIME ) // function
1181 {
1182 word pFanins[DAU_MAX_VAR][DAU_MAX_WORD];
1183 Dss_ObjForEachChild( p->vObjs, pObj, pChild, i )
1184 Dss_ManComputeTruth_rec( p, pChild, nVars, pFanins[i], pPermLits, pnSupp );
1185 Dau_DsdTruthCompose_rec( Dss_ObjTruth(pObj), pFanins, pRes, pObj->nFans, nWords );
1186 if ( fCompl ) Abc_TtNot( pRes, nWords );
1187 return;
1188 }
1189 assert( 0 );
1190
1191}
#define Dss_ObjForEachChild(vVec, pObj, pFanin, i)
Definition dauTree.c:136
void Dau_DsdTruthCompose_rec(word *pFunc, word pFanins[DAU_MAX_VAR][DAU_MAX_WORD], word *pRes, int nVars, int nWordsR)
Definition dauDsd.c:501
@ DAU_DSD_MUX
Definition dau.h:57
unsigned nFans
Definition dauTree.c:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManDump()

void Dss_ManDump ( Dss_Man_t * p)

Definition at line 1056 of file dauTree.c.

1057{
1058 char * pFileName = "dss_tts.txt";
1059 FILE * pFile;
1060 word Temp[DAU_MAX_WORD];
1061 Dss_Obj_t * pObj;
1062 int i;
1063 pFile = fopen( pFileName, "wb" );
1064 if ( pFile == NULL )
1065 {
1066 printf( "Cannot open file \"%s\".\n", pFileName );
1067 return;
1068 }
1069 Dss_VecForEachObj( p->vObjs, pObj, i )
1070 {
1071 if ( pObj->Type != DAU_DSD_PRIME )
1072 continue;
1073 Abc_TtCopy( Temp, Dss_ObjTruth(pObj), Abc_TtWordNum(pObj->nFans), 0 );
1074 Abc_TtStretch6( Temp, pObj->nFans, p->nVars );
1075 fprintf( pFile, "0x" );
1076 Abc_TtPrintHexRev( pFile, Temp, p->nVars );
1077 fprintf( pFile, "\n" );
1078
1079// printf( "%6d : ", i );
1080// Abc_TtPrintHexRev( stdout, Temp, p->nVars );
1081// printf( " " );
1082// Dau_DsdPrintFromTruth( stdout, Temp, p->nVars );
1083 }
1084 fclose( pFile );
1085}
#define Dss_VecForEachObj(vVec, pObj, i)
Definition dauTree.c:127

◆ Dss_ManFree()

void Dss_ManFree ( Dss_Man_t * p)

Definition at line 987 of file dauTree.c.

988{
989 Abc_PrintTime( 1, "Time begin ", p->timeBeg );
990 Abc_PrintTime( 1, "Time decomp", p->timeDec );
991 Abc_PrintTime( 1, "Time lookup", p->timeLook );
992 Abc_PrintTime( 1, "Time end ", p->timeEnd );
993
994// Dss_ManCacheProfile( p );
996 Mem_FlexStop( p->pMemEnts, 0 );
997 Vec_IntFreeP( &p->vCopies );
998 Vec_IntFreeP( &p->vLeaves );
999 Vec_IntFreeP( &p->vNexts );
1000 Vec_PtrFreeP( &p->vObjs );
1001 Mem_FlexStop( p->pMem, 0 );
1002 ABC_FREE( p->pBins );
1003 ABC_FREE( p );
1004}
void Dss_ManCacheFree(Dss_Man_t *p)
Definition dauTree.c:896
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Definition mem.c:359
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManHashProfile()

void Dss_ManHashProfile ( Dss_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 821 of file dauTree.c.

822{
823 Dss_Obj_t * pObj;
824 unsigned * pSpot;
825 int i, Counter;
826 for ( i = 0; i < p->nBins; i++ )
827 {
828 Counter = 0;
829 for ( pSpot = p->pBins + i; *pSpot; pSpot = (unsigned *)Vec_IntEntryP(p->vNexts, pObj->Id), Counter++ )
830 pObj = Dss_VecObj( p->vObjs, *pSpot );
831 if ( Counter )
832 printf( "%d ", Counter );
833 }
834 printf( "\n" );
835}
unsigned Id
Definition dauTree.c:54

◆ Dss_ManMerge()

int Dss_ManMerge ( Dss_Man_t * p,
int * iDsd,
int * nFans,
int ** pFans,
unsigned uSharedMask,
int nKLutSize,
unsigned char * pPermRes,
word * pTruth )

Definition at line 1539 of file dauTree.c.

1540{
1541 int fVerbose = 0;
1542 int fCheck = 0;
1543 static int Counter = 0;
1544// word pTtTemp[DAU_MAX_WORD];
1545 word * pTruthOne;
1546 int pPermResInt[DAU_MAX_VAR];
1547 Dss_Ent_t * pEnt, ** ppSpot;
1548 Dss_Fun_t * pFun;
1549 int i;
1550 abctime clk;
1551 Counter++;
1552 if ( DAU_MAX_VAR < nKLutSize )
1553 {
1554 printf( "Parameter DAU_MAX_VAR (%d) smaller than LUT size (%d).\n", DAU_MAX_VAR, nKLutSize );
1555 return -1;
1556 }
1557 assert( iDsd[0] <= iDsd[1] );
1558
1559if ( fVerbose )
1560{
1561Dss_ManPrintOne( stdout, p, iDsd[0], pFans[0] );
1562Dss_ManPrintOne( stdout, p, iDsd[1], pFans[1] );
1563}
1564
1565 // constant argument
1566 if ( iDsd[0] == 0 ) return 0;
1567 if ( iDsd[0] == 1 ) return iDsd[1];
1568 if ( iDsd[1] == 0 ) return 0;
1569 if ( iDsd[1] == 1 ) return iDsd[0];
1570
1571 // no overlap
1572clk = Abc_Clock();
1573 assert( nFans[0] == Dss_VecLitSuppSize(p->vObjs, iDsd[0]) );
1574 assert( nFans[1] == Dss_VecLitSuppSize(p->vObjs, iDsd[1]) );
1575 assert( nFans[0] + nFans[1] <= nKLutSize + Dss_WordCountOnes(uSharedMask) );
1576 // create map of shared variables
1577 pEnt = Dss_ManSharedMap( p, iDsd, nFans, pFans, uSharedMask );
1578p->timeBeg += Abc_Clock() - clk;
1579 // check cache
1580 if ( p->pCache == NULL )
1581 {
1582clk = Abc_Clock();
1583 if ( uSharedMask == 0 )
1584 pFun = Dss_ManOperationFun( p, iDsd, nFans[0] + nFans[1] );
1585 else
1586 pFun = Dss_ManBooleanAnd( p, pEnt, 0 );
1587 if ( pFun == NULL )
1588 return -1;
1589 assert( (int)pFun->nFans == Dss_VecLitSuppSize(p->vObjs, pFun->iDsd) );
1590 assert( (int)pFun->nFans <= nKLutSize );
1591p->timeDec += Abc_Clock() - clk;
1592 }
1593 else
1594 {
1595clk = Abc_Clock();
1596 ppSpot = Dss_ManCacheLookup( p, pEnt );
1597p->timeLook += Abc_Clock() - clk;
1598clk = Abc_Clock();
1599 if ( *ppSpot == NULL )
1600 {
1601 if ( uSharedMask == 0 )
1602 pFun = Dss_ManOperationFun( p, iDsd, nFans[0] + nFans[1] );
1603 else
1604 pFun = Dss_ManBooleanAnd( p, pEnt, 0 );
1605 if ( pFun == NULL )
1606 return -1;
1607 assert( (int)pFun->nFans == Dss_VecLitSuppSize(p->vObjs, pFun->iDsd) );
1608 assert( (int)pFun->nFans <= nKLutSize );
1609 // create cache entry
1610 *ppSpot = Dss_ManCacheCreate( p, pEnt, pFun );
1611 }
1612 pFun = (*ppSpot)->pFunc;
1613p->timeDec += Abc_Clock() - clk;
1614 }
1615
1616clk = Abc_Clock();
1617 for ( i = 0; i < (int)pFun->nFans; i++ )
1618 if ( pFun->pFans[i] < 2 * nFans[0] ) // first dec
1619 pPermRes[i] = (unsigned char)Dss_Lit2Lit( pFans[0], pFun->pFans[i] );
1620 else
1621 pPermRes[i] = (unsigned char)Dss_Lit2Lit( pFans[1], pFun->pFans[i] - 2 * nFans[0] );
1622 // perform support minimization
1623 if ( uSharedMask && pFun->nFans > 1 )
1624 {
1625 int pVarPres[DAU_MAX_VAR];
1626 int nSupp = 0;
1627 for ( i = 0; i < p->nVars; i++ )
1628 pVarPres[i] = -1;
1629 for ( i = 0; i < (int)pFun->nFans; i++ )
1630 pVarPres[ Abc_Lit2Var(pPermRes[i]) ] = i;
1631 for ( i = 0; i < p->nVars; i++ )
1632 if ( pVarPres[i] >= 0 )
1633 pPermRes[pVarPres[i]] = Abc_Var2Lit( nSupp++, Abc_LitIsCompl(pPermRes[pVarPres[i]]) );
1634 assert( nSupp == (int)pFun->nFans );
1635 }
1636
1637 for ( i = 0; i < (int)pFun->nFans; i++ )
1638 pPermResInt[i] = pPermRes[i];
1639p->timeEnd += Abc_Clock() - clk;
1640
1641if ( fVerbose )
1642{
1643Dss_ManPrintOne( stdout, p, pFun->iDsd, pPermResInt );
1644printf( "\n" );
1645}
1646
1647if ( Counter == 43418 )
1648{
1649// int s = 0;
1650// Dss_ManPrint( NULL, p );
1651}
1652
1653
1654 if ( fCheck )
1655 {
1656 pTruthOne = Dss_ManComputeTruth( p, pFun->iDsd, p->nVars, pPermResInt );
1657 if ( !Abc_TtEqual( pTruthOne, pTruth, Abc_TtWordNum(p->nVars) ) )
1658 {
1659 int s;
1660 // Kit_DsdPrintFromTruth( pTruthOne, p->nVars ); printf( "\n" );
1661 // Kit_DsdPrintFromTruth( pTruth, p->nVars ); printf( "\n" );
1662 printf( "Verification failed.\n" );
1663 s = 0;
1664 }
1665 }
1666 return pFun->iDsd;
1667}
ABC_INT64_T abctime
Definition abc_global.h:332
Dss_Ent_t * Dss_ManSharedMap(Dss_Man_t *p, int *iDsd, int *nFans, int **pFans, unsigned uSharedMask)
Definition dauTree.c:1510
Dss_Ent_t ** Dss_ManCacheLookup(Dss_Man_t *p, Dss_Ent_t *pEnt)
Definition dauTree.c:927
Dss_Fun_t * Dss_ManBooleanAnd(Dss_Man_t *p, Dss_Ent_t *pEnt, int Counter)
Definition dauTree.c:1433
Dss_Fun_t * Dss_ManOperationFun(Dss_Man_t *p, int *iDsd, int nFansTot)
Definition dauTree.c:1389
Dss_Ent_t * Dss_ManCacheCreate(Dss_Man_t *p, Dss_Ent_t *pEnt0, Dss_Fun_t *pFun0)
Definition dauTree.c:944
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManOperation()

int Dss_ManOperation ( Dss_Man_t * p,
int Type,
int * pLits,
int nLits,
unsigned char * pPerm,
word * pTruth )

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

Synopsis [Performs DSD operation on the two literals.]

Description [Returns the perm of the resulting literals. The perm size is equal to the number of support variables. The perm variables are 0-based numbers of pLits[0] followed by nLits[0]-based numbers of pLits[1].]

SideEffects []

SeeAlso []

Definition at line 1287 of file dauTree.c.

1288{
1289 Dss_Obj_t * pChildren[DAU_MAX_VAR];
1290 Dss_Obj_t * pObj, * pChild;
1291 int i, k, nChildren = 0, fCompl = 0, fComplFan;
1292
1293 assert( Type == DAU_DSD_AND || pPerm == NULL );
1294 if ( Type == DAU_DSD_AND && pPerm != NULL )
1295 {
1296 int pBegEnd[DAU_MAX_VAR];
1297 int j, nSSize = 0;
1298 for ( k = 0; k < nLits; k++ )
1299 {
1300 pObj = Dss_Lit2Obj(p->vObjs, pLits[k]);
1301 if ( Dss_IsComplement(pObj) || pObj->Type != DAU_DSD_AND )
1302 {
1303 fComplFan = (Dss_Regular(pObj)->Type == DAU_DSD_VAR && Dss_IsComplement(pObj));
1304 if ( fComplFan )
1305 pObj = Dss_Regular(pObj);
1306 pBegEnd[nChildren] = (nSSize << 16) | (fComplFan << 8) | (nSSize + Dss_Regular(pObj)->nSupp);
1307 nSSize += Dss_Regular(pObj)->nSupp;
1308 pChildren[nChildren++] = pObj;
1309 }
1310 else
1311 Dss_ObjForEachChild( p->vObjs, pObj, pChild, i )
1312 {
1313 fComplFan = (Dss_Regular(pChild)->Type == DAU_DSD_VAR && Dss_IsComplement(pChild));
1314 if ( fComplFan )
1315 pChild = Dss_Regular(pChild);
1316 pBegEnd[nChildren] = (nSSize << 16) | (fComplFan << 8) | (nSSize + Dss_Regular(pChild)->nSupp);
1317 nSSize += Dss_Regular(pChild)->nSupp;
1318 pChildren[nChildren++] = pChild;
1319 }
1320 }
1321 Dss_ObjSort( p->vObjs, pChildren, nChildren, pBegEnd );
1322 // create permutation
1323 for ( j = i = 0; i < nChildren; i++ )
1324 for ( k = (pBegEnd[i] >> 16); k < (pBegEnd[i] & 0xFF); k++ )
1325 pPerm[j++] = (unsigned char)Abc_Var2Lit( k, (pBegEnd[i] >> 8) & 1 );
1326 assert( j == nSSize );
1327 }
1328 else if ( Type == DAU_DSD_AND )
1329 {
1330 for ( k = 0; k < nLits; k++ )
1331 {
1332 pObj = Dss_Lit2Obj(p->vObjs, pLits[k]);
1333 if ( Dss_IsComplement(pObj) || pObj->Type != DAU_DSD_AND )
1334 pChildren[nChildren++] = pObj;
1335 else
1336 Dss_ObjForEachChild( p->vObjs, pObj, pChild, i )
1337 pChildren[nChildren++] = pChild;
1338 }
1339 Dss_ObjSort( p->vObjs, pChildren, nChildren, NULL );
1340 }
1341 else if ( Type == DAU_DSD_XOR )
1342 {
1343 for ( k = 0; k < nLits; k++ )
1344 {
1345 fCompl ^= Abc_LitIsCompl(pLits[k]);
1346 pObj = Dss_Lit2Obj(p->vObjs, Abc_LitRegular(pLits[k]));
1347 if ( pObj->Type != DAU_DSD_XOR )
1348 pChildren[nChildren++] = pObj;
1349 else
1350 Dss_ObjForEachChild( p->vObjs, pObj, pChild, i )
1351 {
1352 assert( !Dss_IsComplement(pChild) );
1353 pChildren[nChildren++] = pChild;
1354 }
1355 }
1356 Dss_ObjSort( p->vObjs, pChildren, nChildren, NULL );
1357 }
1358 else if ( Type == DAU_DSD_MUX )
1359 {
1360 if ( Abc_LitIsCompl(pLits[0]) )
1361 {
1362 pLits[0] = Abc_LitNot(pLits[0]);
1363 ABC_SWAP( int, pLits[1], pLits[2] );
1364 }
1365 if ( Abc_LitIsCompl(pLits[1]) )
1366 {
1367 pLits[1] = Abc_LitNot(pLits[1]);
1368 pLits[2] = Abc_LitNot(pLits[2]);
1369 fCompl ^= 1;
1370 }
1371 for ( k = 0; k < nLits; k++ )
1372 pChildren[nChildren++] = Dss_Lit2Obj(p->vObjs, pLits[k]);
1373 }
1374 else if ( Type == DAU_DSD_PRIME )
1375 {
1376 for ( k = 0; k < nLits; k++ )
1377 pChildren[nChildren++] = Dss_Lit2Obj(p->vObjs, pLits[k]);
1378 }
1379 else assert( 0 );
1380
1381 // shift subgraphs
1382 Vec_IntClear( p->vLeaves );
1383 for ( i = 0; i < nChildren; i++ )
1384 Vec_IntPush( p->vLeaves, Dss_Obj2Lit(pChildren[i]) );
1385 // create new graph
1386 pObj = Dss_ObjFindOrAdd( p, Type, p->vLeaves, pTruth );
1387 return Abc_Var2Lit( pObj->Id, fCompl );
1388}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
void Dss_ObjSort(Vec_Ptr_t *p, Dss_Obj_t **pNodes, int nNodes, int *pPerm)
Definition dauTree.c:664
Dss_Obj_t * Dss_ObjFindOrAdd(Dss_Man_t *p, int Type, Vec_Int_t *vFaninLits, word *pTruth)
Definition dauTree.c:868
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManOperationFun()

Dss_Fun_t * Dss_ManOperationFun ( Dss_Man_t * p,
int * iDsd,
int nFansTot )

Definition at line 1389 of file dauTree.c.

1390{
1391 static char Buffer[100];
1392 Dss_Fun_t * pFun = (Dss_Fun_t *)Buffer;
1393 pFun->iDsd = Dss_ManOperation( p, DAU_DSD_AND, iDsd, 2, pFun->pFans, NULL );
1394//printf( "%d %d -> %d ", iDsd[0], iDsd[1], pFun->iDsd );
1395 pFun->nFans = nFansTot;
1396 assert( (int)pFun->nFans == Dss_VecLitSuppSize(p->vObjs, pFun->iDsd) );
1397 return pFun;
1398}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManPrint()

void Dss_ManPrint ( char * pFileName,
Dss_Man_t * p )

Definition at line 1086 of file dauTree.c.

1087{
1088 Dss_Obj_t * pObj;
1089 int CountNonDsd = 0, CountNonDsdStr = 0;
1090 int i, clk = Abc_Clock();
1091 FILE * pFile;
1092 pFile = pFileName ? fopen( pFileName, "wb" ) : stdout;
1093 if ( pFileName && pFile == NULL )
1094 {
1095 printf( "cannot open output file\n" );
1096 return;
1097 }
1098 Dss_VecForEachObj( p->vObjs, pObj, i )
1099 {
1100 CountNonDsd += (pObj->Type == DAU_DSD_PRIME);
1101 CountNonDsdStr += Dss_ManCheckNonDec_rec( p, pObj );
1102 }
1103 fprintf( pFile, "Total number of objects = %8d\n", Vec_PtrSize(p->vObjs) );
1104 fprintf( pFile, "Non-DSD objects (max =%2d) = %8d\n", p->nNonDecLimit, CountNonDsd );
1105 fprintf( pFile, "Non-DSD structures = %8d\n", CountNonDsdStr );
1106 fprintf( pFile, "Memory used for objects = %6.2f MB.\n", 1.0*Mem_FlexReadMemUsage(p->pMem)/(1<<20) );
1107 fprintf( pFile, "Memory used for array = %6.2f MB.\n", 1.0*sizeof(void *)*Vec_PtrCap(p->vObjs)/(1<<20) );
1108 fprintf( pFile, "Memory used for hash table = %6.2f MB.\n", 1.0*sizeof(int)*p->nBins/(1<<20) );
1109 fprintf( pFile, "Memory used for cache = %6.2f MB.\n", 1.0*Mem_FlexReadMemUsage(p->pMemEnts)/(1<<20) );
1110 fprintf( pFile, "Cache hits = %8d %8d\n", p->nCacheHits[0], p->nCacheHits[1] );
1111 fprintf( pFile, "Cache misses = %8d %8d\n", p->nCacheMisses[0], p->nCacheMisses[1] );
1112 fprintf( pFile, "Cache entries = %8d %8d\n", p->nCacheEntries[0], p->nCacheEntries[1] );
1113 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1114// Dss_ManHashProfile( p );
1115// Dss_ManDump( p );
1116// return;
1117 Dss_VecForEachObj( p->vObjs, pObj, i )
1118 {
1119 if ( i == 50 )
1120 break;
1121 Dss_ManPrintOne( pFile, p, Dss_Obj2Lit(pObj), NULL );
1122 }
1123 fprintf( pFile, "\n" );
1124 if ( pFileName )
1125 fclose( pFile );
1126}
int Mem_FlexReadMemUsage(Mem_Flex_t *p)
Definition mem.c:461
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManPrint_rec()

void Dss_ManPrint_rec ( FILE * pFile,
Dss_Man_t * p,
Dss_Obj_t * pObj,
int * pPermLits,
int * pnSupp )

Definition at line 1005 of file dauTree.c.

1006{
1007 char OpenType[7] = {0, 0, 0, '(', '[', '<', '{'};
1008 char CloseType[7] = {0, 0, 0, ')', ']', '>', '}'};
1009 Dss_Obj_t * pFanin;
1010 int i;
1011 assert( !Dss_IsComplement(pObj) );
1012 if ( pObj->Type == DAU_DSD_CONST0 )
1013 { fprintf( pFile, "0" ); return; }
1014 if ( pObj->Type == DAU_DSD_VAR )
1015 {
1016 int iPermLit = pPermLits ? pPermLits[(*pnSupp)++] : Abc_Var2Lit((*pnSupp)++, 0);
1017 fprintf( pFile, "%s%c", Abc_LitIsCompl(iPermLit)? "!":"", 'a' + Abc_Lit2Var(iPermLit) );
1018 return;
1019 }
1020 if ( pObj->Type == DAU_DSD_PRIME )
1021 Abc_TtPrintHexRev( pFile, Dss_ObjTruth(pObj), pObj->nFans );
1022 fprintf( pFile, "%c", OpenType[pObj->Type] );
1023 Dss_ObjForEachFanin( p->vObjs, pObj, pFanin, i )
1024 {
1025 fprintf( pFile, "%s", Dss_ObjFaninC(pObj, i) ? "!":"" );
1026 Dss_ManPrint_rec( pFile, p, pFanin, pPermLits, pnSupp );
1027 }
1028 fprintf( pFile, "%c", CloseType[pObj->Type] );
1029}
void Dss_ManPrint_rec(FILE *pFile, Dss_Man_t *p, Dss_Obj_t *pObj, int *pPermLits, int *pnSupp)
Definition dauTree.c:1005
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManPrintOne()

void Dss_ManPrintOne ( FILE * pFile,
Dss_Man_t * p,
int iDsdLit,
int * pPermLits )

Definition at line 1030 of file dauTree.c.

1031{
1032 int nSupp = 0;
1033 fprintf( pFile, "%6d : ", Abc_Lit2Var(iDsdLit) );
1034 fprintf( pFile, "%2d ", Dss_VecLitSuppSize(p->vObjs, iDsdLit) );
1035 fprintf( pFile, "%s", Abc_LitIsCompl(iDsdLit) ? "!" : "" );
1036 Dss_ManPrint_rec( pFile, p, Dss_VecObj(p->vObjs, Abc_Lit2Var(iDsdLit)), pPermLits, &nSupp );
1037 fprintf( pFile, "\n" );
1038 assert( nSupp == (int)Dss_VecObj(p->vObjs, Abc_Lit2Var(iDsdLit))->nSupp );
1039}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManSharedMap()

Dss_Ent_t * Dss_ManSharedMap ( Dss_Man_t * p,
int * iDsd,
int * nFans,
int ** pFans,
unsigned uSharedMask )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1510 of file dauTree.c.

1511{
1512 static char Buffer[100];
1513 Dss_Ent_t * pEnt = (Dss_Ent_t *)Buffer;
1514 pEnt->iDsd0 = iDsd[0];
1515 pEnt->iDsd1 = iDsd[1];
1516 pEnt->nShared = 0;
1517 if ( uSharedMask )
1518 {
1519 int i, g, pMapGtoL[DAU_MAX_VAR] = {-1};
1520 for ( i = 0; i < nFans[0]; i++ )
1521 pMapGtoL[ Abc_Lit2Var(pFans[0][i]) ] = Abc_Var2Lit( i, Abc_LitIsCompl(pFans[0][i]) );
1522 for ( i = 0; i < nFans[1]; i++ )
1523 {
1524 g = Abc_Lit2Var( pFans[1][i] );
1525 if ( (uSharedMask >> g) & 1 )
1526 {
1527 assert( pMapGtoL[g] >= 0 );
1528 pEnt->pShared[2*pEnt->nShared+0] = (unsigned char)i;
1529 pEnt->pShared[2*pEnt->nShared+1] = (unsigned char)Abc_LitNotCond( pMapGtoL[g], Abc_LitIsCompl(pFans[1][i]) );
1530 pEnt->nShared++;
1531 }
1532 }
1533 }
1534 pEnt->nWords = Dss_EntWordNum( pEnt );
1535 return pEnt;
1536}
Here is the caller graph for this function:

◆ Dss_ManSharedMapDerive()

Dss_Ent_t * Dss_ManSharedMapDerive ( Dss_Man_t * p,
int iDsd0,
int iDsd1,
Vec_Str_t * vShared )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1681 of file dauTree.c.

1682{
1683 static char Buffer[100];
1684 Dss_Ent_t * pEnt = (Dss_Ent_t *)Buffer;
1685 pEnt->iDsd0 = iDsd0;
1686 pEnt->iDsd1 = iDsd1;
1687 pEnt->nShared = Vec_StrSize(vShared)/2;
1688 memcpy( pEnt->pShared, (unsigned char *)Vec_StrArray(vShared), sizeof(char) * Vec_StrSize(vShared) );
1689 pEnt->nWords = Dss_EntWordNum( pEnt );
1690 return pEnt;
1691}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_NtkAlloc()

Dss_Ntk_t * Dss_NtkAlloc ( int nVars)

Definition at line 453 of file dauTree.c.

454{
455 Dss_Ntk_t * p;
456 Dss_Obj_t * pObj;
457 int i;
458 p = ABC_CALLOC( Dss_Ntk_t, 1 );
459 p->nVars = nVars;
460 p->nMemAlloc = DAU_MAX_STR;
461 p->pMem = ABC_ALLOC( word, p->nMemAlloc );
462 p->vObjs = Vec_PtrAlloc( 100 );
464 for ( i = 0; i < nVars; i++ )
465 {
466 pObj = Dss_ObjAllocNtk( p, DAU_DSD_VAR, 0, 0 );
467 pObj->iVar = i;
468 pObj->nSupp = 1;
469 }
470 return p;
471}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
Dss_Obj_t * Dss_ObjAllocNtk(Dss_Ntk_t *p, int Type, int nFans, int nTruthVars)
Definition dauTree.c:425
unsigned iVar
Definition dauTree.c:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_NtkCheck()

void Dss_NtkCheck ( Dss_Ntk_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 692 of file dauTree.c.

693{
694 Dss_Obj_t * pObj, * pFanin;
695 int i, k;
696 Dss_VecForEachNode( p->vObjs, pObj, i )
697 {
698 Dss_ObjForEachFanin( p->vObjs, pObj, pFanin, k )
699 {
700 if ( pObj->Type == DAU_DSD_AND && pFanin->Type == DAU_DSD_AND )
701 assert( Dss_ObjFaninC(pObj, k) );
702 else if ( pObj->Type == DAU_DSD_XOR )
703 assert( pFanin->Type != DAU_DSD_XOR );
704 else if ( pObj->Type == DAU_DSD_MUX )
705 assert( !Dss_ObjFaninC(pObj, 0) );
706 }
707 }
708}
#define Dss_VecForEachNode(vVec, pObj, i)
Definition dauTree.c:131
Here is the caller graph for this function:

◆ Dss_NtkCollectPerm_rec()

int Dss_NtkCollectPerm_rec ( Dss_Ntk_t * p,
Dss_Obj_t * pObj,
int * pPermDsd,
int * pnPerms )

Definition at line 709 of file dauTree.c.

710{
711 Dss_Obj_t * pChild;
712 int k, fCompl = Dss_IsComplement(pObj);
713 pObj = Dss_Regular( pObj );
714 if ( pObj->Type == DAU_DSD_VAR )
715 {
716 pPermDsd[*pnPerms] = Abc_Var2Lit(pObj->iVar, fCompl);
717 pObj->iVar = (*pnPerms)++;
718 return fCompl;
719 }
720 Dss_ObjForEachChild( p->vObjs, pObj, pChild, k )
721 if ( Dss_NtkCollectPerm_rec( p, pChild, pPermDsd, pnPerms ) )
722 pObj->pFans[k] = (unsigned char)Abc_LitRegular((int)pObj->pFans[k]);
723 return 0;
724}
int Dss_NtkCollectPerm_rec(Dss_Ntk_t *p, Dss_Obj_t *pObj, int *pPermDsd, int *pnPerms)
Definition dauTree.c:709
unsigned pFans[0]
Definition dauTree.c:62
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_NtkCreate()

Dss_Ntk_t * Dss_NtkCreate ( char * pDsd,
int nVars,
word * pTruth )

Definition at line 601 of file dauTree.c.

602{
603 int fCompl = 0;
604 Dss_Ntk_t * pNtk = Dss_NtkAlloc( nVars );
605 if ( *pDsd == '!' )
606 pDsd++, fCompl = 1;
607 if ( Dau_DsdIsConst(pDsd) )
608 pNtk->pRoot = Dss_VecConst0(pNtk->vObjs);
609 else if ( Dau_DsdIsVar(pDsd) )
610 pNtk->pRoot = Dss_VecVar(pNtk->vObjs, Dau_DsdReadVar(pDsd));
611 else
612 {
613 int iLit, pMatches[DAU_MAX_STR];
614 Dau_DsdMergeMatches( pDsd, pMatches );
615 iLit = Dss_NtkCreate_rec( pDsd, &pDsd, pMatches, pNtk, pTruth );
616 pNtk->pRoot = Dss_Lit2Obj( pNtk->vObjs, iLit );
617 }
618 if ( fCompl )
619 pNtk->pRoot = Dss_Not(pNtk->pRoot);
620 return pNtk;
621}
Dss_Ntk_t * Dss_NtkAlloc(int nVars)
Definition dauTree.c:453
int Dss_NtkCreate_rec(char *pStr, char **p, int *pMatches, Dss_Ntk_t *pNtk, word *pTruth)
Definition dauTree.c:538
Dss_Obj_t * pRoot
Definition dauTree.c:72
Vec_Ptr_t * vObjs
Definition dauTree.c:73
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_NtkCreate_rec()

int Dss_NtkCreate_rec ( char * pStr,
char ** p,
int * pMatches,
Dss_Ntk_t * pNtk,
word * pTruth )

Definition at line 538 of file dauTree.c.

539{
540 int fCompl = 0;
541 if ( **p == '!' )
542 {
543 fCompl = 1;
544 (*p)++;
545 }
546 while ( (**p >= 'A' && **p <= 'F') || (**p >= '0' && **p <= '9') )
547 (*p)++;
548/*
549 if ( **p == '<' )
550 {
551 char * q = pStr + pMatches[ *p - pStr ];
552 if ( *(q+1) == '{' )
553 *p = q+1;
554 }
555*/
556 if ( **p >= 'a' && **p <= 'z' ) // var
557 return Abc_Var2Lit( Dss_ObjId(Dss_VecVar(pNtk->vObjs, **p - 'a')), fCompl );
558 if ( **p == '(' || **p == '[' || **p == '<' || **p == '{' ) // and/or/xor
559 {
560 Dss_Obj_t * pObj;
561 Vec_Int_t * vFaninLits = Vec_IntAlloc( 10 );
562 char * q = pStr + pMatches[ *p - pStr ];
563 int Type = 0;
564 if ( **p == '(' )
565 Type = DAU_DSD_AND;
566 else if ( **p == '[' )
567 Type = DAU_DSD_XOR;
568 else if ( **p == '<' )
569 Type = DAU_DSD_MUX;
570 else if ( **p == '{' )
571 Type = DAU_DSD_PRIME;
572 else assert( 0 );
573 assert( *q == **p + 1 + (**p != '(') );
574 for ( (*p)++; *p < q; (*p)++ )
575 Vec_IntPush( vFaninLits, Dss_NtkCreate_rec(pStr, p, pMatches, pNtk, pTruth) );
576 assert( *p == q );
577 if ( Type == DAU_DSD_PRIME )
578 {
579 Vec_Int_t * vFaninLitsNew;
580 word pTemp[DAU_MAX_WORD];
581 char pCanonPerm[DAU_MAX_VAR];
582 int i, uCanonPhase, nFanins = Vec_IntSize(vFaninLits);
583 Abc_TtCopy( pTemp, pTruth, Abc_TtWordNum(nFanins), 0 );
584 uCanonPhase = Abc_TtCanonicize( pTemp, nFanins, pCanonPerm );
585 fCompl = (uCanonPhase >> nFanins) & 1;
586 vFaninLitsNew = Vec_IntAlloc( nFanins );
587 for ( i = 0; i < nFanins; i++ )
588 Vec_IntPush( vFaninLitsNew, Abc_LitNotCond(Vec_IntEntry(vFaninLits, pCanonPerm[i]), (uCanonPhase>>i)&1) );
589 pObj = Dss_ObjCreateNtk( pNtk, DAU_DSD_PRIME, vFaninLitsNew );
590 Abc_TtCopy( Dss_ObjTruth(pObj), pTemp, Abc_TtWordNum(nFanins), 0 );
591 Vec_IntFree( vFaninLitsNew );
592 }
593 else
594 pObj = Dss_ObjCreateNtk( pNtk, Type, vFaninLits );
595 Vec_IntFree( vFaninLits );
596 return Abc_LitNotCond( Dss_Obj2Lit(pObj), fCompl );
597 }
598 assert( 0 );
599 return -1;
600}
Dss_Obj_t * Dss_ObjCreateNtk(Dss_Ntk_t *p, int Type, Vec_Int_t *vFaninLits)
Definition dauTree.c:440
unsigned Abc_TtCanonicize(word *pTruth, int nVars, char *pCanonPerm)
FUNCTION DECLARATIONS ///.
Definition dauCanon.c:1036
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_NtkFree()

void Dss_NtkFree ( Dss_Ntk_t * p)

Definition at line 472 of file dauTree.c.

473{
474 Vec_PtrFree( p->vObjs );
475 ABC_FREE( p->pMem );
476 ABC_FREE( p );
477}
Here is the caller graph for this function:

◆ Dss_NtkPrint()

void Dss_NtkPrint ( Dss_Ntk_t * p)

Definition at line 497 of file dauTree.c.

498{
499 if ( Dss_Regular(p->pRoot)->Type == DAU_DSD_CONST0 )
500 printf( "%d", Dss_IsComplement(p->pRoot) );
501 else
502 {
503 printf( "%s", Dss_IsComplement(p->pRoot) ? "!":"" );
504 if ( Dss_Regular(p->pRoot)->Type == DAU_DSD_VAR )
505 printf( "%c", 'a' + Dss_Regular(p->pRoot)->iVar );
506 else
507 Dss_NtkPrint_rec( p, Dss_Regular(p->pRoot) );
508 }
509 printf( "\n" );
510}
void Dss_NtkPrint_rec(Dss_Ntk_t *p, Dss_Obj_t *pObj)
Definition dauTree.c:478
Here is the call graph for this function:

◆ Dss_NtkPrint_rec()

void Dss_NtkPrint_rec ( Dss_Ntk_t * p,
Dss_Obj_t * pObj )

Definition at line 478 of file dauTree.c.

479{
480 char OpenType[7] = {0, 0, 0, '(', '[', '<', '{'};
481 char CloseType[7] = {0, 0, 0, ')', ']', '>', '}'};
482 Dss_Obj_t * pFanin;
483 int i;
484 assert( !Dss_IsComplement(pObj) );
485 if ( pObj->Type == DAU_DSD_VAR )
486 { printf( "%c", 'a' + pObj->iVar ); return; }
487 if ( pObj->Type == DAU_DSD_PRIME )
488 Abc_TtPrintHexRev( stdout, Dss_ObjTruth(pObj), pObj->nFans );
489 printf( "%c", OpenType[pObj->Type] );
490 Dss_ObjForEachFanin( p->vObjs, pObj, pFanin, i )
491 {
492 printf( "%s", Dss_ObjFaninC(pObj, i) ? "!":"" );
493 Dss_NtkPrint_rec( p, pFanin );
494 }
495 printf( "%c", CloseType[pObj->Type] );
496}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_NtkRebuild()

int Dss_NtkRebuild ( Dss_Man_t * p,
Dss_Ntk_t * pNtk )

Definition at line 1264 of file dauTree.c.

1265{
1266 assert( p->nVars == pNtk->nVars );
1267 if ( Dss_Regular(pNtk->pRoot)->Type == DAU_DSD_CONST0 )
1268 return Dss_IsComplement(pNtk->pRoot);
1269 if ( Dss_Regular(pNtk->pRoot)->Type == DAU_DSD_VAR )
1270 return Abc_Var2Lit( Dss_Regular(pNtk->pRoot)->iVar + 1, Dss_IsComplement(pNtk->pRoot) );
1271 return Dss_NtkRebuild_rec( p, pNtk, pNtk->pRoot );
1272}
int Dss_NtkRebuild_rec(Dss_Man_t *p, Dss_Ntk_t *pNtk, Dss_Obj_t *pObj)
Definition dauTree.c:1227
int nVars
Definition dauTree.c:68
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_NtkRebuild_rec()

int Dss_NtkRebuild_rec ( Dss_Man_t * p,
Dss_Ntk_t * pNtk,
Dss_Obj_t * pObj )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1227 of file dauTree.c.

1228{
1229 Dss_Obj_t * pChildren[DAU_MAX_VAR];
1230 Dss_Obj_t * pChild, * pObjNew;
1231 int i, k, fCompl = Dss_IsComplement(pObj);
1232 pObj = Dss_Regular(pObj);
1233 if ( pObj->Type == DAU_DSD_VAR )
1234 return Abc_Var2Lit( 1, fCompl );
1235 Dss_ObjForEachChild( pNtk->vObjs, pObj, pChild, k )
1236 {
1237 pChildren[k] = Dss_Lit2Obj( p->vObjs, Dss_NtkRebuild_rec( p, pNtk, pChild ) );
1238 if ( pObj->Type == DAU_DSD_XOR && Dss_IsComplement(pChildren[k]) )
1239 pChildren[k] = Dss_Not(pChildren[k]), fCompl ^= 1;
1240 }
1241 // normalize MUX
1242 if ( pObj->Type == DAU_DSD_MUX )
1243 {
1244 if ( Dss_IsComplement(pChildren[0]) )
1245 {
1246 pChildren[0] = Dss_Not(pChildren[0]);
1247 ABC_SWAP( Dss_Obj_t *, pChildren[1], pChildren[2] );
1248 }
1249 if ( Dss_IsComplement(pChildren[1]) )
1250 {
1251 pChildren[1] = Dss_Not(pChildren[1]);
1252 pChildren[2] = Dss_Not(pChildren[2]);
1253 fCompl ^= 1;
1254 }
1255 }
1256 // shift subgraphs
1257 Vec_IntClear( p->vLeaves );
1258 for ( i = 0; i < k; i++ )
1259 Vec_IntPush( p->vLeaves, Dss_Obj2Lit(pChildren[i]) );
1260 // create new graph
1261 pObjNew = Dss_ObjFindOrAdd( p, pObj->Type, p->vLeaves, pObj->Type == DAU_DSD_PRIME ? Dss_ObjTruth(pObj) : NULL );
1262 return Abc_Var2Lit( pObjNew->Id, fCompl );
1263}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_NtkTransform()

void Dss_NtkTransform ( Dss_Ntk_t * p,
int * pPermDsd )

Definition at line 725 of file dauTree.c.

726{
727 Dss_Obj_t * pChildren[DAU_MAX_VAR];
728 Dss_Obj_t * pObj, * pChild;
729 int i, k, nPerms;
730 if ( Dss_Regular(p->pRoot)->Type == DAU_DSD_CONST0 )
731 return;
732 Dss_VecForEachNode( p->vObjs, pObj, i )
733 {
734 if ( pObj->Type == DAU_DSD_MUX || pObj->Type == DAU_DSD_PRIME )
735 continue;
736 Dss_ObjForEachChild( p->vObjs, pObj, pChild, k )
737 pChildren[k] = pChild;
738 Dss_ObjSort( p->vObjs, pChildren, Dss_ObjFaninNum(pObj), NULL );
739 for ( k = 0; k < Dss_ObjFaninNum(pObj); k++ )
740 pObj->pFans[k] = Dss_Obj2Lit( pChildren[k] );
741 }
742 nPerms = 0;
743 if ( Dss_NtkCollectPerm_rec( p, p->pRoot, pPermDsd, &nPerms ) )
744 p->pRoot = Dss_Regular(p->pRoot);
745 assert( nPerms == (int)Dss_Regular(p->pRoot)->nSupp );
746}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ObjAlloc()

Dss_Obj_t * Dss_ObjAlloc ( Dss_Man_t * p,
int Type,
int nFans,
int nTruthVars )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 760 of file dauTree.c.

761{
762 int nWords = Dss_ObjWordNum(nFans) + (nTruthVars ? Abc_TtWordNum(nTruthVars) : 0);
763 Dss_Obj_t * pObj = (Dss_Obj_t *)Mem_FlexEntryFetch( p->pMem, sizeof(word) * nWords );
764 Dss_ObjClean( pObj );
765 pObj->Type = Type;
766 pObj->nFans = nFans;
767 pObj->nWords = Dss_ObjWordNum(nFans);
768 pObj->Id = Vec_PtrSize( p->vObjs );
769 pObj->iVar = 31;
770 Vec_PtrPush( p->vObjs, pObj );
771 Vec_IntPush( p->vNexts, 0 );
772 return pObj;
773}
unsigned nWords
Definition dauTree.c:58
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ObjAllocNtk()

Dss_Obj_t * Dss_ObjAllocNtk ( Dss_Ntk_t * p,
int Type,
int nFans,
int nTruthVars )

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

Synopsis [Creating DSD network.]

Description []

SideEffects []

SeeAlso []

Definition at line 425 of file dauTree.c.

426{
427 Dss_Obj_t * pObj;
428 pObj = (Dss_Obj_t *)(p->pMem + p->nMem);
429 Dss_ObjClean( pObj );
430 pObj->nFans = nFans;
431 pObj->nWords = Dss_ObjWordNum( nFans );
432 pObj->Type = Type;
433 pObj->Id = Vec_PtrSize( p->vObjs );
434 pObj->iVar = 31;
435 Vec_PtrPush( p->vObjs, pObj );
436 p->nMem += pObj->nWords + (nTruthVars ? Abc_TtWordNum(nTruthVars) : 0);
437 assert( p->nMem < p->nMemAlloc );
438 return pObj;
439}
Here is the caller graph for this function:

◆ Dss_ObjCheckTransparent()

int Dss_ObjCheckTransparent ( Dss_Man_t * p,
Dss_Obj_t * pObj )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1776 of file dauTree.c.

1777{
1778 Dss_Obj_t * pFanin;
1779 int i;
1780 if ( pObj->Type == DAU_DSD_VAR )
1781 return 1;
1782 if ( pObj->Type == DAU_DSD_AND )
1783 return 0;
1784 if ( pObj->Type == DAU_DSD_XOR )
1785 {
1786 Dss_ObjForEachFanin( p->vObjs, pObj, pFanin, i )
1787 if ( Dss_ObjCheckTransparent( p, pFanin ) )
1788 return 1;
1789 return 0;
1790 }
1791 if ( pObj->Type == DAU_DSD_MUX )
1792 {
1793 pFanin = Dss_ObjFanin( p->vObjs, pObj, 1 );
1794 if ( !Dss_ObjCheckTransparent(p, pFanin) )
1795 return 0;
1796 pFanin = Dss_ObjFanin( p->vObjs, pObj, 2 );
1797 if ( !Dss_ObjCheckTransparent(p, pFanin) )
1798 return 0;
1799 return 1;
1800 }
1801 assert( pObj->Type == DAU_DSD_PRIME );
1802 return 0;
1803}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ObjCompare()

int Dss_ObjCompare ( Vec_Ptr_t * p,
Dss_Obj_t * p0i,
Dss_Obj_t * p1i )

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

Synopsis [Comparing two DSD nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 634 of file dauTree.c.

635{
636 Dss_Obj_t * p0 = Dss_Regular(p0i);
637 Dss_Obj_t * p1 = Dss_Regular(p1i);
638 Dss_Obj_t * pChild0, * pChild1;
639 int i, Res;
640 if ( Dss_ObjType(p0) < Dss_ObjType(p1) )
641 return -1;
642 if ( Dss_ObjType(p0) > Dss_ObjType(p1) )
643 return 1;
644 if ( Dss_ObjType(p0) < DAU_DSD_AND )
645 return 0;
646 if ( Dss_ObjFaninNum(p0) < Dss_ObjFaninNum(p1) )
647 return -1;
648 if ( Dss_ObjFaninNum(p0) > Dss_ObjFaninNum(p1) )
649 return 1;
650 for ( i = 0; i < Dss_ObjFaninNum(p0); i++ )
651 {
652 pChild0 = Dss_ObjChild( p, p0, i );
653 pChild1 = Dss_ObjChild( p, p1, i );
654 Res = Dss_ObjCompare( p, pChild0, pChild1 );
655 if ( Res != 0 )
656 return Res;
657 }
658 if ( Dss_IsComplement(p0i) < Dss_IsComplement(p1i) )
659 return -1;
660 if ( Dss_IsComplement(p0i) > Dss_IsComplement(p1i) )
661 return 1;
662 return 0;
663}
int Dss_ObjCompare(Vec_Ptr_t *p, Dss_Obj_t *p0i, Dss_Obj_t *p1i)
Definition dauTree.c:634
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ObjCreate()

Dss_Obj_t * Dss_ObjCreate ( Dss_Man_t * p,
int Type,
Vec_Int_t * vFaninLits,
word * pTruth )

Definition at line 774 of file dauTree.c.

775{
776 Dss_Obj_t * pObj, * pFanin, * pPrev = NULL;
777 int i, Entry;
778 // check structural canonicity
779 assert( Type != DAU_DSD_MUX || Vec_IntSize(vFaninLits) == 3 );
780 assert( Type != DAU_DSD_MUX || !Abc_LitIsCompl(Vec_IntEntry(vFaninLits, 0)) );
781 assert( Type != DAU_DSD_MUX || !Abc_LitIsCompl(Vec_IntEntry(vFaninLits, 1)) || !Abc_LitIsCompl(Vec_IntEntry(vFaninLits, 2)) );
782 // check that leaves are in good order
783 if ( Type == DAU_DSD_AND || Type == DAU_DSD_XOR )
784 Dss_VecForEachObjVec( vFaninLits, p->vObjs, pFanin, i )
785 {
786 assert( Type != DAU_DSD_AND || Abc_LitIsCompl(Vec_IntEntry(vFaninLits, i)) || Dss_ObjType(pFanin) != DAU_DSD_AND );
787 assert( Type != DAU_DSD_XOR || Dss_ObjType(pFanin) != DAU_DSD_XOR );
788 assert( pPrev == NULL || Dss_ObjCompare(p->vObjs, pPrev, pFanin) <= 0 );
789 pPrev = pFanin;
790 }
791 // create new node
792 pObj = Dss_ObjAlloc( p, Type, Vec_IntSize(vFaninLits), Type == DAU_DSD_PRIME ? Vec_IntSize(vFaninLits) : 0 );
793 if ( Type == DAU_DSD_PRIME )
794 Abc_TtCopy( Dss_ObjTruth(pObj), pTruth, Abc_TtWordNum(Vec_IntSize(vFaninLits)), 0 );
795 assert( pObj->nSupp == 0 );
796 Vec_IntForEachEntry( vFaninLits, Entry, i )
797 {
798 pObj->pFans[i] = Entry;
799 pObj->nSupp += Dss_VecLitSuppSize(p->vObjs, Entry);
800 }
801/*
802 {
803 extern void Dss_ManPrintOne( Dss_Man_t * p, int iDsdLit, int * pPermLits );
804 Dss_ManPrintOne( p, Dss_Obj2Lit(pObj), NULL );
805 }
806*/
807 return pObj;
808}
#define Dss_VecForEachObjVec(vLits, vVec, pObj, i)
Definition dauTree.c:129
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ObjCreateNtk()

Dss_Obj_t * Dss_ObjCreateNtk ( Dss_Ntk_t * p,
int Type,
Vec_Int_t * vFaninLits )

Definition at line 440 of file dauTree.c.

441{
442 Dss_Obj_t * pObj;
443 int i, Entry;
444 pObj = Dss_ObjAllocNtk( p, Type, Vec_IntSize(vFaninLits), Type == DAU_DSD_PRIME ? Vec_IntSize(vFaninLits) : 0 );
445 Vec_IntForEachEntry( vFaninLits, Entry, i )
446 {
447 pObj->pFans[i] = Entry;
448 pObj->nSupp += Dss_VecLitSuppSize(p->vObjs, Entry);
449 }
450 assert( i == (int)pObj->nFans );
451 return pObj;
452}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ObjFindOrAdd()

Dss_Obj_t * Dss_ObjFindOrAdd ( Dss_Man_t * p,
int Type,
Vec_Int_t * vFaninLits,
word * pTruth )

Definition at line 868 of file dauTree.c.

869{
870 Dss_Obj_t * pObj;
871 unsigned * pSpot = Dss_ObjHashLookup( p, Type, vFaninLits, pTruth );
872 if ( *pSpot )
873 return Dss_VecObj( p->vObjs, *pSpot );
874 *pSpot = Vec_PtrSize( p->vObjs );
875 pObj = Dss_ObjCreate( p, Type, vFaninLits, pTruth );
876 return pObj;
877}
unsigned * Dss_ObjHashLookup(Dss_Man_t *p, int Type, Vec_Int_t *vFaninLits, word *pTruth)
Definition dauTree.c:853
Dss_Obj_t * Dss_ObjCreate(Dss_Man_t *p, int Type, Vec_Int_t *vFaninLits, word *pTruth)
Definition dauTree.c:774
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ObjHashLookup()

unsigned * Dss_ObjHashLookup ( Dss_Man_t * p,
int Type,
Vec_Int_t * vFaninLits,
word * pTruth )

Definition at line 853 of file dauTree.c.

854{
855 Dss_Obj_t * pObj;
856 unsigned * pSpot = p->pBins + Dss_ObjHashKey(p, Type, vFaninLits, pTruth);
857 for ( ; *pSpot; pSpot = (unsigned *)Vec_IntEntryP(p->vNexts, pObj->Id) )
858 {
859 pObj = Dss_VecObj( p->vObjs, *pSpot );
860 if ( (int)pObj->Type == Type &&
861 (int)pObj->nFans == Vec_IntSize(vFaninLits) &&
862 !memcmp(pObj->pFans, Vec_IntArray(vFaninLits), sizeof(int)*pObj->nFans) &&
863 (pTruth == NULL || !memcmp(Dss_ObjTruth(pObj), pTruth, (size_t)Abc_TtByteNum(pObj->nFans))) ) // equal
864 return pSpot;
865 }
866 return pSpot;
867}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ObjSort()

void Dss_ObjSort ( Vec_Ptr_t * p,
Dss_Obj_t ** pNodes,
int nNodes,
int * pPerm )

Definition at line 664 of file dauTree.c.

665{
666 int i, j, best_i;
667 for ( i = 0; i < nNodes-1; i++ )
668 {
669 best_i = i;
670 for ( j = i+1; j < nNodes; j++ )
671 if ( Dss_ObjCompare(p, pNodes[best_i], pNodes[j]) == 1 )
672 best_i = j;
673 if ( i == best_i )
674 continue;
675 ABC_SWAP( Dss_Obj_t *, pNodes[i], pNodes[best_i] );
676 if ( pPerm )
677 ABC_SWAP( int, pPerm[i], pPerm[best_i] );
678 }
679}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mpm_FuncCompute()

int Mpm_FuncCompute ( Dss_Man_t * p,
int iDsd0,
int iDsd1,
Vec_Str_t * vShared,
int * pPerm,
int * pnLeaves )

Definition at line 1693 of file dauTree.c.

1694{
1695 int fVerbose = 0;
1696// int fCheck = 0;
1697 Dss_Ent_t * pEnt, ** ppSpot;
1698 Dss_Fun_t * pFun;
1699 int iDsd[2] = { iDsd0, iDsd1 };
1700 int i;
1701 abctime clk;
1702
1703 assert( iDsd0 <= iDsd1 );
1704 if ( DAU_MAX_VAR < *pnLeaves )
1705 {
1706 printf( "Parameter DAU_MAX_VAR (%d) smaller than LUT size (%d).\n", DAU_MAX_VAR, *pnLeaves );
1707 return -1;
1708 }
1709 if ( fVerbose )
1710 {
1711 Dss_ManPrintOne( stdout, p, iDsd0, NULL );
1712 Dss_ManPrintOne( stdout, p, iDsd1, NULL );
1713 }
1714
1715clk = Abc_Clock();
1716 pEnt = Dss_ManSharedMapDerive( p, iDsd0, iDsd1, vShared );
1717 ppSpot = Dss_ManCacheLookup( p, pEnt );
1718p->timeLook += Abc_Clock() - clk;
1719
1720clk = Abc_Clock();
1721 if ( *ppSpot == NULL )
1722 {
1723 if ( Vec_StrSize(vShared) == 0 )
1724 pFun = Dss_ManOperationFun( p, iDsd, *pnLeaves );
1725 else
1726 pFun = Dss_ManBooleanAnd( p, pEnt, 0 );
1727 if ( pFun == NULL )
1728 return -1;
1729 assert( (int)pFun->nFans == Dss_VecLitSuppSize(p->vObjs, pFun->iDsd) );
1730 assert( (int)pFun->nFans <= *pnLeaves );
1731 // create cache entry
1732 *ppSpot = Dss_ManCacheCreate( p, pEnt, pFun );
1733 }
1734 pFun = (*ppSpot)->pFunc;
1735p->timeDec += Abc_Clock() - clk;
1736
1737 *pnLeaves = (int)pFun->nFans;
1738 for ( i = 0; i < (int)pFun->nFans; i++ )
1739 pPerm[i] = (int)pFun->pFans[i];
1740
1741 if ( fVerbose )
1742 {
1743 Dss_ManPrintOne( stdout, p, pFun->iDsd, NULL );
1744 printf( "\n" );
1745 }
1746
1747/*
1748 if ( fCheck )
1749 {
1750 pTruthOne = Dss_ManComputeTruth( p, pFun->iDsd, p->nVars, pPermResInt );
1751 if ( !Abc_TtEqual( pTruthOne, pTruth, Abc_TtWordNum(p->nVars) ) )
1752 {
1753 int s;
1754 // Kit_DsdPrintFromTruth( pTruthOne, p->nVars ); printf( "\n" );
1755 // Kit_DsdPrintFromTruth( pTruth, p->nVars ); printf( "\n" );
1756 printf( "Verification failed.\n" );
1757 s = 0;
1758 }
1759 }
1760*/
1761 return pFun->iDsd;
1762}
Dss_Ent_t * Dss_ManSharedMapDerive(Dss_Man_t *p, int iDsd0, int iDsd1, Vec_Str_t *vShared)
Definition dauTree.c:1681
Here is the call graph for this function: