ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cutTruth.c
Go to the documentation of this file.
1
20
21#include "cutInt.h"
22
24
25
26/*
27 Truth tables computed in this package are represented as bit-strings
28 stored in the cut data structure. Cuts of any number of inputs have
29 the truth table with 2^k bits, where k is the max number of cut inputs.
30*/
31
35
36// used in abcCut.c
37int nTotal = 0;
38int nGood = 0;
39int nEqual = 0;
40
44
56static inline unsigned Cut_TruthPhase( Cut_Cut_t * pCut, Cut_Cut_t * pCut1 )
57{
58 unsigned uPhase = 0;
59 int i, k;
60 for ( i = k = 0; i < (int)pCut->nLeaves; i++ )
61 {
62 if ( k == (int)pCut1->nLeaves )
63 break;
64 if ( pCut->pLeaves[i] < pCut1->pLeaves[k] )
65 continue;
66 assert( pCut->pLeaves[i] == pCut1->pLeaves[k] );
67 uPhase |= (1 << i);
68 k++;
69 }
70 return uPhase;
71}
72
86{
87 unsigned uTruth;
88 unsigned * uCanon2;
89 char * pPhases2;
90 assert( pCut->nVarsMax < 6 );
91
92 // get the direct truth table
93 uTruth = *Cut_CutReadTruth(pCut);
94
95 // compute the direct truth table
96 Extra_TruthCanonFastN( pCut->nVarsMax, pCut->nLeaves, &uTruth, &uCanon2, &pPhases2 );
97// uCanon[0] = uCanon2[0];
98// uCanon[1] = (p->nVarsMax == 6)? uCanon2[1] : uCanon2[0];
99// uPhases[0] = pPhases2[0];
100 pCut->uCanon0 = uCanon2[0];
101 pCut->Num0 = pPhases2[0];
102
103 // get the complemented truth table
104 uTruth = ~*Cut_CutReadTruth(pCut);
105
106 // compute the direct truth table
107 Extra_TruthCanonFastN( pCut->nVarsMax, pCut->nLeaves, &uTruth, &uCanon2, &pPhases2 );
108// uCanon[0] = uCanon2[0];
109// uCanon[1] = (p->nVarsMax == 6)? uCanon2[1] : uCanon2[0];
110// uPhases[0] = pPhases2[0];
111 pCut->uCanon1 = uCanon2[0];
112 pCut->Num1 = pPhases2[0];
113}
114
126void Cut_TruthComputeOld( Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1, int fCompl0, int fCompl1 )
127{
128 static unsigned uTruth0[8], uTruth1[8];
129 int nTruthWords = Cut_TruthWords( pCut->nVarsMax );
130 unsigned * pTruthRes;
131 int i, uPhase;
132
133 // permute the first table
134 uPhase = Cut_TruthPhase( pCut, pCut0 );
135 Extra_TruthExpand( pCut->nVarsMax, nTruthWords, Cut_CutReadTruth(pCut0), uPhase, uTruth0 );
136 if ( fCompl0 )
137 {
138 for ( i = 0; i < nTruthWords; i++ )
139 uTruth0[i] = ~uTruth0[i];
140 }
141
142 // permute the second table
143 uPhase = Cut_TruthPhase( pCut, pCut1 );
144 Extra_TruthExpand( pCut->nVarsMax, nTruthWords, Cut_CutReadTruth(pCut1), uPhase, uTruth1 );
145 if ( fCompl1 )
146 {
147 for ( i = 0; i < nTruthWords; i++ )
148 uTruth1[i] = ~uTruth1[i];
149 }
150
151 // write the resulting table
152 pTruthRes = Cut_CutReadTruth(pCut);
153
154 if ( pCut->fCompl )
155 {
156 for ( i = 0; i < nTruthWords; i++ )
157 pTruthRes[i] = ~(uTruth0[i] & uTruth1[i]);
158 }
159 else
160 {
161 for ( i = 0; i < nTruthWords; i++ )
162 pTruthRes[i] = uTruth0[i] & uTruth1[i];
163 }
164}
165
177void Cut_TruthCompute( Cut_Man_t * p, Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1, int fCompl0, int fCompl1 )
178{
179 // permute the first table
180 if ( fCompl0 )
181 Extra_TruthNot( p->puTemp[0], Cut_CutReadTruth(pCut0), pCut->nVarsMax );
182 else
183 Extra_TruthCopy( p->puTemp[0], Cut_CutReadTruth(pCut0), pCut->nVarsMax );
184 Extra_TruthStretch( p->puTemp[2], p->puTemp[0], pCut0->nLeaves, pCut->nVarsMax, Cut_TruthPhase(pCut, pCut0) );
185 // permute the second table
186 if ( fCompl1 )
187 Extra_TruthNot( p->puTemp[1], Cut_CutReadTruth(pCut1), pCut->nVarsMax );
188 else
189 Extra_TruthCopy( p->puTemp[1], Cut_CutReadTruth(pCut1), pCut->nVarsMax );
190 Extra_TruthStretch( p->puTemp[3], p->puTemp[1], pCut1->nLeaves, pCut->nVarsMax, Cut_TruthPhase(pCut, pCut1) );
191 // produce the resulting table
192 if ( pCut->fCompl )
193 Extra_TruthNand( Cut_CutReadTruth(pCut), p->puTemp[2], p->puTemp[3], pCut->nVarsMax );
194 else
195 Extra_TruthAnd( Cut_CutReadTruth(pCut), p->puTemp[2], p->puTemp[3], pCut->nVarsMax );
196
197// Ivy_TruthTestOne( *Cut_CutReadTruth(pCut) );
198
199 // quit if no fancy computation is needed
200 if ( !p->pParams->fFancy )
201 return;
202
203 if ( pCut->nLeaves != 7 )
204 return;
205
206 // count the total number of truth tables computed
207 nTotal++;
208
209 // MAPPING INTO ALTERA 6-2 LOGIC BLOCKS
210 // call this procedure to find the minimum number of common variables in the cofactors
211 // if this number is less or equal than 3, the cut can be implemented using the 6-2 logic block
212 if ( Extra_TruthMinCofSuppOverlap( Cut_CutReadTruth(pCut), pCut->nVarsMax, NULL ) <= 4 )
213 nGood++;
214
215 // MAPPING INTO ACTEL 2x2 CELLS
216 // call this procedure to see if a semi-canonical form can be found in the lookup table
217 // (if it exists, then a two-level 3-input LUT implementation of the cut exists)
218 // Before this procedure is called, cell manager should be defined by calling
219 // Cut_CellLoad (make sure file "cells22_daomap_iwls.txt" is available in the working dir)
220// if ( Cut_CellIsRunning() && pCut->nVarsMax <= 9 )
221// nGood += Cut_CellTruthLookup( Cut_CutReadTruth(pCut), pCut->nVarsMax );
222}
223
224
225
229
230
232
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
int nGood
Definition abcCut.c:34
int nTotal
DECLARATIONS ///.
Definition cutTruth.c:37
int nEqual
Definition abcCut.c:34
void Cut_TruthComputeOld(Cut_Cut_t *pCut, Cut_Cut_t *pCut0, Cut_Cut_t *pCut1, int fCompl0, int fCompl1)
Definition cutTruth.c:126
void Cut_TruthCompute(Cut_Man_t *p, Cut_Cut_t *pCut, Cut_Cut_t *pCut0, Cut_Cut_t *pCut1, int fCompl0, int fCompl1)
Definition cutTruth.c:177
void Cut_TruthNCanonicize(Cut_Cut_t *pCut)
Definition cutTruth.c:85
struct Cut_ManStruct_t_ Cut_Man_t
BASIC TYPES ///.
Definition cut.h:48
struct Cut_CutStruct_t_ Cut_Cut_t
Definition cut.h:50
Cube * p
Definition exorList.c:222
void Extra_TruthExpand(int nVars, int nWords, unsigned *puTruth, unsigned uPhase, unsigned *puTruthR)
int Extra_TruthMinCofSuppOverlap(unsigned *pTruth, int nVars, int *pVarMin)
void Extra_TruthStretch(unsigned *pOut, unsigned *pIn, int nVars, int nVarsAll, unsigned Phase)
int Extra_TruthCanonFastN(int nVarsMax, int nVarsReal, unsigned *pt, unsigned **pptRes, char **ppfRes)
unsigned uCanon0
Definition cut.h:86
unsigned uCanon1
Definition cut.h:87
unsigned nVarsMax
Definition cut.h:83
unsigned Num1
Definition cut.h:80
unsigned Num0
Definition cut.h:79
int pLeaves[0]
Definition cut.h:89
unsigned fCompl
Definition cut.h:82
unsigned nLeaves
Definition cut.h:84
#define assert(ex)
Definition util_old.h:213