ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
extraUtilCube.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "misc/vec/vec.h"
#include "misc/vec/vecHsh.h"
Include dependency graph for extraUtilCube.c:

Go to the source code of this file.

Functions

void Abc_EnumerateCubeStates2 ()
 FUNCTION DEFINITIONS ///.
 
void Abc_EnumerateCubeStates ()
 

Function Documentation

◆ Abc_EnumerateCubeStates()

void Abc_EnumerateCubeStates ( )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 192 of file extraUtilCube.c.

193{
194 int pXYZ[3][9][2] = {
195 { {3, 5}, {3,17}, {3,15}, {1, 6}, {1,16}, {1,14}, {2, 4}, {2,18}, {2,13} },
196 { {2,14}, {2,24}, {2,12}, {3,13}, {3,23}, {3,10}, {1,15}, {1,22}, {1,11} },
197 { {1,10}, {1, 7}, {1, 4}, {3,12}, {3, 9}, {3, 6}, {2,11}, {2, 8}, {2, 5} } };
198
199 Vec_Int_t * vData = Vec_IntStart( 6 * (1 << 22) ); // 96 MB
200 word State, * pHash = ABC_CALLOC( word, 1 << 29 ); // 4 GB
201 int i, k, v, Beg, End, Counter = 0;
202 char * pPrev, * pState, pStart[24], pFirst[9][24];
203 abctime clk = Abc_Clock();
204 printf( "Enumerating states of 2x2x2 cube.\n" );
205 // init state
206 for ( v = 0; v < 24; v++ )
207 pStart[v] = v;
208 Abc_StatePush( vData, pStart, Counter );
209 Abc_DataXorBit( pHash, Abc_CubeGenerateSign(pStart) );
210 Counter++;
211 // first nine states
212 for ( i = 0; i < 3; i++ )
213 {
214 memcpy( pFirst[i], pStart, 24 );
215 for ( v = 0; v < 9; v++ )
216 ABC_SWAP( char, pFirst[i][pXYZ[i][v][0]-1], pFirst[i][pXYZ[i][v][1]-1] );
217 Abc_StatePush( vData, pFirst[i], Counter );
218 Abc_DataXorBit( pHash, Abc_CubeGenerateSign(pFirst[i]) );
219 Counter++;
220 //Abc_StatePrint( pFirst[i] );
221
222 memcpy( pFirst[3+i], pFirst[i], 24 );
223 for ( v = 0; v < 9; v++ )
224 ABC_SWAP( char, pFirst[3+i][pXYZ[i][v][0]-1], pFirst[3+i][pXYZ[i][v][1]-1] );
225 Abc_StatePush( vData, pFirst[3+i], Counter );
226 Abc_DataXorBit( pHash, Abc_CubeGenerateSign(pFirst[3+i]) );
227 Counter++;
228 //Abc_StatePrint( pFirst[3+i] );
229
230 memcpy( pFirst[6+i], pFirst[3+i], 24 );
231 for ( v = 0; v < 9; v++ )
232 ABC_SWAP( char, pFirst[6+i][pXYZ[i][v][0]-1], pFirst[6+i][pXYZ[i][v][1]-1] );
233 Abc_StatePush( vData, pFirst[6+i], Counter );
234 Abc_DataXorBit( pHash, Abc_CubeGenerateSign(pFirst[6+i]) );
235 Counter++;
236 //Abc_StatePrint( pFirst[6+i] );
237 }
238 printf( "Iter %2d -> %8d ", 0, 1 );
239 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
240 printf( "Iter %2d -> %8d ", 1, Counter );
241 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
242 Beg = 1; End = 10;
243 for ( i = 2; i <= 100; i++ )
244 {
245 if ( Beg == End )
246 break;
247 for ( k = Beg; k < End; k++ )
248 {
249 pPrev = (char *)Vec_IntEntryP(vData, 6*k);
250 for ( v = 0; v < 9; v++ )
251 {
252 pState = (char *)Vec_IntEntryP(vData, 6*Counter);
253 Abc_StatePerm( pPrev, pFirst[v], pState );
254 State = Abc_CubeGenerateSign( pState );
255 if ( !Abc_DataHasBit(pHash, State) )
256 Abc_DataXorBit(pHash, State), Counter++;
257 if ( Counter == (1<<22) )
258 {
259 printf( "Did not converge. " );
260 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
261 return;
262 }
263 }
264 }
265 Beg = End; End = Counter;
266 printf( "Iter %2d -> %8d ", i, Counter );
267 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
268 }
269 Vec_IntFree( vData );
270 ABC_FREE( pHash );
271}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
char * memcpy()
Here is the call graph for this function:

◆ Abc_EnumerateCubeStates2()

void Abc_EnumerateCubeStates2 ( )

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 53 of file extraUtilCube.c.

54{
55 int pXYZ[3][9][2] = {
56 { {3, 5}, {3,17}, {3,15}, {1, 6}, {1,16}, {1,14}, {2, 4}, {2,18}, {2,13} },
57 { {2,14}, {2,24}, {2,12}, {3,13}, {3,23}, {3,10}, {1,15}, {1,22}, {1,11} },
58 { {1,10}, {1, 7}, {1, 4}, {3,12}, {3, 9}, {3, 6}, {2,11}, {2, 8}, {2, 5} } };
59
60 Vec_Int_t * vData = Vec_IntStart( 6 * (1 << 22) ); // 96 MB
61 Hsh_IntMan_t * vHash = Hsh_IntManStart( vData, 6, 1 << 22 ); // 32 MB
62 int i, k, v, RetValue, Beg, End, Counter = 0;
63 char pStart[24], pFirst[9][24];
64 abctime clk = Abc_Clock();
65 printf( "Enumerating states of 2x2x2 cube.\n" );
66 // init state
67 for ( v = 0; v < 24; v++ )
68 pStart[v] = v;
69 Abc_StatePush( vData, pStart, Counter );
70 RetValue = Hsh_IntManAdd( vHash, Counter );
71 assert( RetValue == Counter );
72 Counter++;
73 // first nine states
74 for ( i = 0; i < 3; i++ )
75 {
76 memcpy( pFirst[i], pStart, 24 );
77 for ( v = 0; v < 9; v++ )
78 ABC_SWAP( char, pFirst[i][pXYZ[i][v][0]-1], pFirst[i][pXYZ[i][v][1]-1] );
79 Abc_StatePush( vData, pFirst[i], Counter );
80 RetValue = Hsh_IntManAdd( vHash, Counter );
81 assert( RetValue == Counter );
82 Counter++;
83 //Abc_StatePrint( pFirst[i] );
84
85 memcpy( pFirst[3+i], pFirst[i], 24 );
86 for ( v = 0; v < 9; v++ )
87 ABC_SWAP( char, pFirst[3+i][pXYZ[i][v][0]-1], pFirst[3+i][pXYZ[i][v][1]-1] );
88 Abc_StatePush( vData, pFirst[3+i], Counter );
89 RetValue = Hsh_IntManAdd( vHash, Counter );
90 assert( RetValue == Counter );
91 Counter++;
92 //Abc_StatePrint( pFirst[3+i] );
93
94 memcpy( pFirst[6+i], pFirst[3+i], 24 );
95 for ( v = 0; v < 9; v++ )
96 ABC_SWAP( char, pFirst[6+i][pXYZ[i][v][0]-1], pFirst[6+i][pXYZ[i][v][1]-1] );
97 Abc_StatePush( vData, pFirst[6+i], Counter );
98 RetValue = Hsh_IntManAdd( vHash, Counter );
99 assert( RetValue == Counter );
100 Counter++;
101 //Abc_StatePrint( pFirst[6+i] );
102 }
103 printf( "Iter %2d -> %8d ", 0, 1 );
104 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
105 printf( "Iter %2d -> %8d ", 1, Counter );
106 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
107 Beg = 1; End = 10;
108 for ( i = 2; i <= 100; i++ )
109 {
110 if ( Beg == End )
111 break;
112 for ( k = Beg; k < End; k++ )
113 for ( v = 0; v < 9; v++ )
114 {
115 Abc_StatePerm( (char *)Vec_IntEntryP(vData, 6*k), pFirst[v], (char *)Vec_IntEntryP(vData, 6*Counter) );
116 RetValue = Hsh_IntManAdd( vHash, Counter );
117 if ( RetValue == Counter )
118 Counter++;
119 if ( Counter == (1<<22) )
120 {
121 printf( "Did not converge. " );
122 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
123 return;
124 }
125 }
126 Beg = End; End = Counter;
127 printf( "Iter %2d -> %8d ", i, Counter );
128 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
129 }
130 Hsh_IntManStop( vHash );
131 Vec_IntFree( vData );
132}
#define assert(ex)
Definition util_old.h:213
struct Hsh_IntMan_t_ Hsh_IntMan_t
Definition vecHsh.h:66
Here is the call graph for this function: