From f49e8f0fe73e2b9cf673f754c9fd0951be9a3756 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 4 Jul 2018 14:04:08 -0700 Subject: Adding command 'majgen'. --- src/misc/util/utilTruth.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'src/misc/util') diff --git a/src/misc/util/utilTruth.h b/src/misc/util/utilTruth.h index 36da1271..bc6ad0d5 100644 --- a/src/misc/util/utilTruth.h +++ b/src/misc/util/utilTruth.h @@ -3094,6 +3094,75 @@ static inline int Abc_Tt4Check( int t ) return 0; } + +/**Function************************************************************* + + Synopsis [Returns symmetry profile of the function.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Abc_TtVarsAreSymmetric( word * pTruth, int nVars, int i, int j, word * pCof0, word * pCof1 ) +{ + int nWords = Abc_TtWordNum( nVars ); + assert( i < nVars && j < nVars ); + Abc_TtCofactor0p( pCof0, pTruth, nWords, i ); + Abc_TtCofactor1p( pCof1, pTruth, nWords, i ); + Abc_TtCofactor1( pCof0, nWords, j ); + Abc_TtCofactor0( pCof1, nWords, j ); + return Abc_TtEqual( pCof0, pCof1, nWords ); +} +static inline int Abc_TtIsFullySymmetric( word * pTruth, int nVars ) +{ + int m, v, Polar = 0, Seen = 0; + for ( m = 0; m < (1<> v) & 1); + if ( (Seen >> Count) & 1 ) // seen this count + { + if ( Value != ((Polar >> Count) & 1) ) + return -1; + } + else // new count + { + Seen |= 1 << Count; + if ( Value ) + Polar |= 1 << Count; + } + } + return Polar; +} +static inline void Abc_TtGenFullySymmetric( word * pTruth, int nVars, int Polar ) +{ + int m, v, nWords = Abc_TtWordNum( nVars ); + Abc_TtClear( pTruth, nWords ); + for ( m = 0; m < (1<> v) & 1); + if ( (Polar >> Count) & 1 ) + Abc_TtSetBit( pTruth, m ); + } +} +static inline void Abc_TtTestFullySymmetric() +{ + word pTruth[4]; // 8-var function + int PolarOut, PolarIn = 271; + Abc_TtGenFullySymmetric( pTruth, 8, PolarIn ); + //Abc_TtXorBit( pTruth, 171 ); + PolarOut = Abc_TtIsFullySymmetric( pTruth, 8 ); + assert( PolarIn == PolarOut ); +} + + /*=== utilTruth.c ===========================================================*/ -- cgit v1.2.3