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

Go to the source code of this file.

Macros

#define KIT_FACTOR_MEM_LIMIT   (1<<20)
 DECLARATIONS ///.
 

Functions

int Kit_SopFactorVerify (Vec_Int_t *cSop, Kit_Graph_t *pFForm, int nVars)
 
Kit_Graph_tKit_SopFactor (Vec_Int_t *vCover, int fCompl, int nVars, Vec_Int_t *vMemory)
 FUNCTION DEFINITIONS ///.
 
Kit_Edge_t Kit_SopFactorTrivialCube_rec (Kit_Graph_t *pFForm, unsigned uCube, int nStart, int nFinish)
 
Kit_Edge_t Kit_SopFactorTrivial_rec (Kit_Graph_t *pFForm, unsigned *pCubes, int nCubes, int nLits)
 
void Kit_FactorTest (unsigned *pTruth, int nVars)
 

Macro Definition Documentation

◆ KIT_FACTOR_MEM_LIMIT

#define KIT_FACTOR_MEM_LIMIT   (1<<20)

DECLARATIONS ///.

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

FileName [kitFactor.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Computation kit.]

Synopsis [Algebraic factoring.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - Dec 6, 2006.]

Revision [

Id
kitFactor.c,v 1.00 2006/12/06 00:00:00 alanmi Exp

]

Definition at line 31 of file kitFactor.c.

Function Documentation

◆ Kit_FactorTest()

void Kit_FactorTest ( unsigned * pTruth,
int nVars )

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

Synopsis [Testing procedure for the factoring code.]

Description []

SideEffects []

SeeAlso []

Definition at line 308 of file kitFactor.c.

309{
310 Vec_Int_t * vCover, * vMemory;
311 Kit_Graph_t * pGraph;
312// unsigned uTruthRes;
313 int RetValue;
314
315 // derive SOP
316 vCover = Vec_IntAlloc( 0 );
317 RetValue = Kit_TruthIsop( pTruth, nVars, vCover, 0 );
318 assert( RetValue == 0 );
319
320 // derive factored form
321 vMemory = Vec_IntAlloc( 0 );
322 pGraph = Kit_SopFactor( vCover, 0, nVars, vMemory );
323/*
324 // derive truth table
325 assert( nVars <= 5 );
326 uTruthRes = Kit_GraphToTruth( pGraph );
327 if ( uTruthRes != pTruth[0] )
328 printf( "Verification failed!" );
329*/
330 printf( "Vars = %2d. Cubes = %3d. FFNodes = %3d. FF_memory = %3d.\n",
331 nVars, Vec_IntSize(vCover), Kit_GraphNodeNum(pGraph), Vec_IntSize(vMemory) );
332
333 Vec_IntFree( vMemory );
334 Vec_IntFree( vCover );
335 Kit_GraphFree( pGraph );
336}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Kit_Graph_t * Kit_SopFactor(Vec_Int_t *vCover, int fCompl, int nVars, Vec_Int_t *vMemory)
FUNCTION DEFINITIONS ///.
Definition kitFactor.c:55
struct Kit_Graph_t_ Kit_Graph_t
Definition kit.h:88
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
Definition kitIsop.c:134
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition kitGraph.c:132
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Kit_SopFactor()

Kit_Graph_t * Kit_SopFactor ( Vec_Int_t * vCover,
int fCompl,
int nVars,
Vec_Int_t * vMemory )

FUNCTION DEFINITIONS ///.

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

Synopsis [Factors the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 55 of file kitFactor.c.

56{
57 Kit_Sop_t Sop, * cSop = &Sop;
58 Kit_Graph_t * pFForm;
59 Kit_Edge_t eRoot;
60// int nCubes;
61
62 // works for up to 15 variables because division procedure
63 // used the last bit for marking the cubes going to the remainder
64 assert( nVars < 16 );
65
66 // check for trivial functions
67 if ( Vec_IntSize(vCover) == 0 )
68 return Kit_GraphCreateConst0();
69 if ( Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover, 0) == 0 )
70 return Kit_GraphCreateConst1();
71
72 // prepare memory manager
73// Vec_IntClear( vMemory );
74 Vec_IntGrow( vMemory, KIT_FACTOR_MEM_LIMIT );
75
76 // perform CST
77 Kit_SopCreateInverse( cSop, vCover, 2 * nVars, vMemory ); // CST
78
79 // start the factored form
80 pFForm = Kit_GraphCreate( nVars );
81 // factor the cover
82 eRoot = Kit_SopFactor_rec( pFForm, cSop, 2 * nVars, vMemory );
83 // finalize the factored form
84 Kit_GraphSetRoot( pFForm, eRoot );
85 if ( fCompl )
86 Kit_GraphComplement( pFForm );
87
88 // verify the factored form
89// nCubes = Vec_IntSize(vCover);
90// Vec_IntShrink( vCover, nCubes );
91// if ( !Kit_SopFactorVerify( vCover, pFForm, nVars ) )
92// printf( "Verification has failed.\n" );
93 return pFForm;
94}
#define KIT_FACTOR_MEM_LIMIT
DECLARATIONS ///.
Definition kitFactor.c:31
typedefABC_NAMESPACE_HEADER_START struct Kit_Sop_t_ Kit_Sop_t
INCLUDES ///.
Definition kit.h:54
Kit_Graph_t * Kit_GraphCreateConst1()
Definition kitGraph.c:91
void Kit_SopCreateInverse(Kit_Sop_t *cResult, Vec_Int_t *vInput, int nVars, Vec_Int_t *vMemory)
Definition kitSop.c:68
Kit_Graph_t * Kit_GraphCreate(int nLeaves)
DECLARATIONS ///.
Definition kitGraph.c:46
Kit_Graph_t * Kit_GraphCreateConst0()
Definition kitGraph.c:70
struct Kit_Edge_t_ Kit_Edge_t
Definition kit.h:62
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_SopFactorTrivial_rec()

Kit_Edge_t Kit_SopFactorTrivial_rec ( Kit_Graph_t * pFForm,
unsigned * pCubes,
int nCubes,
int nLits )

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

Synopsis [Factoring SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 263 of file kitFactor.c.

264{
265 Kit_Edge_t eNode1, eNode2;
266 int nCubes1, nCubes2;
267 if ( nCubes == 1 )
268 return Kit_SopFactorTrivialCube_rec( pFForm, pCubes[0], 0, nLits );
269 // split the cubes into two parts
270 nCubes1 = nCubes/2;
271 nCubes2 = nCubes - nCubes1;
272// nCubes2 = nCubes/2;
273// nCubes1 = nCubes - nCubes2;
274 // recursively construct the tree for the parts
275 eNode1 = Kit_SopFactorTrivial_rec( pFForm, pCubes, nCubes1, nLits );
276 eNode2 = Kit_SopFactorTrivial_rec( pFForm, pCubes + nCubes1, nCubes2, nLits );
277 return Kit_GraphAddNodeOr( pFForm, eNode1, eNode2 );
278}
Kit_Edge_t Kit_SopFactorTrivial_rec(Kit_Graph_t *pFForm, unsigned *pCubes, int nCubes, int nLits)
Definition kitFactor.c:263
Kit_Edge_t Kit_SopFactorTrivialCube_rec(Kit_Graph_t *pFForm, unsigned uCube, int nStart, int nFinish)
Definition kitFactor.c:199
Kit_Edge_t Kit_GraphAddNodeOr(Kit_Graph_t *pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1)
Definition kitGraph.c:197
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_SopFactorTrivialCube_rec()

Kit_Edge_t Kit_SopFactorTrivialCube_rec ( Kit_Graph_t * pFForm,
unsigned uCube,
int nStart,
int nFinish )

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

Synopsis [Factoring cube.]

Description []

SideEffects []

SeeAlso []

Definition at line 199 of file kitFactor.c.

200{
201 Kit_Edge_t eNode1, eNode2;
202 int i, iLit = -1, nLits, nLits1, nLits2;
203 assert( uCube );
204 // count the number of literals in this interval
205 nLits = 0;
206 for ( i = nStart; i < nFinish; i++ )
207 if ( Kit_CubeHasLit(uCube, i) )
208 {
209 iLit = i;
210 nLits++;
211 }
212 assert( iLit != -1 );
213 // quit if there is only one literal
214 if ( nLits == 1 )
215 return Kit_EdgeCreate( iLit/2, iLit%2 ); // CST
216 // split the literals into two parts
217 nLits1 = nLits/2;
218 nLits2 = nLits - nLits1;
219// nLits2 = nLits/2;
220// nLits1 = nLits - nLits2;
221 // find the splitting point
222 nLits = 0;
223 for ( i = nStart; i < nFinish; i++ )
224 if ( Kit_CubeHasLit(uCube, i) )
225 {
226 if ( nLits == nLits1 )
227 break;
228 nLits++;
229 }
230 // recursively construct the tree for the parts
231 eNode1 = Kit_SopFactorTrivialCube_rec( pFForm, uCube, nStart, i );
232 eNode2 = Kit_SopFactorTrivialCube_rec( pFForm, uCube, i, nFinish );
233 return Kit_GraphAddNodeAnd( pFForm, eNode1, eNode2 );
234}
Kit_Edge_t Kit_GraphAddNodeAnd(Kit_Graph_t *pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1)
Definition kitGraph.c:173
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_SopFactorVerify()

int Kit_SopFactorVerify ( Vec_Int_t * cSop,
Kit_Graph_t * pFForm,
int nVars )
extern