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

Go to the source code of this file.

Macros

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

Functions

int Kit_TruthIsop2 (unsigned *puTruth0, unsigned *puTruth1, int nVars, Vec_Int_t *vMemory, int fTryBoth, int fReturnTt)
 FUNCTION DEFINITIONS ///.
 
int Kit_TruthIsop (unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
 
void Kit_TruthIsopPrintCover (Vec_Int_t *vCover, int nVars, int fCompl)
 
void Kit_TruthIsopPrint (unsigned *puTruth, int nVars, Vec_Int_t *vCover, int fTryBoth)
 

Macro Definition Documentation

◆ KIT_ISOP_MEM_LIMIT

#define KIT_ISOP_MEM_LIMIT   (1<<20)

DECLARATIONS ///.

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

FileName [kitIsop.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Computation kit.]

Synopsis [ISOP computation based on Morreale's algorithm.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 31 of file kitIsop.c.

Function Documentation

◆ Kit_TruthIsop()

int Kit_TruthIsop ( unsigned * puTruth,
int nVars,
Vec_Int_t * vMemory,
int fTryBoth )

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

Synopsis [Computes ISOP from TT.]

Description [Returns the cover in vMemory. Uses the rest of array in vMemory as an intermediate memory storage. Returns the cover with -1 cubes, if the the computation exceeded the memory limit (KIT_ISOP_MEM_LIMIT words of intermediate data).]

SideEffects []

SeeAlso []

Definition at line 134 of file kitIsop.c.

135{
136 Kit_Sop_t cRes, * pcRes = &cRes;
137 Kit_Sop_t cRes2, * pcRes2 = &cRes2;
138 unsigned * pResult;
139 int RetValue = 0;
140 assert( nVars >= 0 && nVars <= 16 );
141 // if nVars < 5, make sure it does not depend on those vars
142// for ( i = nVars; i < 5; i++ )
143// assert( !Kit_TruthVarInSupport(puTruth, 5, i) );
144 // prepare memory manager
145 Vec_IntClear( vMemory );
146 Vec_IntGrow( vMemory, KIT_ISOP_MEM_LIMIT );
147 // compute ISOP for the direct polarity
148 pResult = Kit_TruthIsop_rec( puTruth, puTruth, nVars, pcRes, vMemory );
149 if ( pcRes->nCubes == -1 )
150 {
151 vMemory->nSize = -1;
152 return -1;
153 }
154 assert( Kit_TruthIsEqual( puTruth, pResult, nVars ) );
155 if ( pcRes->nCubes == 0 || (pcRes->nCubes == 1 && pcRes->pCubes[0] == 0) )
156 {
157 vMemory->pArray[0] = 0;
158 Vec_IntShrink( vMemory, pcRes->nCubes );
159 return 0;
160 }
161 if ( fTryBoth )
162 {
163 // compute ISOP for the complemented polarity
164 Kit_TruthNot( puTruth, puTruth, nVars );
165 pResult = Kit_TruthIsop_rec( puTruth, puTruth, nVars, pcRes2, vMemory );
166 if ( pcRes2->nCubes >= 0 )
167 {
168 assert( Kit_TruthIsEqual( puTruth, pResult, nVars ) );
169 if ( pcRes->nCubes > pcRes2->nCubes || (pcRes->nCubes == pcRes2->nCubes && pcRes->nLits > pcRes2->nLits) )
170 {
171 RetValue = 1;
172 pcRes = pcRes2;
173 }
174 }
175 Kit_TruthNot( puTruth, puTruth, nVars );
176 }
177// printf( "%d ", vMemory->nSize );
178 // move the cover representation to the beginning of the memory buffer
179 memmove( vMemory->pArray, pcRes->pCubes, pcRes->nCubes * sizeof(unsigned) );
180 Vec_IntShrink( vMemory, pcRes->nCubes );
181 return RetValue;
182}
#define KIT_ISOP_MEM_LIMIT
DECLARATIONS ///.
Definition kitIsop.c:31
typedefABC_NAMESPACE_HEADER_START struct Kit_Sop_t_ Kit_Sop_t
INCLUDES ///.
Definition kit.h:54
#define assert(ex)
Definition util_old.h:213
char * memmove()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthIsop2()

int Kit_TruthIsop2 ( unsigned * puTruth0,
unsigned * puTruth1,
int nVars,
Vec_Int_t * vMemory,
int fTryBoth,
int fReturnTt )

FUNCTION DEFINITIONS ///.

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

Synopsis [Computes ISOP from TT.]

Description [Returns the cover in vMemory. Uses the rest of array in vMemory as an intermediate memory storage. Returns the cover with -1 cubes, if the the computation exceeded the memory limit (KIT_ISOP_MEM_LIMIT words of intermediate data).]

SideEffects []

SeeAlso []

Definition at line 55 of file kitIsop.c.

56{
57 Kit_Sop_t cRes, * pcRes = &cRes;
58 Kit_Sop_t cRes2, * pcRes2 = &cRes2;
59 unsigned * pResult;
60 int RetValue = 0;
61 assert( nVars >= 0 && nVars <= 16 );
62 // prepare memory manager
63 Vec_IntClear( vMemory );
64 Vec_IntGrow( vMemory, KIT_ISOP_MEM_LIMIT );
65 // compute ISOP for the direct polarity
66 Kit_TruthNot( puTruth0, puTruth0, nVars );
67 pResult = Kit_TruthIsop_rec( puTruth1, puTruth0, nVars, pcRes, vMemory );
68 Kit_TruthNot( puTruth0, puTruth0, nVars );
69 if ( pcRes->nCubes == -1 )
70 {
71 vMemory->nSize = -1;
72 return -1;
73 }
74 assert( Kit_TruthIsImply( puTruth1, pResult, nVars ) );
75 Kit_TruthNot( puTruth0, puTruth0, nVars );
76 assert( Kit_TruthIsImply( pResult, puTruth0, nVars ) );
77 Kit_TruthNot( puTruth0, puTruth0, nVars );
78 if ( pcRes->nCubes == 0 || (pcRes->nCubes == 1 && pcRes->pCubes[0] == 0) )
79 {
80 vMemory->pArray[0] = 0;
81 Vec_IntShrink( vMemory, pcRes->nCubes );
82 return 0;
83 }
84 if ( fTryBoth )
85 {
86 // compute ISOP for the complemented polarity
87 Kit_TruthNot( puTruth1, puTruth1, nVars );
88 pResult = Kit_TruthIsop_rec( puTruth0, puTruth1, nVars, pcRes2, vMemory );
89 Kit_TruthNot( puTruth1, puTruth1, nVars );
90 if ( pcRes2->nCubes >= 0 )
91 {
92 assert( Kit_TruthIsImply( puTruth0, pResult, nVars ) );
93 Kit_TruthNot( puTruth1, puTruth1, nVars );
94 assert( Kit_TruthIsImply( pResult, puTruth1, nVars ) );
95 Kit_TruthNot( puTruth1, puTruth1, nVars );
96 if ( pcRes->nCubes > pcRes2->nCubes || (pcRes->nCubes == pcRes2->nCubes && pcRes->nLits > pcRes2->nLits) )
97 {
98 RetValue = 1;
99 pcRes = pcRes2;
100 }
101 }
102 }
103// printf( "%d ", vMemory->nSize );
104 // move the cover representation to the beginning of the memory buffer
105 if ( fReturnTt )
106 {
107 int nWords = Kit_TruthWordNum( nVars );
108 memmove( vMemory->pArray, pResult, nWords * sizeof(unsigned) );
109 Vec_IntShrink( vMemory, nWords );
110 }
111 else
112 {
113 memmove( vMemory->pArray, pcRes->pCubes, pcRes->nCubes * sizeof(unsigned) );
114 Vec_IntShrink( vMemory, pcRes->nCubes );
115 }
116 return RetValue;
117}
int nWords
Definition abcNpn.c:127
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthIsopPrint()

void Kit_TruthIsopPrint ( unsigned * puTruth,
int nVars,
Vec_Int_t * vCover,
int fTryBoth )

Definition at line 207 of file kitIsop.c.

208{
209 int fCompl = Kit_TruthIsop( puTruth, nVars, vCover, fTryBoth );
210 Kit_TruthIsopPrintCover( vCover, nVars, fCompl );
211}
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
Definition kitIsop.c:134
void Kit_TruthIsopPrintCover(Vec_Int_t *vCover, int nVars, int fCompl)
Definition kitIsop.c:183
Here is the call graph for this function:

◆ Kit_TruthIsopPrintCover()

void Kit_TruthIsopPrintCover ( Vec_Int_t * vCover,
int nVars,
int fCompl )

Definition at line 183 of file kitIsop.c.

184{
185 int i, k, Entry, Literal;
186 if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover, 0) == 0) )
187 {
188 printf( "Constant %d\n", Vec_IntSize(vCover) );
189 return;
190 }
191 Vec_IntForEachEntry( vCover, Entry, i )
192 {
193 for ( k = 0; k < nVars; k++ )
194 {
195 Literal = 3 & (Entry >> (k << 1));
196 if ( Literal == 1 ) // neg literal
197 printf( "0" );
198 else if ( Literal == 2 ) // pos literal
199 printf( "1" );
200 else if ( Literal == 0 )
201 printf( "-" );
202 else assert( 0 );
203 }
204 printf( " %d\n", !fCompl );
205 }
206}
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the caller graph for this function: