From 38e2f41655d4d44ccfa935b5b8d687596124c169 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 30 May 2019 19:27:31 -0700 Subject: Updating command 'symfun' to generate symmetric functions and their NPN classes. --- src/misc/util/utilTruth.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/misc/util') diff --git a/src/misc/util/utilTruth.h b/src/misc/util/utilTruth.h index 8d28d33e..6fa5e0a3 100644 --- a/src/misc/util/utilTruth.h +++ b/src/misc/util/utilTruth.h @@ -3191,7 +3191,32 @@ static inline void Abc_TtTestFullySymmetric() } -/*=== utilTruth.c ===========================================================*/ +/**Function************************************************************* + + Synopsis [Generates truth table of a symmetric function.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline word * Abc_TtSymFunGenerate( char * pOnes, int nVars ) +{ + int m, k, Count; + word * pTruth = ABC_CALLOC( word, Abc_TtWordNum(nVars) ); + assert( (int)strlen(pOnes) == nVars + 1 ); + for ( m = 0; m < (1 << nVars); m++ ) + { + Count = 0; + for ( k = 0; k < nVars; k++ ) + Count += (m >> k) & 1; + if ( pOnes[Count] == '1' ) + Abc_TtXorBit( pTruth, m ); + } + return pTruth; +} ABC_NAMESPACE_HEADER_END -- cgit v1.2.3