src/sat/fraig/fraigChoice.c File Reference

#include "fraigInt.h"
Include dependency graph for fraigChoice.c:

Go to the source code of this file.

Functions

void Fraig_ManAddChoices (Fraig_Man_t *pMan, int fVerbose, int nLimit)

Function Documentation

void Fraig_ManAddChoices ( Fraig_Man_t pMan,
int  fVerbose,
int  nLimit 
)

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

FileName [fraigTrans.c]

PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

Synopsis [Adds the additive and distributive choices to the AIG.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - February 1, 2003.]

Revision [

Id
fraigTrans.c,v 1.1 2005/02/28 05:34:34 alanmi Exp

] DECLARATIONS /// FUNCTION DEFITIONS ///Function*************************************************************

Synopsis [Adds choice nodes based on associativity.]

Description [Make nLimit big AND gates and add all decompositions to the Fraig.]

SideEffects []

SeeAlso []

Definition at line 41 of file fraigChoice.c.

00042 {
00043 //    ProgressBar * pProgress;
00044     char Buffer[100];
00045     int clkTotal = clock();
00046     int i, nNodesBefore, nNodesAfter, nInputs, nMaxNodes;
00047     int /*nMaxLevel,*/ nDistributive;
00048     Fraig_Node_t *pNode, *pRepr;
00049     Fraig_Node_t *pX, *pA, *pB, *pC, /* *pD,*/ *pN, /* *pQ, *pR,*/ *pT;
00050     int fShortCut = 0;
00051 
00052     nDistributive = 0;
00053 
00054 //    Fraig_ManSetApprox( pMan, 1 );
00055 
00056     // NO functional reduction
00057     if (fShortCut) Fraig_ManSetFuncRed( pMan, 0 );
00058 
00059     // First we mark critical functions i.e. compute those
00060     // nodes which lie on the critical path. Note that this
00061     // doesn't update the required times on any choice nodes
00062     // which are not the representatives
00063 /*
00064     nMaxLevel = Fraig_GetMaxLevel( pMan );
00065     for ( i = 0; i < pMan->nOutputs; i++ )
00066     {
00067         Fraig_SetNodeRequired( pMan, pMan->pOutputs[i], nMaxLevel );
00068     }
00069 */
00070     nNodesBefore = Fraig_ManReadNodeNum( pMan );
00071     nInputs      = Fraig_ManReadInputNum( pMan );
00072     nMaxNodes    = nInputs + nLimit * ( nNodesBefore - nInputs );
00073 
00074     printf ("Limit = %d, Before = %d\n", nMaxNodes, nNodesBefore );
00075 
00076     if (0) 
00077     {
00078         char buffer[128];
00079         sprintf (buffer, "test" );
00080 //        Fraig_MappingShow( pMan, buffer );
00081     }
00082 
00083 //    pProgress = Extra_ProgressBarStart( stdout, nMaxNodes );
00084 Fraig_ManCheckConsistency( pMan );
00085 
00086     for ( i = nInputs+1; (i < Fraig_ManReadNodeNum( pMan )) 
00087             && (nMaxNodes > Fraig_ManReadNodeNum( pMan )); ++i )
00088     {
00089 //        if ( i == nNodesBefore )
00090 //            break;
00091 
00092         pNode = Fraig_ManReadIthNode( pMan, i );
00093         assert ( pNode );
00094 
00095         pRepr = pNode->pRepr ? pNode->pRepr : pNode;
00096         //printf ("Slack: %d\n", Fraig_NodeReadSlack( pRepr ));
00097         
00098         // All the new associative choices we add will have huge slack
00099         // since we do not redo timing, and timing doesnt handle choices
00100         // well anyway. However every newly added node is a choice of an
00101         // existing critical node, so they are considered critical.
00102 //        if ( (Fraig_NodeReadSlack( pRepr ) > 3) && (i < nNodesBefore)  )     
00103 //            continue;
00104 
00105 //        if ( pNode->pRepr )
00106 //            continue;
00107 
00108         // Try ((ab)c), x = ab -> (a(bc)) and (b(ac))
00109         pX = Fraig_NodeReadOne(pNode);
00110         pC = Fraig_NodeReadTwo(pNode);
00111         if (Fraig_NodeIsAnd(pX) && !Fraig_IsComplement(pX))
00112         {
00113             pA = Fraig_NodeReadOne(Fraig_Regular(pX));
00114             pB = Fraig_NodeReadTwo(Fraig_Regular(pX));
00115 
00116 //            pA = Fraig_NodeGetRepr( pA );
00117 //            pB = Fraig_NodeGetRepr( pB );
00118 //            pC = Fraig_NodeGetRepr( pC );
00119 
00120             if (fShortCut) 
00121             {
00122                 pT = Fraig_NodeAnd(pMan, pB, pC);
00123                 if ( !pT->pRepr )
00124                 {
00125                     pN = Fraig_NodeAnd(pMan, pA, pT);
00126 //                    Fraig_NodeAddChoice( pMan, pNode, pN );
00127                 }
00128             }
00129             else
00130                 pN = Fraig_NodeAnd(pMan, pA, Fraig_NodeAnd(pMan, pB, pC));
00131             // assert ( Fraig_NodesEqual(pN, pNode) );
00132 
00133 
00134             if (fShortCut) 
00135             {
00136                 pT = Fraig_NodeAnd(pMan, pA, pC);
00137                 if ( !pT->pRepr )
00138                 {
00139                     pN = Fraig_NodeAnd(pMan, pB, pT);
00140 //                    Fraig_NodeAddChoice( pMan, pNode, pN );
00141                 }
00142             }
00143             else
00144                 pN = Fraig_NodeAnd(pMan, pB, Fraig_NodeAnd(pMan, pA, pC));
00145             // assert ( Fraig_NodesEqual(pN, pNode) );
00146         }
00147 
00148 
00149         // Try (a(bc)), x = bc -> ((ab)c) and ((ac)b)
00150         pA = Fraig_NodeReadOne(pNode);
00151         pX = Fraig_NodeReadTwo(pNode);
00152         if (Fraig_NodeIsAnd(pX) && !Fraig_IsComplement(pX))
00153         {
00154             pB = Fraig_NodeReadOne(Fraig_Regular(pX));
00155             pC = Fraig_NodeReadTwo(Fraig_Regular(pX));
00156 
00157 //            pA = Fraig_NodeGetRepr( pA );
00158 //            pB = Fraig_NodeGetRepr( pB );
00159 //            pC = Fraig_NodeGetRepr( pC );
00160 
00161             if (fShortCut) 
00162             {
00163                 pT = Fraig_NodeAnd(pMan, pA, pB);
00164                 if ( !pT->pRepr )
00165                 {
00166                     pN = Fraig_NodeAnd(pMan, pC, pT);
00167 //                    Fraig_NodeAddChoice( pMan, pNode, pN );
00168                 }
00169             }
00170             else
00171                 pN = Fraig_NodeAnd(pMan, Fraig_NodeAnd(pMan, pA, pB), pC);
00172             // assert ( Fraig_NodesEqual(pN, pNode) );
00173 
00174             if (fShortCut) 
00175             {
00176                 pT = Fraig_NodeAnd(pMan, pA, pC);
00177                 if ( !pT->pRepr )
00178                 {
00179                     pN = Fraig_NodeAnd(pMan, pB, pT);
00180 //                    Fraig_NodeAddChoice( pMan, pNode, pN );
00181                 }
00182             }
00183             else
00184                 pN = Fraig_NodeAnd(pMan, Fraig_NodeAnd(pMan, pA, pC), pB);
00185             // assert ( Fraig_NodesEqual(pN, pNode) );
00186         }
00187 
00188 
00189 /*
00190         // Try distributive transform
00191         pQ = Fraig_NodeReadOne(pNode);
00192         pR = Fraig_NodeReadTwo(pNode);
00193         if ( (Fraig_IsComplement(pQ) && Fraig_NodeIsAnd(pQ))
00194              && (Fraig_IsComplement(pR) && Fraig_NodeIsAnd(pR)) )
00195         {
00196             pA = Fraig_NodeReadOne(Fraig_Regular(pQ));
00197             pB = Fraig_NodeReadTwo(Fraig_Regular(pQ));
00198             pC = Fraig_NodeReadOne(Fraig_Regular(pR));
00199             pD = Fraig_NodeReadTwo(Fraig_Regular(pR));
00200 
00201             // Now detect the !(xy + xz) pattern, store 
00202             // x in pA, y in pB and z in pC and set pD = 0 to indicate
00203             // pattern was found
00204             assert (pD != 0);
00205             if (pA == pC) { pC = pD;                   pD = 0; } 
00206             if (pA == pD) {                            pD = 0; } 
00207             if (pB == pC) { pB = pA; pA = pC; pC = pD; pD = 0; }
00208             if (pB == pD) { pB = pA; pA = pD;          pD = 0; }
00209             if (pD == 0)
00210             {
00211                 nDistributive++;
00212                 pN = Fraig_Not(Fraig_NodeAnd(pMan, pA, 
00213                         Fraig_NodeOr(pMan, pB, pC)));
00214                 if (fShortCut) Fraig_NodeAddChoice( pMan, pNode, pN );
00215                 // assert ( Fraig_NodesEqual(pN, pNode) );
00216             }
00217         }
00218 */            
00219         if ( i % 1000 == 0 )
00220         {
00221             sprintf( Buffer, "Adding choice %6d...", i - nNodesBefore );
00222 //            Extra_ProgressBarUpdate( pProgress, i, Buffer );
00223         }
00224     }
00225 
00226 //    Extra_ProgressBarStop( pProgress );
00227 
00228 Fraig_ManCheckConsistency( pMan );
00229 
00230     nNodesAfter = Fraig_ManReadNodeNum( pMan );
00231     printf ( "Nodes before = %6d. Nodes with associative choices = %6d. Increase = %4.2f %%.\n", 
00232             nNodesBefore, nNodesAfter, ((float)(nNodesAfter - nNodesBefore)) * 100.0/(nNodesBefore - nInputs) );
00233     printf ( "Distributive = %d\n", nDistributive );
00234 
00235 }


Generated on Tue Jan 5 12:19:38 2010 for abc70930 by  doxygen 1.6.1