ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
dauCount.c File Reference
#include "dauInt.h"
Include dependency graph for dauCount.c:

Go to the source code of this file.

Functions

void Abc_TtCountGenerate ()
 FUNCTION DEFINITIONS ///.
 
int Abc_TtCountOnesInCofsQuick_rec (word *pTruth, int nVars, int *pStore)
 
int Abc_TtCountOnesInCofsQuick (word *pTruth, int nVars, int *pStore)
 
void Abc_TtCountOnesInCofsTest2 ()
 
void Abc_TtCountOnesInCofsTest ()
 

Function Documentation

◆ Abc_TtCountGenerate()

void Abc_TtCountGenerate ( )

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 305 of file dauCount.c.

306{
307 static word s_CMasks6[3] = {
308 ABC_CONST(0x5555555555555555),
309 ABC_CONST(0x3333333333333333),
310 ABC_CONST(0x0F0F0F0F0F0F0F0F)
311 };
312 static int bit_count[256] = {
313 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
314 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
315 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
316 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
317 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
318 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
319 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
320 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
321 };
322 int i, k, c;
323 printf("{ ");
324 for ( i = 0; i < 256; i++, printf(" },\n{ ") )
325 for ( k = 0; k < 32; k++ )
326 {
327 printf( "ABC_CONST(0x0%d", bit_count[i] );
328 for ( c = 3; c >= 0; c-- )
329 printf( "0%d", (((k >> c) & 1) == 0) * bit_count[i] );
330 for ( c = 2; c >= 0; c-- )
331 printf( "0%d", bit_count[s_CMasks6[c] & i] );
332 printf( ")%s", k == 31 ? "":", " );
333 }
334}
#define ABC_CONST(number)
PARAMETERS ///.
Definition abc_global.h:240
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36

◆ Abc_TtCountOnesInCofsQuick()

int Abc_TtCountOnesInCofsQuick ( word * pTruth,
int nVars,
int * pStore )

Definition at line 376 of file dauCount.c.

377{
378 if ( nVars == 0 )
379 return (int)(pTruth[0] & 1);
380 memset( pStore, 0, sizeof(int)*nVars );
381 return Abc_TtCountOnesInCofsQuick_rec( pTruth, nVars, pStore );
382}
int Abc_TtCountOnesInCofsQuick_rec(word *pTruth, int nVars, int *pStore)
Definition dauCount.c:347
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCountOnesInCofsQuick_rec()

int Abc_TtCountOnesInCofsQuick_rec ( word * pTruth,
int nVars,
int * pStore )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 347 of file dauCount.c.

348{
349 if ( nVars <= 8 )
350 {
351 word Res = 0;
352 unsigned char * pResC = (unsigned char *)&Res;
353 unsigned char * pTruthC = (unsigned char *)pTruth;
354 int i, nBytes = nVars <= 6 ? 4 : 1 << (nVars-4), nBytes2 = nBytes << 1;
355 assert( nVars >= 1 && nVars <= 8 );
356 for ( i = 0; i < nBytes; i++ )
357 Res += Table[pTruthC[i]][i];
358 if ( nVars == 8 )
359 pStore[7] += pResC[7];
360 for ( ; i < nBytes2; i++ )
361 Res += Table[pTruthC[i]][i];
362 for ( i = 0; i < nVars-1; i++ )
363 pStore[i] += pResC[i];
364 if ( nVars < 8 )
365 pStore[nVars-1] += pResC[nVars-1];
366 return (int)pResC[7];
367 }
368 else
369 {
370 int Res1 = Abc_TtCountOnesInCofsQuick_rec( pTruth, nVars-1, pStore );
371 int Res2 = Abc_TtCountOnesInCofsQuick_rec( pTruth + (1 << (nVars-7)), nVars-1, pStore );
372 pStore[nVars-1] = Res1;
373 return Res1 + Res2;
374 }
375}
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCountOnesInCofsTest()

void Abc_TtCountOnesInCofsTest ( )

Definition at line 410 of file dauCount.c.

411{
412 word Truth[4] = {0};
413 int Store1[8] = {0}, Store2[8] = {0};
414 int n, i, k, Res1, Res2;
415 srand( time(NULL) );
416 for ( n = 0; n < 1000000; n++ )
417 {
418 for ( i = 0; i < 4; i++ )
419 for ( k = 0; k < 8; k++ )
420 Truth[i] ^= (word)(rand() & 0xFF) << (k << 3);
421 Res1 = Abc_TtCountOnesInCofsSimple( Truth, 8, Store1 );
422 Res2 = Abc_TtCountOnesInCofsQuick( Truth, 8, Store2 );
423 assert( Res1 == Res2 );
424 for ( i = 0; i < 8; i++ )
425 assert( Store1[i] == Store2[i] );
426 }
427}
int Abc_TtCountOnesInCofsQuick(word *pTruth, int nVars, int *pStore)
Definition dauCount.c:376
int Abc_TtCountOnesInCofsSimple(word *pTruth, int nVars, int *pStore)
Definition dauCanon.c:370
Here is the call graph for this function:

◆ Abc_TtCountOnesInCofsTest2()

void Abc_TtCountOnesInCofsTest2 ( )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 396 of file dauCount.c.

397{
398 word Truth = ABC_CONST(0x5555555555555555) & ABC_CONST(0x3333333333333333);
399
400 int Store1[8] = {0}, Store2[8] = {0};
401 int i, Res1, Res2;
402
403 Res1 = Abc_TtCountOnesInCofsSimple( &Truth, 2, Store1 );
404 Res2 = Abc_TtCountOnesInCofsQuick( &Truth, 2, Store2 );
405 assert( Res1 == Res2 );
406 for ( i = 0; i < 8; i++ )
407 assert( Store1[i] == Store2[i] );
408
409}
Here is the call graph for this function: