ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ifDec08.c File Reference
#include "if.h"
#include "misc/extra/extra.h"
#include "bool/kit/kit.h"
Include dependency graph for ifDec08.c:

Go to the source code of this file.

Functions

void Kit_DsdPrintFromTruth (unsigned *pTruth, int nVars)
 
void Extra_PrintBinary (FILE *pFile, unsigned Sign[], int nBits)
 
void If_Dec08PrintConfig (unsigned *pZ)
 
void If_Dec08Verify (word *pF, int nVars, unsigned *pZ)
 
void If_Dec08Cofactors (word *pF, int nVars, int iVar, word *pCof0, word *pCof1)
 
int If_Dec08Perform (word *pF, int nVars, int fDerive)
 
int If_CutPerformCheck08 (If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
 

Function Documentation

◆ Extra_PrintBinary()

void Extra_PrintBinary ( FILE * pFile,
unsigned Sign[],
int nBits )
extern

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

Synopsis [Prints the bit string.]

Description []

SideEffects []

SeeAlso []

Definition at line 516 of file extraUtilFile.c.

517{
518 int i;
519 for ( i = nBits-1; i >= 0; i-- )
520 fprintf( pFile, "%c", '0' + Abc_InfoHasBit(Sign, i) );
521// fprintf( pFile, "\n" );
522}

◆ If_CutPerformCheck08()

int If_CutPerformCheck08 ( If_Man_t * p,
unsigned * pTruth,
int nVars,
int nLeaves,
char * pStr )

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

Synopsis [Performs additional check.]

Description []

SideEffects []

SeeAlso []

Definition at line 475 of file ifDec08.c.

476{
477 int nSupp, fDerive = 0;
478 word pF[16];
479 if ( nLeaves <= 5 )
480 return 1;
481 If_Dec08Copy( pF, (word *)pTruth, nVars );
482 nSupp = If_Dec08Support( pF, nLeaves );
483 if ( !nSupp || !If_DecSuppIsMinBase(nSupp) )
484 return 0;
485 if ( If_Dec08Perform( pF, nLeaves, fDerive ) )
486 {
487// printf( "1" );
488 return 1;
489// If_Dec08Verify( t, nLeaves, NULL );
490 }
491// printf( "0" );
492 return 0;
493}
int If_Dec08Perform(word *pF, int nVars, int fDerive)
Definition ifDec08.c:379
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
Here is the call graph for this function:

◆ If_Dec08Cofactors()

void If_Dec08Cofactors ( word * pF,
int nVars,
int iVar,
word * pCof0,
word * pCof1 )

Definition at line 337 of file ifDec08.c.

338{
339 int nWords = If_Dec08WordNum( nVars );
340 assert( iVar < nVars );
341 if ( iVar < 6 )
342 {
343 int i, Shift = (1 << iVar);
344 for ( i = 0; i < nWords; i++ )
345 {
346 pCof0[i] = (pF[i] & ~Truth6[iVar]) | ((pF[i] & ~Truth6[iVar]) << Shift);
347 pCof1[i] = (pF[i] & Truth6[iVar]) | ((pF[i] & Truth6[iVar]) >> Shift);
348 }
349 return;
350 }
351 else
352 {
353 int i, k, Step = (1 << (iVar - 6));
354 for ( k = 0; k < nWords; k += 2*Step )
355 {
356 for ( i = 0; i < Step; i++ )
357 {
358 pCof0[i] = pCof0[Step+i] = pF[i];
359 pCof1[i] = pCof1[Step+i] = pF[Step+i];
360 }
361 pF += 2*Step;
362 pCof0 += 2*Step;
363 pCof1 += 2*Step;
364 }
365 return;
366 }
367}
int nWords
Definition abcNpn.c:127
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ If_Dec08Perform()

int If_Dec08Perform ( word * pF,
int nVars,
int fDerive )

Definition at line 379 of file ifDec08.c.

380{
381// static int Cnt = 0;
382 word pCof0[16], pCof1[16];
383 int Pla2Var[10], Var2Pla[10], Count[210], Masks[210];
384 int i, i0,i1,i2, v, x;
385 assert( nVars >= 6 && nVars <= 8 );
386 // start arrays
387 for ( i = 0; i < nVars; i++ )
388 {
389 assert( If_Dec08HasVar( pF, nVars, i ) );
390 Pla2Var[i] = Var2Pla[i] = i;
391 }
392/*
393 Cnt++;
394//if ( Cnt == 108 )
395{
396printf( "%d\n", Cnt );
397//Extra_PrintHex( stdout, (unsigned *)pF, nVars );
398//printf( "\n" );
399Kit_DsdPrintFromTruth( (unsigned *)pF, nVars );
400printf( "\n" );
401printf( "\n" );
402}
403*/
404 // generate permutations
405 v = 0;
406 for ( i0 = 0; i0 < nVars; i0++ )
407 for ( i1 = i0+1; i1 < nVars; i1++ )
408 for ( i2 = i1+1; i2 < nVars; i2++, v++ )
409 {
410 If_Dec08MoveTo( pF, nVars, i0, nVars-1, Pla2Var, Var2Pla );
411 If_Dec08MoveTo( pF, nVars, i1, nVars-2, Pla2Var, Var2Pla );
412 If_Dec08MoveTo( pF, nVars, i2, nVars-3, Pla2Var, Var2Pla );
413 If_DecVerifyPerm( Pla2Var, Var2Pla, nVars );
414 Count[v] = If_Dec08CofCount( pF, nVars );
415 Masks[v] = (1 << i0) | (1 << i1) | (1 << i2);
416 assert( Count[v] > 1 );
417//printf( "%d ", Count[v] );
418 if ( Count[v] == 2 || Count[v] > 5 )
419 continue;
420 for ( x = 0; x < 4; x++ )
421 {
422 If_Dec08Cofactors( pF, nVars, nVars-1-x, pCof0, pCof1 );
423 if ( If_Dec08CofCount2(pCof0, nVars) <= 2 && If_Dec08CofCount2(pCof1, nVars) <= 2 )
424 {
425 Count[v] = -Count[v];
426 break;
427 }
428 }
429 }
430//printf( "\n" );
431 assert( v <= 210 );
432 // check if there are compatible bound sets
433 for ( i0 = 0; i0 < v; i0++ )
434 for ( i1 = i0+1; i1 < v; i1++ )
435 {
436 if ( If_Dec08Count16(Masks[i0] & Masks[i1]) > 8 - nVars )
437 continue;
438 if ( nVars == 8 )
439 {
440 if ( Count[i0] == 2 && Count[i1] == 2 )
441 return 1;
442 }
443 else if ( nVars == 7 )
444 {
445 if ( (Count[i0] == 2 && Count[i1] == 2) ||
446 (Count[i0] == 2 && Count[i1] < 0) ||
447 (Count[i0] < 0 && Count[i1] == 2) )
448 return 1;
449 }
450 else
451 {
452 if ( (Count[i0] == 2 && Count[i1] == 2) ||
453 (Count[i0] == 2 && Count[i1] < 0) ||
454 (Count[i0] < 0 && Count[i1] == 2) ||
455 (Count[i0] < 0 && Count[i1] < 0) )
456 return 1;
457 }
458 }
459// printf( "not found\n" );
460 return 0;
461}
void If_Dec08Cofactors(word *pF, int nVars, int iVar, word *pCof0, word *pCof1)
Definition ifDec08.c:337
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_Dec08PrintConfig()

void If_Dec08PrintConfig ( unsigned * pZ)

Definition at line 92 of file ifDec08.c.

93{
94 while ( *pZ )
95 If_Dec08PrintConfigOne( *pZ++ );
96}
Here is the caller graph for this function:

◆ If_Dec08Verify()

void If_Dec08Verify ( word * pF,
int nVars,
unsigned * pZ )

Definition at line 118 of file ifDec08.c.

119{
120 word pN[16][16], * pG[4];
121 int i, w, v, k, nWords;
122 unsigned z;
123 nWords = If_Dec08WordNum( nVars );
124 for ( k = 0; k < nVars; k++ )
125 for ( w = 0; w < nWords; w++ )
126 pN[k][w] = Truth10[k][w];
127 for ( i = 0; (z = pZ[i]); i++, k++ )
128 {
129 for ( v = 0; v < 4; v++ )
130 pG[v] = pN[ (z >> (16+(v<<2))) & 7 ];
131 If_Dec08ComposeLut4( (int)(z & 0xffff), pG, pN[k], nVars );
132 }
133 k--;
134 for ( w = 0; w < nWords; w++ )
135 if ( pN[k][w] != pF[w] )
136 {
138 Kit_DsdPrintFromTruth( (unsigned*)pF, nVars ); printf( "\n" );
139 Kit_DsdPrintFromTruth( (unsigned*)pN[k], nVars ); printf( "\n" );
140 printf( "Verification failed!\n" );
141 break;
142 }
143}
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition kitDsd.c:491
void If_Dec08PrintConfig(unsigned *pZ)
Definition ifDec08.c:92
Here is the call graph for this function:

◆ Kit_DsdPrintFromTruth()

void Kit_DsdPrintFromTruth ( unsigned * pTruth,
int nVars )
extern

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

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 491 of file kitDsd.c.

492{
493 Kit_DsdNtk_t * pTemp, * pTemp2;
494// pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 5 );
495 pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 8 );
496// Kit_DsdPrintExpanded( pTemp );
497 pTemp2 = Kit_DsdExpand( pTemp );
498 Kit_DsdPrint( stdout, pTemp2 );
499 Kit_DsdVerify( pTemp2, pTruth, nVars );
500 Kit_DsdNtkFree( pTemp2 );
501 Kit_DsdNtkFree( pTemp );
502}
void Kit_DsdVerify(Kit_DsdNtk_t *pNtk, unsigned *pTruth, int nVars)
Definition kitDsd.c:2493
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
Definition kitDsd.c:375
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition kitDsd.c:164
Kit_DsdNtk_t * Kit_DsdDecomposeMux(unsigned *pTruth, int nVars, int nDecMux)
Definition kitDsd.c:2351
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)
Definition kitDsd.c:1452
struct Kit_DsdNtk_t_ Kit_DsdNtk_t
Definition kit.h:124
Here is the caller graph for this function: