abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
luckyFast6.c File Reference
#include "luckyInt.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void resetPCanonPermArray_6Vars (char *x)
 
void resetPCanonPermArray (char *x, int nVars)
 
word Abc_allFlip (word x, unsigned *pCanonPhase)
 
unsigned adjustInfoAfterSwap (char *pCanonPerm, unsigned uCanonPhase, int iVar, unsigned info)
 
word Extra_Truth6SwapAdjacent (word t, int iVar)
 
word Extra_Truth6ChangePhase (word t, int iVar)
 
word Extra_Truth6MinimumRoundOne (word t, int iVar, char *pCanonPerm, unsigned *pCanonPhase)
 
word Extra_Truth6MinimumRoundOne_noEBFC (word t, int iVar, char *pCanonPerm, unsigned *pCanonPhase)
 
word Extra_Truth6MinimumRoundMany (word t, int *pStore, char *pCanonPerm, unsigned *pCanonPhase)
 
word Extra_Truth6MinimumRoundMany_noEBFC (word t, int *pStore, char *pCanonPerm, unsigned *pCanonPhase)
 
word Extra_Truth6MinimumRoundMany1 (word t, int *pStore, char *pCanonPerm, unsigned *pCanonPhase)
 
word luckyCanonicizer_final_fast_6Vars (word InOut, int *pStore, char *pCanonPerm, unsigned *pCanonPhase)
 
word luckyCanonicizer_final_fast_6Vars1 (word InOut, int *pStore, char *pCanonPerm, unsigned *pCanonPhase)
 

Function Documentation

word Abc_allFlip ( word  x,
unsigned *  pCanonPhase 
)

Definition at line 39 of file luckyFast6.c.

40 {
41  if( (x>>63) )
42  {
43  (* pCanonPhase) ^=(1<<6);
44  return ~x;
45  }
46  else
47  return x;
48 
49 }
unsigned adjustInfoAfterSwap ( char *  pCanonPerm,
unsigned  uCanonPhase,
int  iVar,
unsigned  info 
)

Definition at line 51 of file luckyFast6.c.

52 {
53  if(info<4)
54  return (uCanonPhase ^= (info << iVar));
55  else
56  {
57  char temp;
58  uCanonPhase ^= ((info-4) << iVar);
59  temp=pCanonPerm[iVar];
60  pCanonPerm[iVar]=pCanonPerm[iVar+1];
61  pCanonPerm[iVar+1]=temp;
62  if ( ((uCanonPhase & (1 << iVar)) > 0) != ((uCanonPhase & (1 << (iVar+1))) > 0) )
63  {
64  uCanonPhase ^= (1 << iVar);
65  uCanonPhase ^= (1 << (iVar+1));
66  }
67  return uCanonPhase;
68  }
69 
70 
71 }
word Extra_Truth6ChangePhase ( word  t,
int  iVar 
)

Definition at line 86 of file luckyFast6.c.

87 {
88  // elementary truth tables
89  static word Truth6[6] = {
90  ABC_CONST(0xAAAAAAAAAAAAAAAA),
91  ABC_CONST(0xCCCCCCCCCCCCCCCC),
92  ABC_CONST(0xF0F0F0F0F0F0F0F0),
93  ABC_CONST(0xFF00FF00FF00FF00),
94  ABC_CONST(0xFFFF0000FFFF0000),
95  ABC_CONST(0xFFFFFFFF00000000)
96  };
97  assert( iVar < 6 );
98  return ((t & ~Truth6[iVar]) << (1 << iVar)) | ((t & Truth6[iVar]) >> (1 << iVar));
99 }
static word Truth6[6]
Definition: ifDec07.c:52
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
#define assert(ex)
Definition: util_old.h:213
word Extra_Truth6MinimumRoundMany ( word  t,
int *  pStore,
char *  pCanonPerm,
unsigned *  pCanonPhase 
)

Definition at line 176 of file luckyFast6.c.

177 {
178  int i, bitInfoTemp;
179  word tMin0, tMin=t;
180  do
181  {
182  bitInfoTemp = pStore[0];
183  tMin0 = tMin;
184  for ( i = 0; i < 5; i++ )
185  {
186  if(bitInfoTemp == pStore[i+1])
187  tMin = Extra_Truth6MinimumRoundOne( tMin, i, pCanonPerm, pCanonPhase );
188  else
189  bitInfoTemp = pStore[i+1];
190  }
191  }while ( tMin0 != tMin );
192  return tMin;
193 }
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
word Extra_Truth6MinimumRoundOne(word t, int iVar, char *pCanonPerm, unsigned *pCanonPhase)
Definition: luckyFast6.c:101
word Extra_Truth6MinimumRoundMany1 ( word  t,
int *  pStore,
char *  pCanonPerm,
unsigned *  pCanonPhase 
)

Definition at line 213 of file luckyFast6.c.

214 {
215  word tMin0, tMin=t;
216  char pCanonPerm1[16];
217  unsigned uCanonPhase1;
218  switch ((* pCanonPhase) >> 7)
219  {
220  case 0 :
221  {
222 
223  return Extra_Truth6MinimumRoundMany_noEBFC( t, pStore, pCanonPerm, pCanonPhase);
224  }
225  case 1 :
226  {
227  return Extra_Truth6MinimumRoundMany( t, pStore, pCanonPerm, pCanonPhase);
228  }
229  case 2 :
230  {
231  uCanonPhase1 = *pCanonPhase;
232  uCanonPhase1 ^= (1 << 6);
233  memcpy(pCanonPerm1,pCanonPerm,sizeof(char)*16);
234  tMin0 = Extra_Truth6MinimumRoundMany_noEBFC( t, pStore, pCanonPerm, pCanonPhase);
235  tMin = Extra_Truth6MinimumRoundMany_noEBFC( ~t, pStore, pCanonPerm1, &uCanonPhase1);
236  if(tMin0 <=tMin)
237  return tMin0;
238  else
239  {
240  *pCanonPhase = uCanonPhase1;
241  memcpy(pCanonPerm,pCanonPerm1,sizeof(char)*16);
242  return tMin;
243  }
244  }
245  case 3 :
246  {
247  uCanonPhase1 = *pCanonPhase;
248  uCanonPhase1 ^= (1 << 6);
249  memcpy(pCanonPerm1,pCanonPerm,sizeof(char)*16);
250  tMin0 = Extra_Truth6MinimumRoundMany( t, pStore, pCanonPerm, pCanonPhase);
251  tMin = Extra_Truth6MinimumRoundMany( ~t, pStore, pCanonPerm1, &uCanonPhase1);
252  if(tMin0 <=tMin)
253  return tMin0;
254  else
255  {
256  *pCanonPhase = uCanonPhase1;
257  memcpy(pCanonPerm,pCanonPerm1,sizeof(char)*16);
258  return tMin;
259  }
260  }
261  }
262  return Extra_Truth6MinimumRoundMany( t, pStore, pCanonPerm, pCanonPhase);
263 }
word Extra_Truth6MinimumRoundMany(word t, int *pStore, char *pCanonPerm, unsigned *pCanonPhase)
Definition: luckyFast6.c:176
char * memcpy()
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
word Extra_Truth6MinimumRoundMany_noEBFC(word t, int *pStore, char *pCanonPerm, unsigned *pCanonPhase)
Definition: luckyFast6.c:195
word Extra_Truth6MinimumRoundMany_noEBFC ( word  t,
int *  pStore,
char *  pCanonPerm,
unsigned *  pCanonPhase 
)

Definition at line 195 of file luckyFast6.c.

196 {
197  int i, bitInfoTemp;
198  word tMin0, tMin=t;
199  do
200  {
201  bitInfoTemp = pStore[0];
202  tMin0 = tMin;
203  for ( i = 0; i < 5; i++ )
204  {
205  if(bitInfoTemp == pStore[i+1])
206  tMin = Extra_Truth6MinimumRoundOne_noEBFC( tMin, i, pCanonPerm, pCanonPhase );
207  else
208  bitInfoTemp = pStore[i+1];
209  }
210  }while ( tMin0 != tMin );
211  return tMin;
212 }
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
word Extra_Truth6MinimumRoundOne_noEBFC(word t, int iVar, char *pCanonPerm, unsigned *pCanonPhase)
Definition: luckyFast6.c:158
word Extra_Truth6MinimumRoundOne ( word  t,
int  iVar,
char *  pCanonPerm,
unsigned *  pCanonPhase 
)

Definition at line 101 of file luckyFast6.c.

102 {
103  word tCur, tMin = t; // ab
104  unsigned info =0;
105  assert( iVar >= 0 && iVar < 5 );
106 
107  tCur = Extra_Truth6ChangePhase( t, iVar ); // !a b
108  if(tCur<tMin)
109  {
110  info = 1;
111  tMin = tCur;
112  }
113  tCur = Extra_Truth6ChangePhase( t, iVar+1 ); // a !b
114  if(tCur<tMin)
115  {
116  info = 2;
117  tMin = tCur;
118  }
119  tCur = Extra_Truth6ChangePhase( tCur, iVar ); // !a !b
120  if(tCur<tMin)
121  {
122  info = 3;
123  tMin = tCur;
124  }
125 
126  t = Extra_Truth6SwapAdjacent( t, iVar ); // b a
127  if(t<tMin)
128  {
129  info = 4;
130  tMin = t;
131  }
132 
133  tCur = Extra_Truth6ChangePhase( t, iVar ); // !b a
134  if(tCur<tMin)
135  {
136  info = 6;
137  tMin = tCur;
138  }
139  tCur = Extra_Truth6ChangePhase( t, iVar+1 ); // b !a
140  if(tCur<tMin)
141  {
142  info = 5;
143  tMin = tCur;
144  }
145  tCur = Extra_Truth6ChangePhase( tCur, iVar ); // !b !a
146  if(tCur<tMin)
147  {
148  (* pCanonPhase) = adjustInfoAfterSwap(pCanonPerm, * pCanonPhase, iVar, 7);
149  return tCur;
150  }
151  else
152  {
153  (* pCanonPhase) = adjustInfoAfterSwap(pCanonPerm, * pCanonPhase, iVar, info);
154  return tMin;
155  }
156 }
word Extra_Truth6ChangePhase(word t, int iVar)
Definition: luckyFast6.c:86
unsigned adjustInfoAfterSwap(char *pCanonPerm, unsigned uCanonPhase, int iVar, unsigned info)
Definition: luckyFast6.c:51
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define assert(ex)
Definition: util_old.h:213
word Extra_Truth6SwapAdjacent(word t, int iVar)
Definition: luckyFast6.c:73
word Extra_Truth6MinimumRoundOne_noEBFC ( word  t,
int  iVar,
char *  pCanonPerm,
unsigned *  pCanonPhase 
)

Definition at line 158 of file luckyFast6.c.

159 {
160  word tMin;
161  assert( iVar >= 0 && iVar < 5 );
162 
163  tMin = Extra_Truth6SwapAdjacent( t, iVar ); // b a
164  if(t<tMin)
165  return t;
166  else
167  {
168  (* pCanonPhase) = adjustInfoAfterSwap(pCanonPerm, * pCanonPhase, iVar, 4);
169  return tMin;
170  }
171 }
unsigned adjustInfoAfterSwap(char *pCanonPerm, unsigned uCanonPhase, int iVar, unsigned info)
Definition: luckyFast6.c:51
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define assert(ex)
Definition: util_old.h:213
word Extra_Truth6SwapAdjacent(word t, int iVar)
Definition: luckyFast6.c:73
word Extra_Truth6SwapAdjacent ( word  t,
int  iVar 
)

Definition at line 73 of file luckyFast6.c.

74 {
75  // variable swapping code
76  static word PMasks[5][3] = {
77  { ABC_CONST(0x9999999999999999), ABC_CONST(0x2222222222222222), ABC_CONST(0x4444444444444444) },
78  { ABC_CONST(0xC3C3C3C3C3C3C3C3), ABC_CONST(0x0C0C0C0C0C0C0C0C), ABC_CONST(0x3030303030303030) },
79  { ABC_CONST(0xF00FF00FF00FF00F), ABC_CONST(0x00F000F000F000F0), ABC_CONST(0x0F000F000F000F00) },
80  { ABC_CONST(0xFF0000FFFF0000FF), ABC_CONST(0x0000FF000000FF00), ABC_CONST(0x00FF000000FF0000) },
81  { ABC_CONST(0xFFFF00000000FFFF), ABC_CONST(0x00000000FFFF0000), ABC_CONST(0x0000FFFF00000000) }
82  };
83  assert( iVar < 5 );
84  return (t & PMasks[iVar][0]) | ((t & PMasks[iVar][1]) << (1 << iVar)) | ((t & PMasks[iVar][2]) >> (1 << iVar));
85 }
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static word PMasks[5][3]
Definition: ifDec07.c:44
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
#define assert(ex)
Definition: util_old.h:213
word luckyCanonicizer_final_fast_6Vars ( word  InOut,
int *  pStore,
char *  pCanonPerm,
unsigned *  pCanonPhase 
)

Definition at line 265 of file luckyFast6.c.

266 {
267  (* pCanonPhase) = Kit_TruthSemiCanonicize_Yasha1( &InOut, 6, pCanonPerm, pStore);
268  return Extra_Truth6MinimumRoundMany1(InOut, pStore, pCanonPerm, pCanonPhase);
269 }
unsigned Kit_TruthSemiCanonicize_Yasha1(word *pInOut, int nVars, char *pCanonPerm, int *pStore)
Definition: luckySwap.c:245
word Extra_Truth6MinimumRoundMany1(word t, int *pStore, char *pCanonPerm, unsigned *pCanonPhase)
Definition: luckyFast6.c:213
word luckyCanonicizer_final_fast_6Vars1 ( word  InOut,
int *  pStore,
char *  pCanonPerm,
unsigned *  pCanonPhase 
)

Definition at line 270 of file luckyFast6.c.

271 {
272  (* pCanonPhase) = Kit_TruthSemiCanonicize_Yasha1( &InOut, 6, pCanonPerm, pStore);
273  InOut = Extra_Truth6MinimumRoundMany1(InOut, pStore, pCanonPerm, pCanonPhase);
274  Kit_TruthChangePhase_64bit( &InOut, 6, 5 );
275  Kit_TruthChangePhase_64bit( &InOut, 6, 4 );
276  Kit_TruthChangePhase_64bit( &InOut, 6, 3 );
277  Kit_TruthChangePhase_64bit( &InOut, 6, 2 );
278  Kit_TruthChangePhase_64bit( &InOut, 6, 1 );
279  Kit_TruthChangePhase_64bit( &InOut, 6, 0 );
280  (*pCanonPhase) ^= 0x3F;
281  return Extra_Truth6MinimumRoundMany1(InOut, pStore, pCanonPerm, pCanonPhase);
282 }
unsigned Kit_TruthSemiCanonicize_Yasha1(word *pInOut, int nVars, char *pCanonPerm, int *pStore)
Definition: luckySwap.c:245
void Kit_TruthChangePhase_64bit(word *pInOut, int nVars, int iVar)
Definition: luckySwap.c:100
word Extra_Truth6MinimumRoundMany1(word t, int *pStore, char *pCanonPerm, unsigned *pCanonPhase)
Definition: luckyFast6.c:213
void resetPCanonPermArray ( char *  x,
int  nVars 
)

Definition at line 30 of file luckyFast6.c.

31 {
32  int i;
33  for(i=0;i<nVars;i++)
34  x[i] = 'a'+i;
35 }
ABC_NAMESPACE_IMPL_START void resetPCanonPermArray_6Vars ( char *  x)

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

FileName [luckyFast6.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Semi-canonical form computation package.]

Synopsis [Truth table minimization procedures for 6 vars.]

Author [Jake]

Date [Started - September 2012]

Definition at line 21 of file luckyFast6.c.

22 {
23  x[0]='a';
24  x[1]='b';
25  x[2]='c';
26  x[3]='d';
27  x[4]='e';
28  x[5]='f';
29 }