#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "kit.h"
Go to the source code of this file.
|
| typedef unsigned __int64 | word |
| | DECLARATIONS ///.
|
| |
| typedef unsigned short | shot |
| |
◆ inline
CFile****************************************************************
FileName [kitPerm.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Computation kit.]
Synopsis [Procedures for permuting truth tables.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - Oct 26, 2011.]
Revision [
- Id
- kitPerm.c,v 1.00 2011/11/26 00:00:00 alanmi Exp
]
Definition at line 28 of file kitPerm.c.
◆ NFUNCS
◆ shot
| typedef unsigned short shot |
◆ word
| typedef unsigned __int64 word |
DECLARATIONS ///.
Definition at line 36 of file kitPerm.c.
◆ Kit_PermCompute()
| void Kit_PermCompute |
( |
word * | o, |
|
|
word * | i, |
|
|
int | V ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 199 of file kitPerm.c.
200{
202 int v, n = (1 << (V-3));
203 assert( V >= 6 && V <= 16 );
204 for ( v = 0; v < n; v++ )
205 ((byte *)i)[v] = P[((byte *)i)[v]];
206 for ( v = 3; v < V; v++ )
207 {
208 Kit_PermCycleMany( (
shot *)o, (
byte *)i, V, v );
209 t = i; i = o; o = t;
210 }
211 if ( V & 1 )
212 {
213 n = (1 << (V-6));
214 for ( v = 0; v < n; v++ )
215 o[v] = i[v];
216 }
217}
unsigned __int64 word
DECLARATIONS ///.
◆ Kit_PermComputeNaive()
| void Kit_PermComputeNaive |
( |
word * | F, |
|
|
int | nVars ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 230 of file kitPerm.c.
231{
233 int i, V2P[16], P2V[16];
234 for ( i = 0; i < nVars; i++ )
235 V2P[i] = P2V[i] = i;
237}
void If_CluReverseOrder(word *pTruth, int nVars, int *V2P, int *P2V, int iVarStart)
◆ Kit_PermComputeTest()
| void Kit_PermComputeTest |
( |
| ) |
|
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 278 of file kitPerm.c.
279{
282 int k, b;
284
285 srand( 0 );
286
287 clk = Abc_Clock();
288 for ( k = 0; k <
NFUNCS; k++ )
289 for ( b = 0; b < 8; b++ )
290 ((
byte *)(T + k))[b] = (
byte)(rand() & 0xFF);
291 ABC_PRT(
"Assign", Abc_Clock() - clk );
292
293
294
295
296
297 clk = Abc_Clock();
298 for ( k = 0; k <
NFUNCS; k++ )
299 {
300 i = T[k];
301
303 }
304 ABC_PRT(
"Perm1 ", Abc_Clock() - clk );
305
306
307 clk = Abc_Clock();
308 for ( k = 0; k <
NFUNCS; k++ )
309 {
310 i = T[k];
312
313
314
315
316 }
317 ABC_PRT(
"Perm2 ", Abc_Clock() - clk );
318
321}
void Kit_PermCompute(word *o, word *i, int V)
◆ Kit_PermComputeTest_()
| void Kit_PermComputeTest_ |
( |
| ) |
|
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso [] `
Definition at line 334 of file kitPerm.c.
335{
337 t = 0xacaccacaaccaacca;
338
340
341
342}
◆ Kit_PermCreateP()
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 135 of file kitPerm.c.
136{
137 int i, s1, s2, r;
138 for ( i = 0; i < 256; i++ )
139 {
140 if ( i % 16 == 0 )
141 printf( "\n" );
142 s1 = i & 0x0A;
143 s2 = i & 0x50;
144 r = i ^ s1 ^ s2 ^ (s1 << 3) ^ (s2 >> 3);
146 printf( "0x%02x, ", r );
147 }
148}
◆ Kit_PermCreateS()
FUNCTION DEFINITIONS ///.
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 111 of file kitPerm.c.
112{
113 int i, n, r;
114 for ( i = 0; i < 256; i++ )
115 {
116 if ( i % 8 == 0 )
117 printf( "\n" );
118 for ( r = n = 0; n < 8; n++ )
119 r |= ((i & (1 << n)) << n);
120 printf( "0x%04x, ", r );
121 }
122}
◆ M()
Definition at line 240 of file kitPerm.c.
241{
244 int i;
245 for( i = 0; i < n; i++)
246 temp = temp + (((f1>>i)&a) << (2*i) ) + (((f2>>i)&a) << (2*i+1));
247 return temp;
248}
◆ Tf()
Definition at line 250 of file kitPerm.c.
251{
252 if(n==1)
253 return f;
254 else
255 {
256
257 int x;
258 x = (1 << (n-1));
259 return (
M (
Tf( (f << x) >> x, n-1),
Tf( (f >> x), n-1), x) );
260 }
261}
word M(word f1, word f2, int n)