ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaGen.c File Reference
#include "gia.h"
#include "misc/util/utilTruth.h"
#include "misc/extra/extra.h"
Include dependency graph for giaGen.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START Gia_Man_tGia_DeriveAig (Vec_Wrd_t *vSims, Vec_Str_t *vSimsOut)
 DECLARATIONS ///.
 
void Gia_DeriveAigTest ()
 
int Gia_ManSimulateWords (Gia_Man_t *p, int nWords)
 
int Gia_ManSimulateWordsInit (Gia_Man_t *p, Vec_Wrd_t *vSimsIn)
 
Vec_Wrd_tGia_ManSimulateWordsOut (Gia_Man_t *p, Vec_Wrd_t *vSimsIn)
 
void Gia_ManDumpFiles (Gia_Man_t *p, int nCexesT, int nCexesV, int Seed, char *pFileName)
 
void Gia_ManDumpPlaFiles (Gia_Man_t *p, int nCexesT, int nCexesV, int Seed, char *pFileName)
 
void Gia_ManSimLogStats (Gia_Man_t *p, char *pDumpFile, int Total, int Correct, int Guess)
 
int Gia_ManSimParamRead (char *pFileName, int *pnIns, int *pnWords)
 
void Gia_ManSimFileRead (char *pFileName, int nIns, int nWords, Vec_Wrd_t *vSimsIn, Vec_Int_t *vValues)
 
void Gia_ManCompareValues (Gia_Man_t *p, Vec_Wrd_t *vSimsIn, Vec_Int_t *vValues, char *pDumpFile)
 
void Gia_ManReadSimFile (char *pFileName, int *pnIns, int *pnOuts, int *pnPats, Vec_Wrd_t **pvSimsIn, Vec_Wrd_t **pvSimsOut)
 
int Gia_ManReadBinaryFile (char *pFileName, Vec_Wrd_t **pvSimsIn, Vec_Str_t **pvSimsOut)
 
void Gia_ManSimLogStats2 (Gia_Man_t *p, char *pDumpFile, int Total, int nPositives, float ErrorTotal, float GuessTotal)
 
int Gia_ManGetExampleValue (word **ppSims, int nSims, int iExample)
 
void Gia_ManCompareValues2 (int nInputs, Gia_Man_t *p, Vec_Wrd_t *vSimsIn, Vec_Str_t *vValues, char *pDumpFile)
 
void Gia_ManTestWordFileUnused (Gia_Man_t *p, char *pFileName, char *pDumpFile)
 
void Gia_ManTestOneFile (Gia_Man_t *p, char *pFileName, char *pDumpFile)
 
int Gia_ManReadCifar10File (char *pFileName, Vec_Wrd_t **pvSimsIn, Vec_Str_t **pvSimsOut, int *pnExamples)
 
int Gia_ManSimulateBatch (Gia_Man_t *p, Vec_Wrd_t *vSimsIn, Vec_Str_t *vSimsOut, Vec_Str_t *vSimsOut2, int b, int Limit)
 
Vec_Str_tGia_ManSimulateAll (Gia_Man_t *p, Vec_Wrd_t *vSimsIn, Vec_Str_t *vSimsOut, int nExamples, int fVerbose)
 
void Gia_ManCompareCifar10Values (Gia_Man_t *p, Vec_Str_t *vRes, Vec_Str_t *vSimsOut, char *pDumpFile, int nExamples)
 
void Gia_ManTestWordFile (Gia_Man_t *p, char *pFileName, char *pDumpFile, int fVerbose)
 
int Gia_ManSumCount (char *p, Vec_Int_t *vDec, int b)
 
Vec_Str_tGia_ManSumEnum_rec (int Num)
 
void Gia_ManSumEnum (int n, Vec_Int_t *vDec)
 
Vec_Int_tGia_ManSumGenDec (int n)
 
void Gia_ManSumEnumTest ()
 
void Gia_ManGenNeuronDumpVerilog (Vec_Wrd_t *vData, int nIBits, int nOBits)
 
void Gia_ManGenNeuronAdder (Gia_Man_t *p, int nLits, int *pLitsA, int *pLitsB, int Carry, Vec_Int_t *vRes)
 
void Gia_ManGenCompact (Gia_Man_t *p, Vec_Int_t *vIn0, Vec_Int_t *vIn1, Vec_Int_t *vIn2, Vec_Int_t *vOut0, Vec_Int_t *vOut1)
 
Vec_Wec_tGia_ManGenNeuronCreateArgs (Vec_Wrd_t *vData, int nIBits, int nOBits)
 
Vec_Wec_tGia_ManGenNeuronTransformArgs (Gia_Man_t *pNew, Vec_Wec_t *vArgs, int nLutSize, int nOBits)
 
Vec_Wec_tGia_ManGenNeuronCompactArgs (Gia_Man_t *pNew, Vec_Wec_t *vArgs, int nLutSize, int nOBits)
 
Vec_Int_tGia_ManGenNeuronFinal (Gia_Man_t *pNew, Vec_Wec_t *vArgs, int nOBits)
 
int Gia_ManGenNeuronBitWidth (Vec_Wrd_t *vData, int nIBits)
 
Gia_Man_tGia_ManGenNeuron (char *pFileName, int nIBits, int nLutSize, int fDump, int fVerbose)
 
Gia_Man_tGia_ManDupGenComp (int nBits, int fInterleave)
 
Vec_Int_tGia_GenDecoder (Gia_Man_t *p, int *pLits, int nLits)
 
Gia_Man_tGia_ManGenMux (int nIns, char *pNums)
 
Gia_Man_tGia_ManGenSorter (int LogN)
 
void Gia_ManGenPrep (int nVars, int **p)
 
void Gia_ManGenSK (int nVars, int **p)
 
void Gia_ManGenBK (int nVars, int **p)
 
void Gia_ManGenHC (int nVars, int **p)
 
void Gia_ManGenRca (int nVars, int **p)
 
void Gia_ManGenPrint (int nVars, int **p)
 
void Gia_ManGenPrefix (Gia_Man_t *pNew, int *p, int *g, int p2, int g2)
 
Gia_Man_tGia_ManGenAdder (int nVars, int fSK, int fBK, int fHC, int fCarries, int fVerbose)
 

Function Documentation

◆ Gia_DeriveAig()

ABC_NAMESPACE_IMPL_START Gia_Man_t * Gia_DeriveAig ( Vec_Wrd_t * vSims,
Vec_Str_t * vSimsOut )

DECLARATIONS ///.

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

FileName [giaGen.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
giaGen.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file giaGen.c.

49{
50 int nInputs = 32*32*24;
51 int nWords = nInputs/64;
52 int nExamps = 64;
53 int i, e, iLitOut[10] = {0};
54 Gia_Man_t * pNew;
55 assert( Vec_WrdSize(vSims) % nInputs == 0 );
56 pNew = Gia_ManStart( nInputs * nExamps + 10000 );
57 for ( i = 0; i < nInputs; i++ )
58 Gia_ManAppendCi( pNew );
59 Gia_ManHashStart( pNew );
60 for ( e = 0; e < nExamps; e++ )
61 {
62 int Class = Vec_StrEntry( vSimsOut, e );
63 int This = 1;
64 word * pSim = Vec_WrdEntryP( vSims, e*nWords );
65 for ( i = 0; i < nInputs; i++ )
66 This = Gia_ManHashAnd( pNew, This, Abc_Var2Lit(i+1, !Abc_TtGetBit(pSim, i)) );
67 assert( Class >= 0 && Class <= 9 );
68 iLitOut[Class] = Gia_ManHashOr( pNew, iLitOut[Class], This );
69 //printf( "Finished example %d\n", e );
70 }
71 for ( i = 0; i < 10; i++ )
72 Gia_ManAppendCo( pNew, iLitOut[i] );
73 //pNew = Gia_ManCleanup( pTemp = pNew );
74 //Gia_ManStop( pTemp );
75 return pNew;
76}
int nWords
Definition abcNpn.c:127
void Gia_ManHashStart(Gia_Man_t *p)
Definition giaHash.c:125
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:621
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_DeriveAigTest()

void Gia_DeriveAigTest ( )

Definition at line 77 of file giaGen.c.

78{
79 extern int Gia_ManReadCifar10File( char * pFileName, Vec_Wrd_t ** pvSimsIn, Vec_Str_t ** pvSimsOut, int * pnExamples );
80 char pFileName[100] = "test";
81 Vec_Wrd_t * vSimsIn;
82 Vec_Str_t * vSimsOut;
83 int nExamples = 0;
84 int nInputs = Gia_ManReadCifar10File( pFileName, &vSimsIn, &vSimsOut, &nExamples );
85 Gia_Man_t * pThis = Gia_DeriveAig( vSimsIn, vSimsOut );
86 Gia_AigerWrite( pThis, "examples64.aig", 0, 0, 0 );
87 printf( "Dumped file \"%s\".\n", "examples64.aig" );
88 Gia_ManStop( pThis );
89 Vec_WrdFree( vSimsIn );
90 Vec_StrFree( vSimsOut );
91 nInputs = 0;
92}
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
int Gia_ManReadCifar10File(char *pFileName, Vec_Wrd_t **pvSimsIn, Vec_Str_t **pvSimsOut, int *pnExamples)
Definition giaGen.c:787
ABC_NAMESPACE_IMPL_START Gia_Man_t * Gia_DeriveAig(Vec_Wrd_t *vSims, Vec_Str_t *vSimsOut)
DECLARATIONS ///.
Definition giaGen.c:48
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
void Gia_AigerWrite(Gia_Man_t *p, char *pFileName, int fWriteSymbols, int fCompact, int fWriteNewLine)
Definition giaAiger.c:1595
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition vecWrd.h:42
Here is the call graph for this function:

◆ Gia_GenDecoder()

Vec_Int_t * Gia_GenDecoder ( Gia_Man_t * p,
int * pLits,
int nLits )

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

Synopsis [Generates optimized AIG for the decoder and the multiplexer.]

Description []

SideEffects []

SeeAlso []

Definition at line 1249 of file giaGen.c.

1250{
1251 if ( nLits == 1 )
1252 {
1253 Vec_Int_t * vRes = Vec_IntAlloc( 2 );
1254 Vec_IntPush( vRes, Abc_LitNot(pLits[0]) );
1255 Vec_IntPush( vRes, pLits[0] );
1256 return vRes;
1257 }
1258 assert( nLits > 1 );
1259 int nPart1 = nLits / 2;
1260 int nPart2 = nLits - nPart1;
1261 Vec_Int_t * vRes1 = Gia_GenDecoder( p, pLits, nPart1 );
1262 Vec_Int_t * vRes2 = Gia_GenDecoder( p, pLits+nPart1, nPart2 );
1263 Vec_Int_t * vRes = Vec_IntAlloc( Vec_IntSize(vRes1) * Vec_IntSize(vRes2) );
1264 int i, k, Lit1, Lit2;
1265 Vec_IntForEachEntry( vRes2, Lit2, k )
1266 Vec_IntForEachEntry( vRes1, Lit1, i )
1267 Vec_IntPush( vRes, Gia_ManHashAnd(p, Lit1, Lit2) );
1268 Vec_IntFree( vRes1 );
1269 Vec_IntFree( vRes2 );
1270 return vRes;
1271}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
Vec_Int_t * Gia_GenDecoder(Gia_Man_t *p, int *pLits, int nLits)
Definition giaGen.c:1249
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCompareCifar10Values()

void Gia_ManCompareCifar10Values ( Gia_Man_t * p,
Vec_Str_t * vRes,
Vec_Str_t * vSimsOut,
char * pDumpFile,
int nExamples )

Definition at line 883 of file giaGen.c.

884{
885 int i, Guess = (nExamples+9)/10, Count = 0;
886 for ( i = 0; i < nExamples; i++ )
887 {
888 char ValueReal = Vec_StrEntry(vRes, i);
889 char ValueGold = Vec_StrEntry(vSimsOut, i);
890 if ( ValueReal == ValueGold )
891 Count++;
892 }
893 printf( "Summary: Total = %6d. Errors = %6d. Correct = %6d. (%6.2f %%) Naive guess = %6d. (%6.2f %%)\n",
894 nExamples, nExamples - Count,
895 Count, 100.0*Count/nExamples,
896 Guess, 100.0*Guess/nExamples);
897 if ( pDumpFile == NULL )
898 return;
899 Gia_ManSimLogStats( p, pDumpFile, nExamples, Count, Guess );
900 printf( "Finished dumping statistics into file \"%s\".\n", pDumpFile );
901}
void Gia_ManSimLogStats(Gia_Man_t *p, char *pDumpFile, int Total, int Correct, int Guess)
Definition giaGen.c:404
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCompareValues()

void Gia_ManCompareValues ( Gia_Man_t * p,
Vec_Wrd_t * vSimsIn,
Vec_Int_t * vValues,
char * pDumpFile )

Definition at line 504 of file giaGen.c.

505{
506 int i, Value, Guess, Count = 0, nWords = Vec_WrdSize(vSimsIn) / Gia_ManCiNum(p);
507 word * pSims;
508 assert( Vec_IntSize(vValues) == nWords * 64 );
509 Gia_ManSimulateWordsInit( p, vSimsIn );
510 assert( p->nSimWords == nWords );
511 pSims = Gia_ManObjSim( p, Gia_ObjId(p, Gia_ManCo(p, 0)) );
512 Vec_IntForEachEntry( vValues, Value, i )
513 if ( Abc_TtGetBit(pSims, i) == Value )
514 Count++;
515 Guess = (Vec_IntSum(vValues) > nWords * 32) ? Vec_IntSum(vValues) : nWords * 64 - Vec_IntSum(vValues);
516 printf( "Total = %6d. Errors = %6d. Correct = %6d. (%6.2f %%) Naive guess = %6d. (%6.2f %%)\n",
517 Vec_IntSize(vValues), Vec_IntSize(vValues) - Count,
518 Count, 100.0*Count/Vec_IntSize(vValues),
519 Guess, 100.0*Guess/Vec_IntSize(vValues));
520 if ( pDumpFile == NULL )
521 return;
522 Gia_ManSimLogStats( p, pDumpFile, Vec_IntSize(vValues), Count, Guess );
523 printf( "Finished dumping statistics into file \"%s\".\n", pDumpFile );
524}
int Gia_ManSimulateWordsInit(Gia_Man_t *p, Vec_Wrd_t *vSimsIn)
Definition giaGen.c:172
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCompareValues2()

void Gia_ManCompareValues2 ( int nInputs,
Gia_Man_t * p,
Vec_Wrd_t * vSimsIn,
Vec_Str_t * vValues,
char * pDumpFile )

Definition at line 680 of file giaGen.c.

681{
682 float Error1, ErrorTotal = 0, Guess1, GuessTotal = 0;
683 int i, o, nPositives = 0, nWords = Vec_WrdSize(vSimsIn) / Gia_ManCiNum(p);
684 word ** ppSims = ABC_CALLOC( word *, Gia_ManCoNum(p) );
685 Gia_Obj_t * pObj;
686 assert( nWords == (1<<10) );
687 assert( Vec_WrdSize(vSimsIn) % Gia_ManCiNum(p) == 0 );
688 assert( Vec_StrSize(vValues) == (1 << 16) );
689 assert( nWords*64 == (1 << 16) );
690 // simulate examples given in vSimsIn
691 Gia_ManSimulateWordsInit( p, vSimsIn );
692 // collect simulation info for the outputs
693 assert( p->nSimWords == nWords );
694 Gia_ManForEachCo( p, pObj, o )
695 ppSims[o] = Gia_ManObjSim( p, Gia_ObjId(p, pObj) );
696 // compare the output for each example
697 for ( i = 0; i < nWords*64; i++ )
698 {
699 int ValueGold = (int)Vec_StrEntry( vValues, i );
700 int ValueImpl = Gia_ManGetExampleValue( ppSims, Gia_ManCoNum(p), i );
701 // compute error for this example
702 Error1 = (float)(ValueGold - ValueImpl)/256;
703 ErrorTotal += Error1 * Error1;
704 // compute error of zero-output
705 Guess1 = ValueGold > 0 ? Abc_AbsInt(ValueImpl) : 0;
706 GuessTotal += Guess1 * Guess1;
707 // count positive values (disregard negative values due to Leaky ReLU)
708 nPositives += (int)(ValueGold > 0);
709 }
710 ABC_FREE( ppSims );
711 printf( "Total = %6d. Positive = %6d. (%6.2f %%) Errors = %e. Guess = %e. (%6.2f %%)\n",
712 Vec_StrSize(vValues), nPositives, 100.0*nPositives/Vec_StrSize(vValues),
713 ErrorTotal, GuessTotal, 100.0*ErrorTotal/GuessTotal );
714 if ( pDumpFile == NULL )
715 return;
716 Gia_ManSimLogStats2( p, pDumpFile, Vec_StrSize(vValues), nPositives, ErrorTotal, GuessTotal );
717 printf( "Finished dumping statistics into file \"%s\".\n", pDumpFile );
718}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
void Gia_ManSimLogStats2(Gia_Man_t *p, char *pDumpFile, int Total, int nPositives, float ErrorTotal, float GuessTotal)
Definition giaGen.c:654
int Gia_ManGetExampleValue(word **ppSims, int nSims, int iExample)
Definition giaGen.c:670
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDumpFiles()

void Gia_ManDumpFiles ( Gia_Man_t * p,
int nCexesT,
int nCexesV,
int Seed,
char * pFileName )

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

Synopsis [Dump data files.]

Description []

SideEffects []

SeeAlso []

Definition at line 241 of file giaGen.c.

242{
243 int n, nSize[2] = {nCexesT*64, nCexesV*64};
244
245 char pFileNameOutTX[100];
246 char pFileNameOutTY[100];
247 char pFileNameOutVX[100];
248 char pFileNameOutVY[100];
249 char pFileNameOut[100];
250
251 //sprintf( pFileNameOutTX, "train_%s_%d_%d.data", pFileName ? pFileName : Gia_ManName(p), nSize[0], Gia_ManCiNum(p) );
252 //sprintf( pFileNameOutTY, "train_%s_%d_%d.data", pFileName ? pFileName : Gia_ManName(p), nSize[0], Gia_ManCoNum(p) );
253 //sprintf( pFileNameOutVX, "test_%s_%d_%d.data", pFileName ? pFileName : Gia_ManName(p), nSize[1], Gia_ManCiNum(p) );
254 //sprintf( pFileNameOutVY, "test_%s_%d_%d.data", pFileName ? pFileName : Gia_ManName(p), nSize[1], Gia_ManCoNum(p) );
255
256 sprintf( pFileNameOutTX, "%s_x.train.data", pFileName ? pFileName : Gia_ManName(p) );
257 sprintf( pFileNameOutTY, "%s_y.train.data", pFileName ? pFileName : Gia_ManName(p) );
258 sprintf( pFileNameOutVX, "%s_x.test.data", pFileName ? pFileName : Gia_ManName(p) );
259 sprintf( pFileNameOutVY, "%s_y.test.data", pFileName ? pFileName : Gia_ManName(p) );
260
261 Gia_ManRandomW( 1 );
262 for ( n = 0; n < Seed; n++ )
263 Gia_ManRandomW( 0 );
264 for ( n = 0; n < 2; n++ )
265 {
266 int Res = Gia_ManSimulateWords( p, nSize[n] );
267
268 Vec_Bit_t * vBitX = Vec_BitAlloc( nSize[n] * Gia_ManCiNum(p) );
269 Vec_Bit_t * vBitY = Vec_BitAlloc( nSize[n] * Gia_ManCoNum(p) );
270
271 FILE * pFileOutX = fopen( n ? pFileNameOutVX : pFileNameOutTX, "wb" );
272 FILE * pFileOutY = fopen( n ? pFileNameOutVY : pFileNameOutTY, "wb" );
273
274 int i, k, Id, Num, Value, nBytes;
275 for ( k = 0; k < nSize[n]; k++ )
276 {
277 Gia_ManForEachCiId( p, Id, i )
278 {
279 Vec_BitPush( vBitX, Abc_TtGetBit(Gia_ManObjSim(p, Id), k) );
280 //printf( "%d", Abc_TtGetBit(Gia_ManObjSim(p, Id), k) );
281 }
282 //printf( " " );
283 Gia_ManForEachCoId( p, Id, i )
284 {
285 Vec_BitPush( vBitY, Abc_TtGetBit(Gia_ManObjSim(p, Id), k) );
286 //printf( "%d", Abc_TtGetBit(Gia_ManObjSim(p, Id), k) );
287 }
288 //printf( "\n" );
289 }
290 assert( Vec_BitSize(vBitX) <= Vec_BitCap(vBitX) );
291 assert( Vec_BitSize(vBitY) <= Vec_BitCap(vBitY) );
292
293 Num = 2; Value = fwrite( &Num, 1, 4, pFileOutX ); assert( Value == 4 );
294 Num = nSize[n]; Value = fwrite( &Num, 1, 4, pFileOutX ); assert( Value == 4 );
295 Num = Gia_ManCiNum(p); Value = fwrite( &Num, 1, 4, pFileOutX ); assert( Value == 4 );
296
297 nBytes = nSize[n] * Gia_ManCiNum(p) / 8;
298 assert( nSize[n] * Gia_ManCiNum(p) % 8 == 0 );
299 Value = fwrite( Vec_BitArray(vBitX), 1, nBytes, pFileOutX );
300 assert( Value == nBytes );
301
302 Num = 2; Value = fwrite( &Num, 1, 4, pFileOutY ); assert( Value == 4 );
303 Num = nSize[n]; Value = fwrite( &Num, 1, 4, pFileOutY ); assert( Value == 4 );
304 Num = Gia_ManCoNum(p); Value = fwrite( &Num, 1, 4, pFileOutY ); assert( Value == 4 );
305
306 nBytes = nSize[n] * Gia_ManCoNum(p) / 8;
307 assert( nSize[n] * Gia_ManCoNum(p) % 8 == 0 );
308 Value = fwrite( Vec_BitArray(vBitY), 1, nBytes, pFileOutY );
309 assert( Value == nBytes );
310
311 fclose( pFileOutX );
312 fclose( pFileOutY );
313
314 Vec_BitFree( vBitX );
315 Vec_BitFree( vBitY );
316
317 Res = 0;
318 }
319 printf( "Finished dumping files \"%s\" and \"%s\".\n", pFileNameOutTX, pFileNameOutTY );
320 printf( "Finished dumping files \"%s\" and \"%s\".\n", pFileNameOutVX, pFileNameOutVY );
321
322 sprintf( pFileNameOut, "%s.flist", pFileName ? pFileName : Gia_ManName(p) );
323 {
324 FILE * pFile = fopen( pFileNameOut, "wb" );
325 fprintf( pFile, "%s\n", pFileNameOutTX );
326 fprintf( pFile, "%s\n", pFileNameOutTY );
327 fprintf( pFile, "%s\n", pFileNameOutVX );
328 fprintf( pFile, "%s\n", pFileNameOutVY );
329 fclose( pFile );
330 printf( "Finished dumping file list \"%s\".\n", pFileNameOut );
331 }
332}
int Gia_ManSimulateWords(Gia_Man_t *p, int nWords)
Definition giaGen.c:151
#define Gia_ManForEachCoId(p, Id, i)
Definition gia.h:1240
word Gia_ManRandomW(int fReset)
Definition giaUtil.c:67
#define Gia_ManForEachCiId(p, Id, i)
Definition gia.h:1230
char * sprintf()
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
Definition vecBit.h:42
Here is the call graph for this function:

◆ Gia_ManDumpPlaFiles()

void Gia_ManDumpPlaFiles ( Gia_Man_t * p,
int nCexesT,
int nCexesV,
int Seed,
char * pFileName )

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

Synopsis [Dump data files.]

Description []

SideEffects []

SeeAlso []

Definition at line 345 of file giaGen.c.

346{
347 int n, nSize[3] = {nCexesT, nCexesV, nCexesV};
348
349 char pFileNameOut[3][100];
350
351 sprintf( pFileNameOut[0], "%s.train.pla", pFileName ? pFileName : Gia_ManName(p) );
352 sprintf( pFileNameOut[1], "%s.valid.pla", pFileName ? pFileName : Gia_ManName(p) );
353 sprintf( pFileNameOut[2], "%s.test.pla", pFileName ? pFileName : Gia_ManName(p) );
354
355 Gia_ManRandomW( 1 );
356 for ( n = 0; n < Seed; n++ )
357 Gia_ManRandomW( 0 );
358 for ( n = 0; n < 3; n++ )
359 {
360 int Res = Gia_ManSimulateWords( p, nSize[n] );
361 int i, k, Id;
362
363 FILE * pFileOut = fopen( pFileNameOut[n], "wb" );
364
365 fprintf( pFileOut, ".i %d\n", Gia_ManCiNum(p) );
366 fprintf( pFileOut, ".o %d\n", Gia_ManCoNum(p) );
367 fprintf( pFileOut, ".p %d\n", nSize[n]*64 );
368 fprintf( pFileOut, ".type fr\n" );
369 for ( k = 0; k < nSize[n]*64; k++ )
370 {
371 Gia_ManForEachCiId( p, Id, i )
372 {
373 //Vec_BitPush( vBitX, Abc_TtGetBit(Gia_ManObjSim(p, Id), k) );
374 fprintf( pFileOut, "%d", Abc_TtGetBit(Gia_ManObjSim(p, Id), k) );
375 }
376 fprintf( pFileOut, " " );
377 Gia_ManForEachCoId( p, Id, i )
378 {
379 //Vec_BitPush( vBitY, Abc_TtGetBit(Gia_ManObjSim(p, Id), k) );
380 fprintf( pFileOut, "%d", Abc_TtGetBit(Gia_ManObjSim(p, Id), k) );
381 }
382 fprintf( pFileOut, "\n" );
383 }
384 fprintf( pFileOut, ".e\n" );
385
386 fclose( pFileOut );
387
388 Res = 0;
389 }
390 printf( "Finished dumping files: \"%s.{train, valid, test}.pla\".\n", pFileName ? pFileName : Gia_ManName(p) );
391}
Here is the call graph for this function:

◆ Gia_ManDupGenComp()

Gia_Man_t * Gia_ManDupGenComp ( int nBits,
int fInterleave )

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

Synopsis [Generates minimum-node AIG for n-bit comparator (a > b).]

Description []

SideEffects []

SeeAlso []

Definition at line 1195 of file giaGen.c.

1196{
1197 Gia_Man_t * pNew, * pTemp; int i, iLit = 1;
1198 Vec_Int_t * vBitsA = Vec_IntAlloc( nBits + 1 );
1199 Vec_Int_t * vBitsB = Vec_IntAlloc( nBits + 1 );
1200 pNew = Gia_ManStart( 6*nBits+10 );
1201 pNew->pName = Abc_UtilStrsav( "comp" );
1202 Gia_ManHashAlloc( pNew );
1203 if ( fInterleave ) {
1204 for ( i = 0; i < nBits; i++ )
1205 Vec_IntPush( vBitsA, Gia_ManAppendCi(pNew) ),
1206 Vec_IntPush( vBitsB, Gia_ManAppendCi(pNew) );
1207 }
1208 else {
1209 for ( i = 0; i < nBits; i++ )
1210 Vec_IntPush( vBitsA, Gia_ManAppendCi(pNew) );
1211 for ( i = 0; i < nBits; i++ )
1212 Vec_IntPush( vBitsB, Gia_ManAppendCi(pNew) );
1213 }
1214 Vec_IntPush( vBitsA, 0 );
1215 Vec_IntPush( vBitsB, 0 );
1216 for ( i = 0; i < nBits; i++ ) {
1217 int iLitA0 = Vec_IntEntry(vBitsA, i);
1218 int iLitA1 = Vec_IntEntry(vBitsA, i+1);
1219 int iLitB0 = Vec_IntEntry(vBitsB, i);
1220 int iLitB1 = Vec_IntEntry(vBitsB, i+1);
1221 int iOrLit0;
1222 if ( i == 0 )
1223 iOrLit0 = Gia_ManHashOr(pNew, Abc_LitNotCond(iLitA0, !(i&1)), Abc_LitNotCond(iLitB0, i&1));
1224 else
1225 iOrLit0 = Gia_ManHashAnd(pNew, Abc_LitNotCond(iLitA0, !(i&1)), Abc_LitNotCond(iLitB0, i&1));
1226 int iOrLit1 = Gia_ManHashAnd(pNew, Abc_LitNotCond(iLitA1, !(i&1)), Abc_LitNotCond(iLitB1, i&1));
1227 int iOrLit = Gia_ManHashOr(pNew, iOrLit0, iOrLit1 );
1228 iLit = Gia_ManHashOr(pNew, Abc_LitNot(iLit), iOrLit );
1229 }
1230 Gia_ManAppendCo( pNew, Abc_LitNotCond(iLit, nBits&1) );
1231 pNew = Gia_ManCleanup( pTemp = pNew );
1232 Gia_ManStop( pTemp );
1233 Vec_IntFree( vBitsA );
1234 Vec_IntFree( vBitsB );
1235 return pNew;
1236}
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
char * pName
Definition gia.h:99
Here is the call graph for this function:

◆ Gia_ManGenAdder()

Gia_Man_t * Gia_ManGenAdder ( int nVars,
int fSK,
int fBK,
int fHC,
int fCarries,
int fVerbose )

Definition at line 1442 of file giaGen.c.

1443{
1444 extern void Wlc_BlastFullAdder( Gia_Man_t * pNew, int a, int b, int c, int * pc, int * ps );
1445 int i, k, nBits = Abc_Base2Log(nVars), nVarsAlloc = (1 << nBits) + 2;
1446 int ** pStore = (int **)Extra_ArrayAlloc( nVarsAlloc, nVarsAlloc, 4 );
1447 printf( "Generating %d-bit ", nVars );
1448 Gia_ManGenPrep( nVars+2, pStore );
1449 if ( fSK )
1450 Gia_ManGenSK( nVars, pStore ), printf("Sklansky ");
1451 else if ( fBK )
1452 Gia_ManGenBK( nVars, pStore ), printf("Brent-Kung ");
1453 else if ( fHC )
1454 Gia_ManGenHC( nVars, pStore ), printf("Huan-Carlsson ");
1455 else
1456 Gia_ManGenRca( nVars, pStore ), printf("ripple-carry ");
1457 printf( "adder with%s carry-in and carry-out\n", fCarries ? "":"out" );
1458 if ( fVerbose ) Gia_ManGenPrint( nVars, pStore );
1459 Gia_Man_t * p = Gia_ManStart( 1000 ), * pTemp;
1460 p->pName = Abc_UtilStrsav( "adder" );
1461 int * pLitsI = ABC_CALLOC( int, 2*nVars+10 );
1462 for ( k = 0; k < nVars; k++ )
1463 pLitsI[2*k] = Gia_ManAppendCi(p);
1464 for ( k = 0; k < nVars; k++ )
1465 pLitsI[2*k+1] = Gia_ManAppendCi(p);
1466 int Carry = fCarries ? Gia_ManAppendCi(p) : 0;
1468 for ( k = 0; k < nVars; k++ )
1469 Wlc_BlastFullAdder( p, pLitsI[2*k], pLitsI[2*k+1], k ? 0 : Carry, &pLitsI[2*k+1], &pLitsI[2*k] );
1470 int * pLits = ABC_CALLOC( int, 2*nVars+10 );
1471 memcpy( pLits, pLitsI, sizeof(int)*2*nVars );
1472 for ( i = 1; i < nVars; i++ )
1473 for ( k = 1; k < nVars; k++ )
1474 if ( pStore[i][k] >= 0 )
1475 Gia_ManGenPrefix( p, &pLits[2*k], &pLits[2*k+1], pLits[2*pStore[i][k]], pLits[2*pStore[i][k]+1] );
1476 for ( k = 0; k < nVars; k++ )
1477 Gia_ManAppendCo( p, k ? Gia_ManHashXor(p, pLitsI[2*k], pLits[2*(k-1)+1]) : pLitsI[2*k] );
1478 if ( fCarries )
1479 Gia_ManAppendCo( p, pLits[2*(k-1)+1] );
1480 ABC_FREE( pStore );
1481 ABC_FREE( pLitsI );
1482 ABC_FREE( pLits );
1483 p = Gia_ManCleanup( pTemp = p );
1484 Gia_ManStop( pTemp );
1485 return p;
1486}
void ** Extra_ArrayAlloc(int nCols, int nRows, int Size)
void Gia_ManGenHC(int nVars, int **p)
Definition giaGen.c:1401
void Gia_ManGenPrefix(Gia_Man_t *pNew, int *p, int *g, int p2, int g2)
Definition giaGen.c:1437
void Gia_ManGenSK(int nVars, int **p)
Definition giaGen.c:1381
void Gia_ManGenBK(int nVars, int **p)
Definition giaGen.c:1389
void Gia_ManGenPrint(int nVars, int **p)
Definition giaGen.c:1419
void Gia_ManGenRca(int nVars, int **p)
Definition giaGen.c:1413
void Gia_ManGenPrep(int nVars, int **p)
Definition giaGen.c:1374
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:668
char * memcpy()
void Wlc_BlastFullAdder(Gia_Man_t *pNew, int a, int b, int c, int *pc, int *ps)
Definition wlcBlast.c:401
Here is the call graph for this function:

◆ Gia_ManGenBK()

void Gia_ManGenBK ( int nVars,
int ** p )

Definition at line 1389 of file giaGen.c.

1390{
1391 int i, k, nBits = Abc_Base2Log(nVars);
1392 nVars = 1 << nBits;
1393 for ( i = 1; i < nBits; i++ )
1394 for ( k = (1 << i) - 1; k < nVars; k += (1 << i) )
1395 p[i][k] = k - (1 << (i-1));
1396 p[nBits][nVars-1] = (1<<(nBits-1))-1;
1397 for ( i = 1; i < nBits; i++ )
1398 for ( k = (1 << i) - 1; k < nVars-(1 << i); k += (1 << i) )
1399 p[2*nBits-1-i][nVars-1-k+((1<<(i-1))-1)] = nVars-1-k+((1<<(i-1))-1) - (1 << (i-1));
1400}
Here is the caller graph for this function:

◆ Gia_ManGenCompact()

void Gia_ManGenCompact ( Gia_Man_t * p,
Vec_Int_t * vIn0,
Vec_Int_t * vIn1,
Vec_Int_t * vIn2,
Vec_Int_t * vOut0,
Vec_Int_t * vOut1 )

Definition at line 1055 of file giaGen.c.

1056{
1057 extern void Wlc_BlastFullAdder( Gia_Man_t * pNew, int a, int b, int c, int * pc, int * ps );
1058 assert( Vec_IntSize(vIn0) == Vec_IntSize(vIn1) );
1059 assert( Vec_IntSize(vIn0) == Vec_IntSize(vIn2) );
1060 Vec_IntPush( vOut1, 0 );
1061 int i, Lit0, Lit1, Lit2, Out0, Out1;
1062 Vec_IntForEachEntryThree( vIn0, vIn1, vIn2, Lit0, Lit1, Lit2, i ) {
1063 Wlc_BlastFullAdder( p, Lit0, Lit1, Lit2, &Out1, &Out0 );
1064 Vec_IntPush( vOut0, Out0 );
1065 Vec_IntPush( vOut1, Out1 );
1066 }
1067 Vec_IntPop( vOut1 );
1068 assert( Vec_IntSize(vIn0) == Vec_IntSize(vOut0) );
1069 assert( Vec_IntSize(vIn0) == Vec_IntSize(vOut1) );
1070}
#define Vec_IntForEachEntryThree(vVec1, vVec2, vVec3, Entry1, Entry2, Entry3, i)
Definition vecInt.h:68
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManGenHC()

void Gia_ManGenHC ( int nVars,
int ** p )

Definition at line 1401 of file giaGen.c.

1402{
1403 int i, k, nBits = Abc_Base2Log(nVars);
1404 nVars = 1 << nBits;
1405 for ( k = 1; k < nVars; k += 2 )
1406 p[1][k] = k - 1;
1407 for ( i = 2; i <= nBits; i++ )
1408 for ( k = 1 + (1 << (i-1)); k < nVars; k += 2 )
1409 p[i][k] = k - (1 << (i-1));
1410 for ( k = 2; k < nVars; k += 2 )
1411 p[nBits+1][k] = k - 1;
1412}
Here is the caller graph for this function:

◆ Gia_ManGenMux()

Gia_Man_t * Gia_ManGenMux ( int nIns,
char * pNums )

Definition at line 1272 of file giaGen.c.

1273{
1274 Vec_Int_t * vIns = Vec_IntAlloc( nIns );
1275 Vec_Int_t * vData = Vec_IntAlloc( 1 << nIns );
1276 Gia_Man_t * p = Gia_ManStart( 4*(1 << nIns) + nIns ), * pTemp;
1277 int i, iStart = 0, nSize = 1 << nIns;
1278 p->pName = Abc_UtilStrsav( "mux" );
1279 for ( i = 0; i < nIns; i++ )
1280 Vec_IntPush( vIns, Gia_ManAppendCi(p) );
1281 for ( i = 0; i < nSize; i++ )
1282 Vec_IntPush( vData, Gia_ManAppendCi(p) );
1284 for ( i = (int)strlen(pNums)-1; i >= 0; i-- )
1285 {
1286 int k, b, nBits = (int)(pNums[i] - '0');
1287 Vec_Int_t * vDec = Gia_GenDecoder( p, Vec_IntEntryP(vIns, iStart), nBits );
1288 for ( k = 0; k < nSize; k++ )
1289 Vec_IntWriteEntry( vData, k, Gia_ManHashAnd(p, Vec_IntEntry(vData, k), Vec_IntEntry(vDec, k%Vec_IntSize(vDec))) );
1290 for ( b = 0; b < nBits; b++, nSize /= 2 )
1291 for ( k = 0; k < nSize/2; k++ )
1292 Vec_IntWriteEntry( vData, k, Gia_ManHashOr(p, Vec_IntEntry(vData, 2*k), Vec_IntEntry(vData, 2*k+1)) );
1293 Vec_IntFree( vDec );
1294 iStart += nBits;
1295 }
1296 assert( nSize == 1 );
1297 Gia_ManAppendCo( p, Vec_IntEntry(vData, 0) );
1298 Vec_IntFree( vIns );
1299 Vec_IntFree( vData );
1300 p = Gia_ManCleanup( pTemp = p );
1301 Gia_ManStop( pTemp );
1302 return p;
1303}
int strlen()
Here is the call graph for this function:

◆ Gia_ManGenNeuron()

Gia_Man_t * Gia_ManGenNeuron ( char * pFileName,
int nIBits,
int nLutSize,
int fDump,
int fVerbose )

Definition at line 1143 of file giaGen.c.

1144{
1145 int nWords = -1;
1146 Vec_Wrd_t * vData = Vec_WrdReadHex( pFileName, &nWords, 0 );
1147 if ( vData == NULL )
1148 return NULL;
1149
1150 assert( nWords == 1 );
1151 assert( 0 < nIBits && nIBits < 32 );
1152 int i, Lit, nOBits = Gia_ManGenNeuronBitWidth( vData, nIBits );
1153 if ( fDump ) Gia_ManGenNeuronDumpVerilog( vData, nIBits, nOBits );
1154
1155 Gia_Man_t * pTemp, * pNew = Gia_ManStart( 10000 );
1156 pNew->pName = Abc_UtilStrsav( "neuron" );
1157 for ( i = 0; i < nIBits * (Vec_WrdSize(vData)-1); i++ )
1158 Gia_ManAppendCi( pNew );
1159 Gia_ManHashAlloc( pNew );
1160
1161 Vec_Wec_t * vTemp, * vArgs = Gia_ManGenNeuronCreateArgs( vData, nIBits, nOBits );
1162 Vec_WrdFree( vData );
1163
1164 if ( nLutSize ) {
1165 vArgs = Gia_ManGenNeuronTransformArgs( pNew, vTemp = vArgs, nLutSize, nOBits );
1166 Vec_WecFree( vTemp );
1167 while ( Vec_WecSize(vArgs) > 2 ) {
1168 vArgs = Gia_ManGenNeuronCompactArgs( pNew, vTemp = vArgs, nLutSize, nOBits );
1169 Vec_WecFree( vTemp );
1170 }
1171 }
1172
1173 Vec_Int_t * vRes = Gia_ManGenNeuronFinal( pNew, vArgs, nOBits );
1174 Vec_IntForEachEntry( vRes, Lit, i )
1175 Gia_ManAppendCo( pNew, Lit );
1176 Vec_IntFree( vRes );
1177 Vec_WecFree( vArgs );
1178
1179 pNew = Gia_ManCleanup( pTemp = pNew );
1180 Gia_ManStop( pTemp );
1181 return pNew;
1182}
Vec_Wec_t * Gia_ManGenNeuronCreateArgs(Vec_Wrd_t *vData, int nIBits, int nOBits)
Definition giaGen.c:1071
Vec_Int_t * Gia_ManGenNeuronFinal(Gia_Man_t *pNew, Vec_Wec_t *vArgs, int nOBits)
Definition giaGen.c:1127
Vec_Wec_t * Gia_ManGenNeuronTransformArgs(Gia_Man_t *pNew, Vec_Wec_t *vArgs, int nLutSize, int nOBits)
Definition giaGen.c:1091
int Gia_ManGenNeuronBitWidth(Vec_Wrd_t *vData, int nIBits)
Definition giaGen.c:1135
Vec_Wec_t * Gia_ManGenNeuronCompactArgs(Gia_Man_t *pNew, Vec_Wec_t *vArgs, int nLutSize, int nOBits)
Definition giaGen.c:1110
void Gia_ManGenNeuronDumpVerilog(Vec_Wrd_t *vData, int nIBits, int nOBits)
Definition giaGen.c:1028
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
Here is the call graph for this function:

◆ Gia_ManGenNeuronAdder()

void Gia_ManGenNeuronAdder ( Gia_Man_t * p,
int nLits,
int * pLitsA,
int * pLitsB,
int Carry,
Vec_Int_t * vRes )

Definition at line 1045 of file giaGen.c.

1046{
1047 extern void Wlc_BlastFullAdder( Gia_Man_t * pNew, int a, int b, int c, int * pc, int * ps );
1048 int i, Res = -1;
1049 Vec_IntClear( vRes );
1050 for ( i = 0; i < nLits; i++ ) {
1051 Wlc_BlastFullAdder( p, pLitsA[i], pLitsB[i], Carry, &Carry, &Res );
1052 Vec_IntPush( vRes, Res );
1053 }
1054}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManGenNeuronBitWidth()

int Gia_ManGenNeuronBitWidth ( Vec_Wrd_t * vData,
int nIBits )

Definition at line 1135 of file giaGen.c.

1136{
1137 int i, InMask = (1<<nIBits)-1;
1138 word Data, DataMax = Vec_WrdEntryLast(vData);
1139 Vec_WrdForEachEntryStop( vData, Data, i, Vec_WrdSize(vData)-1 )
1140 DataMax += InMask * Data;
1141 return Abc_Base2LogW(DataMax);
1142}
#define Vec_WrdForEachEntryStop(vVec, Entry, i, Stop)
Definition vecWrd.h:58
Here is the caller graph for this function:

◆ Gia_ManGenNeuronCompactArgs()

Vec_Wec_t * Gia_ManGenNeuronCompactArgs ( Gia_Man_t * pNew,
Vec_Wec_t * vArgs,
int nLutSize,
int nOBits )

Definition at line 1110 of file giaGen.c.

1111{
1112 int i, nParts = Vec_WecSize(vArgs) / 3;
1113 Vec_Wec_t * vNew = Vec_WecAlloc( 2 * nParts + Vec_WecSize(vArgs) % 3 );
1114 for ( i = 0; i < nParts; i++ ) {
1115 Vec_Int_t * vIn0 = Vec_WecEntry(vArgs, 3*i+0);
1116 Vec_Int_t * vIn1 = Vec_WecEntry(vArgs, 3*i+1);
1117 Vec_Int_t * vIn2 = Vec_WecEntry(vArgs, 3*i+2);
1118 Vec_Int_t * vOut0 = Vec_WecPushLevel(vNew);
1119 Vec_Int_t * vOut1 = Vec_WecPushLevel(vNew);
1120 Gia_ManGenCompact( pNew, vIn0, vIn1, vIn2, vOut0, vOut1 );
1121 }
1122 for ( i = 3*nParts; i < Vec_WecSize(vArgs); i++ )
1123 Vec_IntAppend( Vec_WecPushLevel(vNew), Vec_WecEntry(vArgs, i) );
1124 assert( Vec_WecSize(vNew) == 2 * nParts + Vec_WecSize(vArgs) % 3 );
1125 return vNew;
1126}
void Gia_ManGenCompact(Gia_Man_t *p, Vec_Int_t *vIn0, Vec_Int_t *vIn1, Vec_Int_t *vIn2, Vec_Int_t *vOut0, Vec_Int_t *vOut1)
Definition giaGen.c:1055
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManGenNeuronCreateArgs()

Vec_Wec_t * Gia_ManGenNeuronCreateArgs ( Vec_Wrd_t * vData,
int nIBits,
int nOBits )

Definition at line 1071 of file giaGen.c.

1072{
1073 word Data = Vec_WrdEntryLast(vData); int i, b, n, nLits = 2;
1074 Vec_Wec_t * vArgs = Vec_WecAlloc( Vec_WrdSize(vData) * nIBits );
1075 Vec_Int_t * vLev = Vec_WecPushLevel( vArgs );
1076 Vec_IntFill( vLev, nOBits, 0 );
1077 for ( b = 0; b < nOBits; b++ )
1078 if ( (Data >> b) & 1 )
1079 Vec_IntWriteEntry( vLev, b, 1 );
1080 Vec_WrdForEachEntryStop( vData, Data, i, Vec_WrdSize(vData)-1 ) {
1081 for ( n = 0; n < nIBits; n++, nLits += 2 ) {
1082 Vec_Int_t * vLev = Vec_WecPushLevel( vArgs );
1083 Vec_IntFill( vLev, nOBits, 0 );
1084 for ( b = 0; b < nOBits; b++ )
1085 if ( ((Data >> b) & 1) && b+n < nOBits )
1086 Vec_IntWriteEntry( vLev, b+n, nLits );
1087 }
1088 }
1089 return vArgs;
1090}
Here is the caller graph for this function:

◆ Gia_ManGenNeuronDumpVerilog()

void Gia_ManGenNeuronDumpVerilog ( Vec_Wrd_t * vData,
int nIBits,
int nOBits )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1028 of file giaGen.c.

1029{
1030 FILE * pFile = fopen( "temp.v", "wb" );
1031 if ( pFile == NULL ) {
1032 printf( "Cannot open output file.\n" );
1033 return;
1034 }
1035 fprintf( pFile, "module neuron_%d_%d_%d ( input [%d:0] i, output [%d:0] o );\n",
1036 Vec_WrdSize(vData)-1, nIBits, nOBits, (Vec_WrdSize(vData)-1)*nIBits-1, nOBits-1 );
1037 fprintf( pFile, "assign o = %d'h%lX", nOBits, Vec_WrdEntryLast(vData) );
1038 word Data; int i;
1039 Vec_WrdForEachEntryStop( vData, Data, i, Vec_WrdSize(vData)-1 )
1040 fprintf( pFile, "\n + %d'h%lX * i[%d:%d]", nOBits, Data, nIBits*(i+1)-1, nIBits*i );
1041 fprintf( pFile, ";\nendmodule\n\n" );
1042 fclose( pFile );
1043 printf( "Dumped the neuron specification into file \"temp.v\".\n" );
1044}
Here is the caller graph for this function:

◆ Gia_ManGenNeuronFinal()

Vec_Int_t * Gia_ManGenNeuronFinal ( Gia_Man_t * pNew,
Vec_Wec_t * vArgs,
int nOBits )

Definition at line 1127 of file giaGen.c.

1128{
1129 Vec_Int_t * vRes = Vec_IntAlloc( nOBits ), * vArg; int i;
1130 Vec_IntAppend( vRes, Vec_WecEntry(vArgs, 0) );
1131 Vec_WecForEachLevelStart( vArgs, vArg, i, 1 )
1132 Gia_ManGenNeuronAdder( pNew, nOBits, Vec_IntArray(vArg), Vec_IntArray(vRes), 0, vRes );
1133 return vRes;
1134}
void Gia_ManGenNeuronAdder(Gia_Man_t *p, int nLits, int *pLitsA, int *pLitsB, int Carry, Vec_Int_t *vRes)
Definition giaGen.c:1045
#define Vec_WecForEachLevelStart(vGlob, vVec, i, LevelStart)
Definition vecWec.h:59
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManGenNeuronTransformArgs()

Vec_Wec_t * Gia_ManGenNeuronTransformArgs ( Gia_Man_t * pNew,
Vec_Wec_t * vArgs,
int nLutSize,
int nOBits )

Definition at line 1091 of file giaGen.c.

1092{
1093 int i, nParts = (Vec_WecSize(vArgs) + nLutSize - 2) / nLutSize;
1094 while ( Vec_WecSize(vArgs) < nLutSize*nParts+1 )
1095 Vec_IntFill( Vec_WecPushLevel(vArgs), nOBits, 0 );
1096 assert( Vec_WecSize(vArgs) == nLutSize*nParts+1 );
1097 Vec_Wec_t * vNew = Vec_WecAlloc( nParts );
1098 Vec_Int_t * vRes = Vec_WecPushLevel( vNew ), * vArg;
1099 Vec_IntAppend( vRes, Vec_WecEntry(vArgs, 0) );
1100 Vec_WecForEachLevelStart( vArgs, vArg, i, 1 ) {
1101 Gia_ManGenNeuronAdder( pNew, nOBits, Vec_IntArray(vArg), Vec_IntArray(vRes), 0, vRes );
1102 if ( (i-1) % nLutSize == nLutSize-1 && i < Vec_WecSize(vArgs)-1 ) {
1103 vRes = Vec_WecPushLevel( vNew );
1104 Vec_IntFill( vRes, nOBits, 0 );
1105 }
1106 }
1107 assert( Vec_WecSize(vNew) == nParts );
1108 return vNew;
1109}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManGenPrefix()

void Gia_ManGenPrefix ( Gia_Man_t * pNew,
int * p,
int * g,
int p2,
int g2 )

Definition at line 1437 of file giaGen.c.

1438{
1439 *g = Gia_ManHashOr(pNew, *g, Gia_ManHashAnd(pNew, *p, g2));
1440 *p = Gia_ManHashAnd(pNew, *p, p2);
1441}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManGenPrep()

void Gia_ManGenPrep ( int nVars,
int ** p )

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

Synopsis [Generates brand-name adders.]

Description []

SideEffects []

SeeAlso []

Definition at line 1374 of file giaGen.c.

1375{
1376 int i, k;
1377 for ( i = 0; i < nVars; i++ )
1378 for ( k = 0; k < nVars; k++ )
1379 p[i][k] = -1;
1380}
Here is the caller graph for this function:

◆ Gia_ManGenPrint()

void Gia_ManGenPrint ( int nVars,
int ** p )

Definition at line 1419 of file giaGen.c.

1420{
1421 int i, k;
1422 for ( i = nVars-1; i >= 0; i-- )
1423 printf( "%2d ", i );
1424 printf( "\n" );
1425 for ( i = 0; i < nVars; i++ ) {
1426 for ( k = nVars-1; k >= 0; k-- )
1427 if ( p[i][k] >= 0 )
1428 break;
1429 for ( k = nVars-1; k >= 0; k-- )
1430 if ( p[i][k] == -1 )
1431 printf( " - " );
1432 else
1433 printf( "%2d ", p[i][k] );
1434 printf("\n");
1435 }
1436}
Here is the caller graph for this function:

◆ Gia_ManGenRca()

void Gia_ManGenRca ( int nVars,
int ** p )

Definition at line 1413 of file giaGen.c.

1414{
1415 int i;
1416 for ( i = 1; i < nVars; i++ )
1417 p[i][i] = i-1;
1418}
Here is the caller graph for this function:

◆ Gia_ManGenSK()

void Gia_ManGenSK ( int nVars,
int ** p )

Definition at line 1381 of file giaGen.c.

1382{
1383 int i, k, nBits = Abc_Base2Log(nVars);
1384 for ( i = 0; i < nBits; i++ )
1385 for ( k = 0; k < nVars; k++ )
1386 if ( (k >> i) & 1 )
1387 p[i+1][k] = ((1 << i) - 1) | ((k >> (i+1)) << (i+1));
1388}
Here is the caller graph for this function:

◆ Gia_ManGenSorter()

Gia_Man_t * Gia_ManGenSorter ( int LogN)

Definition at line 1347 of file giaGen.c.

1348{
1349 int i, nVars = 1 << LogN;
1350 int nVarsAlloc = nVars + 2 * (nVars * LogN * (LogN-1) / 4 + nVars - 1);
1351 Vec_Int_t * vLits = Vec_IntAlloc( nVars );
1352 Gia_Man_t * p = Gia_ManStart( 1 + 2*nVars + nVarsAlloc );
1353 p->pName = Abc_UtilStrsav( "sorter" );
1354 for ( i = 0; i < nVars; i++ )
1355 Vec_IntPush( vLits, Gia_ManAppendCi(p) );
1356 Gia_ManGenSorterConstrRange( p, Vec_IntArray(vLits), 0, nVars - 1 );
1357 for ( i = 0; i < nVars; i++ )
1358 Gia_ManAppendCo( p, Vec_IntEntry(vLits, i) );
1359 Vec_IntFree( vLits );
1360 return p;
1361}
Here is the call graph for this function:

◆ Gia_ManGetExampleValue()

int Gia_ManGetExampleValue ( word ** ppSims,
int nSims,
int iExample )

Definition at line 670 of file giaGen.c.

671{
672 int o, Sign = 0, ValueSim = 0;
673 for ( o = 0; o < nSims; o++ )
674 if ( (Sign = Abc_TtGetBit(ppSims[o], iExample)) )
675 ValueSim |= (1 << o);
676 if ( Sign )
677 ValueSim |= ~0 << nSims;
678 return ValueSim;
679}
Here is the caller graph for this function:

◆ Gia_ManReadBinaryFile()

int Gia_ManReadBinaryFile ( char * pFileName,
Vec_Wrd_t ** pvSimsIn,
Vec_Str_t ** pvSimsOut )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 617 of file giaGen.c.

618{
619 extern void Extra_BitMatrixTransposeP( Vec_Wrd_t * vSimsIn, int nWordsIn, Vec_Wrd_t * vSimsOut, int nWordsOut );
620 int nFileSize = Extra_FileSize( pFileName );
621 int nExamples = 1 << 16;
622 int nInputs = nFileSize / nExamples - 1;
623 int nWords = (8*nInputs + 63)/64, i;
624 char * pContents = Extra_FileReadContents( pFileName );
625 Vec_Wrd_t * vSimsIn = Vec_WrdStart( nExamples * nWords );
626 Vec_Wrd_t * vSimsIn2 = Vec_WrdStart( nExamples * nWords );
627 Vec_Str_t * vSimsOut = Vec_StrAlloc( nExamples );
628 assert( nFileSize % nExamples == 0 );
629 for ( i = 0; i < nExamples; i++ )
630 {
631 memcpy( (void *)Vec_WrdEntryP(vSimsIn, i*nWords), (void *)(pContents + i*(nInputs+1)), nInputs );
632 Vec_StrPush( vSimsOut, pContents[i*(nInputs+1) + nInputs] );
633 }
634 Extra_BitMatrixTransposeP( vSimsIn, nWords, vSimsIn2, nExamples/64 );
635 Vec_WrdShrink( vSimsIn2, 8*nInputs * nExamples/64 );
636 Vec_WrdFree( vSimsIn );
637 *pvSimsIn = vSimsIn2;
638 *pvSimsOut = vSimsOut;
639 ABC_FREE( pContents );
640 return nInputs;
641}
int Extra_FileSize(char *pFileName)
char * Extra_FileReadContents(char *pFileName)
ABC_NAMESPACE_IMPL_START void Extra_BitMatrixTransposeP(Vec_Wrd_t *vSimsIn, int nWordsIn, Vec_Wrd_t *vSimsOut, int nWordsOut)
DECLARATIONS ///.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManReadCifar10File()

int Gia_ManReadCifar10File ( char * pFileName,
Vec_Wrd_t ** pvSimsIn,
Vec_Str_t ** pvSimsOut,
int * pnExamples )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 787 of file giaGen.c.

788{
789 int nPixels = 32*32*3;
790 int nFileSize = Extra_FileSize( pFileName );
791 int nExamples = nFileSize / (nPixels + 1);
792 int nWordsIn = nPixels / 8;
793 int nWordsOut = (nExamples + 63) / 64; int e;
794 if ( nFileSize % (nPixels + 1) )
795 {
796 printf( "The input file \"%s\" with image data does not appear to be in CIFAR10 format.\n", pFileName );
797 return 0;
798 }
799 else
800 {
801 Vec_Wrd_t * vSimsIn = Vec_WrdStart( 64 * nWordsOut * nWordsIn );
802 Vec_Str_t * vSimsOut = Vec_StrAlloc( 64 * nWordsOut );
803 unsigned char * pBuffer = ABC_ALLOC( unsigned char, nFileSize );
804 FILE * pFile = fopen( pFileName, "rb" );
805 int Value = fread( pBuffer, 1, nFileSize, pFile );
806 fclose( pFile );
807 assert( Value == nFileSize );
808 printf( "Successfully read %5.2f MB (%d images) from file \"%s\".\n", (float)nFileSize/(1<<20), nExamples, pFileName );
809 for ( e = 0; e < nExamples; e++ )
810 {
811 Vec_StrPush( vSimsOut, (char)pBuffer[e*(nPixels + 1)] );
812 memcpy( Vec_WrdEntryP(vSimsIn, e*nWordsIn), pBuffer + e*(nPixels + 1) + 1, nPixels );
813 }
814 ABC_FREE( pBuffer );
815 for ( ; e < 64 * nWordsOut; e++ )
816 Vec_StrPush( vSimsOut, (char)0 );
817 memset( Vec_WrdEntryP(vSimsIn, nExamples*nWordsIn), 0, (64*nWordsOut - nExamples)*nWordsIn );
818 *pvSimsIn = vSimsIn;
819 *pvSimsOut = vSimsOut;
820 *pnExamples = nExamples;
821 return 8*nPixels;
822 }
823}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManReadSimFile()

void Gia_ManReadSimFile ( char * pFileName,
int * pnIns,
int * pnOuts,
int * pnPats,
Vec_Wrd_t ** pvSimsIn,
Vec_Wrd_t ** pvSimsOut )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 537 of file giaGen.c.

538{
539 char * pTemp, pBuffer[1000];
540 Vec_Wrd_t * vSimsIn = NULL, * vSimsOut = NULL;
541 int i, iPat = 0, nWordsI, nWordsO, nIns = -1, nOuts = -1, nPats = -1;
542 FILE * pFile = fopen( pFileName, "rb" );
543 if ( pFile == NULL )
544 {
545 printf( "Cannot open file \"%s\" for reading.\n", pFileName );
546 return;
547 }
548 while ( fgets( pBuffer, 1000, pFile ) != NULL )
549 {
550 pTemp = pBuffer;
551 if ( pTemp[0] == '\0' || pTemp[0] == '#' || pTemp[0] == ' ' )
552 continue;
553 if ( pTemp[0] != '.' )
554 break;
555 if ( pTemp[1] == 'i' )
556 nIns = atoi(pTemp+2);
557 else if ( pTemp[1] == 'o' )
558 nOuts = atoi(pTemp+2);
559 else if ( pTemp[1] == 'p' )
560 {
561 if ( atoi(pTemp+2) % 64 == 0 )
562 printf( "Expecting the number of patterns divisible by 64.\n" );
563 nPats = atoi(pTemp+2) / 64;
564 }
565 }
566 if ( nIns == -1 || nOuts == -1 || nPats == -1 )
567 {
568 printf( "Some of the parameters (inputs, outputs, patterns) is not specified.\n" );
569 fclose( pFile );
570 return;
571 }
572 nWordsI = (nIns + 63) / 64;
573 nWordsO = (nOuts + 63) / 64;
574
575 vSimsIn = Vec_WrdStart( nPats * nWordsI );
576 vSimsOut = Vec_WrdStart( nPats * nWordsO );
577 rewind(pFile);
578 while ( fgets( pBuffer, 1000, pFile ) != NULL )
579 {
580 if ( pTemp[0] == '\0' || pTemp[0] == '.' )
581 continue;
582 for ( i = 0, pTemp = pBuffer; *pTemp != '\n'; pTemp++ )
583 if ( *pTemp == '0' || *pTemp == '1' )
584 {
585 if ( *pTemp == '1' )
586 {
587 if ( i < nIns )
588 Abc_TtSetBit( Vec_WrdEntryP(vSimsIn, nWordsI*iPat), i );
589 else
590 Abc_TtSetBit( Vec_WrdEntryP(vSimsOut, nWordsO*iPat), i-nIns );
591 }
592 i++;
593 }
594 iPat++;
595 }
596 if ( iPat != nPats )
597 printf( "The number of patterns does not match.\n" );
598 fclose( pFile );
599 *pnIns = nIns;
600 *pnOuts = nOuts;
601 *pnPats = nPats;
602 *pvSimsIn = vSimsIn;
603 *pvSimsOut = vSimsOut;
604}
VOID_HACK rewind()
Here is the call graph for this function:

◆ Gia_ManSimFileRead()

void Gia_ManSimFileRead ( char * pFileName,
int nIns,
int nWords,
Vec_Wrd_t * vSimsIn,
Vec_Int_t * vValues )

Definition at line 467 of file giaGen.c.

468{
469 int c, nPats = 0, Count = 0, fReadDot = 0;
470 FILE * pFile = fopen( pFileName, "rb" );
471 if ( pFile == NULL )
472 {
473 printf( "Cannot open file \"%s\" for reading.\n", pFileName );
474 return;
475 }
476 assert( Vec_WrdSize(vSimsIn) % nWords == 0 );
477 while ( (c = fgetc(pFile)) != EOF )
478 {
479 if ( c == '.' )
480 fReadDot = 1;
481 if ( c == '\n' )
482 fReadDot = 0;
483 if ( fReadDot )
484 continue;
485 if ( c != '0' && c != '1' )
486 continue;
487 if ( Count == nIns )
488 {
489 Vec_IntPush( vValues, c - '0' );
490 Count = 0;
491 nPats++;
492 }
493 else
494 {
495 if ( c == '1' )
496 Abc_TtSetBit( Vec_WrdEntryP(vSimsIn, Count * nWords), nPats );
497 Count++;
498 }
499 }
500 assert( nPats == 64*nWords );
501 fclose( pFile );
502 printf( "Finished reading %d simulation patterns for %d inputs. Probability of 1 at the output is %6.2f %%.\n", 64*nWords, nIns, 100.0*Vec_IntSum(vValues)/nPats );
503}
Here is the caller graph for this function:

◆ Gia_ManSimLogStats()

void Gia_ManSimLogStats ( Gia_Man_t * p,
char * pDumpFile,
int Total,
int Correct,
int Guess )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 404 of file giaGen.c.

405{
406 FILE * pTable = fopen( pDumpFile, "wb" );
407 fprintf( pTable, "{\n" );
408 fprintf( pTable, " \"name\" : \"%s\",\n", p->pName );
409 fprintf( pTable, " \"input\" : %d,\n", Gia_ManCiNum(p) );
410 fprintf( pTable, " \"output\" : %d,\n", Gia_ManCoNum(p) );
411 fprintf( pTable, " \"and\" : %d,\n", Gia_ManAndNum(p) );
412 fprintf( pTable, " \"level\" : %d,\n", Gia_ManLevelNum(p) );
413 fprintf( pTable, " \"total\" : %d,\n", Total );
414 fprintf( pTable, " \"correct\" : %d,\n", Correct );
415 fprintf( pTable, " \"guess\" : %d\n", Guess );
416 fprintf( pTable, "}\n" );
417 fclose( pTable );
418}
int Gia_ManLevelNum(Gia_Man_t *p)
Definition giaUtil.c:546
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSimLogStats2()

void Gia_ManSimLogStats2 ( Gia_Man_t * p,
char * pDumpFile,
int Total,
int nPositives,
float ErrorTotal,
float GuessTotal )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 654 of file giaGen.c.

655{
656 FILE * pTable = fopen( pDumpFile, "wb" );
657 fprintf( pTable, "{\n" );
658 fprintf( pTable, " \"name\" : \"%s\",\n", p->pName );
659 fprintf( pTable, " \"input\" : %d,\n", Gia_ManCiNum(p) );
660 fprintf( pTable, " \"output\" : %d,\n", Gia_ManCoNum(p) );
661 fprintf( pTable, " \"and\" : %d,\n", Gia_ManAndNum(p) );
662 fprintf( pTable, " \"level\" : %d,\n", Gia_ManLevelNum(p) );
663 fprintf( pTable, " \"total\" : %d,\n", Total );
664 fprintf( pTable, " \"positive\" : %d,\n", nPositives );
665 fprintf( pTable, " \"error\" : %e,\n", ErrorTotal );
666 fprintf( pTable, " \"guess\" : %e\n", GuessTotal );
667 fprintf( pTable, "}\n" );
668 fclose( pTable );
669}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSimParamRead()

int Gia_ManSimParamRead ( char * pFileName,
int * pnIns,
int * pnWords )

Definition at line 419 of file giaGen.c.

420{
421 int c, nIns = -1, nLines = 0, Count = 0, fReadDot = 0;
422 FILE * pFile = fopen( pFileName, "rb" );
423 if ( pFile == NULL )
424 {
425 printf( "Cannot open file \"%s\" for reading.\n", pFileName );
426 return 0;
427 }
428 while ( (c = fgetc(pFile)) != EOF )
429 {
430 if ( c == '.' )
431 fReadDot = 1;
432 if ( c == '\n' )
433 {
434 if ( !fReadDot )
435 {
436 if ( nIns == -1 )
437 nIns = Count;
438 else if ( nIns != Count )
439 {
440 printf( "The number of symbols (%d) does not match other lines (%d).\n", Count, nIns );
441 fclose( pFile );
442 return 0;
443 }
444 Count = 0;
445 nLines++;
446 }
447 fReadDot = 0;
448 }
449 if ( fReadDot )
450 continue;
451 if ( c != '0' && c != '1' )
452 continue;
453 Count++;
454 }
455 if ( nLines % 64 > 0 )
456 {
457 printf( "The number of lines (%d) is not divisible by 64.\n", nLines );
458 fclose( pFile );
459 return 0;
460 }
461 *pnIns = nIns - 1;
462 *pnWords = nLines / 64;
463 //printf( "Expecting %d inputs and %d words of simulation data.\n", *pnIns, *pnWords );
464 fclose( pFile );
465 return 1;
466}
Here is the caller graph for this function:

◆ Gia_ManSimulateAll()

Vec_Str_t * Gia_ManSimulateAll ( Gia_Man_t * p,
Vec_Wrd_t * vSimsIn,
Vec_Str_t * vSimsOut,
int nExamples,
int fVerbose )

Definition at line 860 of file giaGen.c.

861{
862 extern void Extra_BitMatrixTransposeP( Vec_Wrd_t * vSimsIn, int nWordsIn, Vec_Wrd_t * vSimsOut, int nWordsOut );
863 Vec_Str_t * vRes = Vec_StrAlloc( 100 ); int b, Count;
864 int nWordsIn = 32*32*24/64; // one image
865 int nWordsOut = Vec_WrdSize(vSimsIn)/(nWordsIn*64);
866 assert( Vec_WrdSize(vSimsIn) % nWordsIn == 0 );
867 for ( b = 0; b < nWordsOut; b++ )
868 {
869 int Limit = b == nWordsOut-1 ? nExamples-b*64 : 64;
870 Vec_Wrd_t * vSimsIn1 = Vec_WrdStart( nWordsIn*64 );
871 Vec_Wrd_t * vSimsIn2 = Vec_WrdStart( nWordsIn*64 );
872 memcpy( Vec_WrdArray(vSimsIn1), Vec_WrdEntryP(vSimsIn, b*nWordsIn*64), sizeof(word)*nWordsIn*64 );
873 Extra_BitMatrixTransposeP( vSimsIn1, nWordsIn, vSimsIn2, 1 );
874 Vec_WrdFree( vSimsIn1 );
875 Count = Gia_ManSimulateBatch( p, vSimsIn2, vRes, vSimsOut, b, Limit );
876 Vec_WrdFree( vSimsIn2 );
877 if ( fVerbose )
878 printf( "Finished simulating word %4d (out of %4d). Correct = %2d. (Limit = %2d.)\n", b, nWordsOut, Count, Limit );
879 }
880 assert( Vec_StrSize(vRes) == nExamples );
881 return vRes;
882}
int Gia_ManSimulateBatch(Gia_Man_t *p, Vec_Wrd_t *vSimsIn, Vec_Str_t *vSimsOut, Vec_Str_t *vSimsOut2, int b, int Limit)
Definition giaGen.c:836
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSimulateBatch()

int Gia_ManSimulateBatch ( Gia_Man_t * p,
Vec_Wrd_t * vSimsIn,
Vec_Str_t * vSimsOut,
Vec_Str_t * vSimsOut2,
int b,
int Limit )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 836 of file giaGen.c.

837{
838 Gia_Obj_t * pObj;
839 word * ppSims[10];
840 int i, o, Count = 0;
841 assert( Gia_ManCiNum(p) == Vec_WrdSize(vSimsIn) );
842 assert( Gia_ManCoNum(p) == 10 );
843 Gia_ManSimulateWordsInit( p, vSimsIn );
844 Gia_ManForEachCo( p, pObj, o )
845 ppSims[o] = Gia_ManObjSim( p, Gia_ObjId(p, pObj) );
846 for ( i = 0; i < Limit; i++ )
847 {
848 int Value = 0;
849 for ( o = 0; o < 10; o++ )
850 if ( Abc_TtGetBit(ppSims[o], i) )
851 {
852 Value = o;
853 break;
854 }
855 Vec_StrPush( vSimsOut, (char)Value );
856 Count += Value == (int)Vec_StrEntry( vSimsOut2, 64*b+i );
857 }
858 return Count;
859}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSimulateWords()

int Gia_ManSimulateWords ( Gia_Man_t * p,
int nWords )

Definition at line 151 of file giaGen.c.

152{
153 Gia_Obj_t * pObj; int i;
154 // allocate simulation info for one timeframe
155 Vec_WrdFreeP( &p->vSims );
156 p->vSims = Vec_WrdStart( Gia_ManObjNum(p) * nWords );
157 p->nSimWords = nWords;
158 // perform simulation
159 Gia_ManForEachObj1( p, pObj, i )
160 {
161 if ( Gia_ObjIsAnd(pObj) )
162 Gia_ManObjSimAnd( p, i );
163 else if ( Gia_ObjIsCi(pObj) )
164 Gia_ManObjSimPi( p, i );
165 else if ( Gia_ObjIsCo(pObj) )
166 Gia_ManObjSimPo( p, i );
167 else assert( 0 );
168 }
169 return 1;
170}
#define Gia_ManForEachObj1(p, pObj, i)
Definition gia.h:1192
Here is the caller graph for this function:

◆ Gia_ManSimulateWordsInit()

int Gia_ManSimulateWordsInit ( Gia_Man_t * p,
Vec_Wrd_t * vSimsIn )

Definition at line 172 of file giaGen.c.

173{
174 Gia_Obj_t * pObj; int i, Id;
175 int nWords = Vec_WrdSize(vSimsIn) / Gia_ManCiNum(p);
176 assert( Vec_WrdSize(vSimsIn) == nWords * Gia_ManCiNum(p) );
177 // allocate simulation info for one timeframe
178 Vec_WrdFreeP( &p->vSims );
179 p->vSims = Vec_WrdStart( Gia_ManObjNum(p) * nWords );
180 p->nSimWords = nWords;
181 // set input sim info
182 Gia_ManForEachCiId( p, Id, i )
183 memcpy( Vec_WrdEntryP(p->vSims, Id*nWords), Vec_WrdEntryP(vSimsIn, i*nWords), sizeof(word)*nWords );
184 // perform simulation
185 Gia_ManForEachObj1( p, pObj, i )
186 {
187 if ( Gia_ObjIsAnd(pObj) )
188 Gia_ManObjSimAnd( p, i );
189 else if ( Gia_ObjIsCi(pObj) )
190 continue;
191 else if ( Gia_ObjIsCo(pObj) )
192 Gia_ManObjSimPo( p, i );
193 else assert( 0 );
194 }
195 return 1;
196}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSimulateWordsOut()

Vec_Wrd_t * Gia_ManSimulateWordsOut ( Gia_Man_t * p,
Vec_Wrd_t * vSimsIn )

Definition at line 198 of file giaGen.c.

199{
200 Gia_Obj_t * pObj; int i, Id;
201 int nWords = Vec_WrdSize(vSimsIn) / Gia_ManCiNum(p);
202 Vec_Wrd_t * vSimsOut = Vec_WrdStart( nWords * Gia_ManCoNum(p) );
203 assert( Vec_WrdSize(vSimsIn) == nWords * Gia_ManCiNum(p) );
204 // allocate simulation info for one timeframe
205 Vec_WrdFreeP( &p->vSims );
206 p->vSims = Vec_WrdStart( Gia_ManObjNum(p) * nWords );
207 p->nSimWords = nWords;
208 // set input sim info
209 Gia_ManForEachCiId( p, Id, i )
210 memcpy( Vec_WrdEntryP(p->vSims, Id*nWords), Vec_WrdEntryP(vSimsIn, i*nWords), sizeof(word)*nWords );
211 // perform simulation
212 Gia_ManForEachObj1( p, pObj, i )
213 {
214 if ( Gia_ObjIsAnd(pObj) )
215 Gia_ManObjSimAnd( p, i );
216 else if ( Gia_ObjIsCi(pObj) )
217 continue;
218 else if ( Gia_ObjIsCo(pObj) )
219 Gia_ManObjSimPo( p, i );
220 else assert( 0 );
221 }
222 // set output sim info
223 Gia_ManForEachCoId( p, Id, i )
224 memcpy( Vec_WrdEntryP(vSimsOut, i*nWords), Vec_WrdEntryP(p->vSims, Id*nWords), sizeof(word)*nWords );
225 Vec_WrdFreeP( &p->vSims );
226 p->nSimWords = -1;
227 return vSimsOut;
228}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSumCount()

int Gia_ManSumCount ( char * p,
Vec_Int_t * vDec,
int b )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 939 of file giaGen.c.

940{
941 int i, Ent, Count = 0, Sum = 0;
942 for ( i = 0; p[i]; i++ ) {
943 Ent = (p[i] >= '0' && p[i] <= '9') ? p[i]-'0' : p[i]-'A'+10;
944 Count += Vec_IntEntry(vDec, Ent) + b * (1 << (Sum += Ent));
945 }
946 return Count + b * ((1 << Sum) - 1);
947}
Here is the caller graph for this function:

◆ Gia_ManSumEnum()

void Gia_ManSumEnum ( int n,
Vec_Int_t * vDec )

Definition at line 969 of file giaGen.c.

970{
971 Vec_Str_t * vRes = Gia_ManSumEnum_rec( n );
972 for ( int b = 1; b <= 256; b <<= 1 ) {
973 int iBest = -1, CountCur, CountBest = ABC_INFINITY;
974 for ( int c0 = 0; c0 < Vec_StrSize(vRes); c0 += strlen(Vec_StrEntryP(vRes,c0))+1 ) {
975 CountCur = Gia_ManSumCount( Vec_StrEntryP(vRes,c0), vDec, b );
976 if ( CountBest > CountCur )
977 CountBest = CountCur, iBest = c0;
978 }
979 printf( " %8d", CountBest );
980 //printf( " %8s", Vec_StrEntryP(vRes,iBest) );
981 //printf( " %.3f", (float)CountBest/(3*b*((1<<n)-1)) );
982 }
983// Vec_StrPrint( vRes, 0 );
984 Vec_StrFree( vRes );
985}
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
int Gia_ManSumCount(char *p, Vec_Int_t *vDec, int b)
Definition giaGen.c:939
Vec_Str_t * Gia_ManSumEnum_rec(int Num)
Definition giaGen.c:948
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSumEnum_rec()

Vec_Str_t * Gia_ManSumEnum_rec ( int Num)

Definition at line 948 of file giaGen.c.

949{
950 if ( Num == 1 ) {
951 Vec_Str_t * vRes = Vec_StrAlloc(2);
952 Vec_StrPush( vRes, '1' );
953 Vec_StrPush( vRes, '\0' );
954 return vRes;
955 }
956 Vec_Str_t * vRes = Vec_StrAlloc( 16 );
957 for ( int i = 1; i < Num; i++ ) {
958 Vec_Str_t * vRes0 = Gia_ManSumEnum_rec(i);
959 Vec_Str_t * vRes1 = Gia_ManSumEnum_rec(Num-i);
960 for ( int c0 = 0; c0 < Vec_StrSize(vRes0); c0 += strlen(Vec_StrEntryP(vRes0,c0))+1 )
961 for ( int c1 = 0; c1 < Vec_StrSize(vRes1); c1 += strlen(Vec_StrEntryP(vRes1,c1))+1 )
962 Vec_StrPrintF( vRes, "%s%s%c", Vec_StrEntryP(vRes0,c0), Vec_StrEntryP(vRes1,c1), '\0' );
963 Vec_StrPrintF( vRes, "%c%c", Num < 10 ? '0'+Num : 'A'+Num-10, '\0' );
964 Vec_StrFree( vRes0 );
965 Vec_StrFree( vRes1 );
966 }
967 return vRes;
968}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSumEnumTest()

void Gia_ManSumEnumTest ( )

Definition at line 1001 of file giaGen.c.

1002{
1003 Vec_Int_t * vDec = Gia_ManSumGenDec( 16 );
1004 printf( " " );
1005 for ( int b = 1; b <= 256; b <<= 1 )
1006 printf( " %8d", b );
1007 printf( "\n" );
1008 for ( int i = 1; i <= 15; i++ ) {
1009 printf( "%2d :", i );
1010 Gia_ManSumEnum( i, vDec );
1011 printf( "\n" );
1012 }
1013 Vec_IntFree( vDec );
1014}
Vec_Int_t * Gia_ManSumGenDec(int n)
Definition giaGen.c:986
void Gia_ManSumEnum(int n, Vec_Int_t *vDec)
Definition giaGen.c:969
Here is the call graph for this function:

◆ Gia_ManSumGenDec()

Vec_Int_t * Gia_ManSumGenDec ( int n)

Definition at line 986 of file giaGen.c.

987{
988 Vec_Int_t * vDec = Vec_IntAlloc( n + 1 );
989 Vec_IntPush( vDec, 0 );
990 Vec_IntPush( vDec, 0 );
991 Vec_IntPush( vDec, 4 );
992 Vec_IntPush( vDec, 12 );
993 for ( int i = 4; i <= n; i++ ) {
994 int Ent0 = Vec_IntEntry( vDec, i / 2 );
995 int Ent1 = Vec_IntEntry( vDec, i - i / 2 );
996 assert( Vec_IntSize(vDec) == i );
997 Vec_IntPush( vDec, Ent0 + Ent1 + (1 << i / 2) * (1 << (i - i / 2)) );
998 }
999 return vDec;
1000}
Here is the caller graph for this function:

◆ Gia_ManTestOneFile()

void Gia_ManTestOneFile ( Gia_Man_t * p,
char * pFileName,
char * pDumpFile )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 755 of file giaGen.c.

756{
757 Vec_Wrd_t * vSimsIn;
758 Vec_Int_t * vValues;
759 int nIns, nWords;
760 if ( !Gia_ManSimParamRead( pFileName, &nIns, &nWords ) )
761 return;
762 if ( nIns != Gia_ManCiNum(p) )
763 {
764 printf( "The number of inputs in the file \"%s\" (%d) does not match the AIG (%d).\n", pFileName, nIns, Gia_ManCiNum(p) );
765 return;
766 }
767 vSimsIn = Vec_WrdStart( nIns * nWords );
768 vValues = Vec_IntAlloc( nWords * 64 );
769 Gia_ManSimFileRead( pFileName, nIns, nWords, vSimsIn, vValues );
770 Gia_ManCompareValues( p, vSimsIn, vValues, pDumpFile );
771 Vec_WrdFree( vSimsIn );
772 Vec_IntFree( vValues );
773}
void Gia_ManSimFileRead(char *pFileName, int nIns, int nWords, Vec_Wrd_t *vSimsIn, Vec_Int_t *vValues)
Definition giaGen.c:467
int Gia_ManSimParamRead(char *pFileName, int *pnIns, int *pnWords)
Definition giaGen.c:419
void Gia_ManCompareValues(Gia_Man_t *p, Vec_Wrd_t *vSimsIn, Vec_Int_t *vValues, char *pDumpFile)
Definition giaGen.c:504
Here is the call graph for this function:

◆ Gia_ManTestWordFile()

void Gia_ManTestWordFile ( Gia_Man_t * p,
char * pFileName,
char * pDumpFile,
int fVerbose )

Definition at line 902 of file giaGen.c.

903{
904 abctime clk = Abc_Clock();
905 Vec_Wrd_t * vSimsIn;
906 Vec_Str_t * vSimsOut;
907 int i, nExamples = 0;
908 int nInputs = Gia_ManReadCifar10File( pFileName, &vSimsIn, &vSimsOut, &nExamples );
909 char * pKnownFileNames[3] = {"small.aig", "medium.aig", "large.aig"};
910 int pLimitFileSizes[3] = {10000, 100000, 1000000};
911 for ( i = 0; i < 3; i++ )
912 if ( p->pSpec && !strncmp(p->pSpec, pKnownFileNames[i], 5) && Gia_ManAndNum(p) > pLimitFileSizes[i] )
913 printf( "Warning: The input file \"%s\" contains more than %d internal and-nodes.\n", pKnownFileNames[i], pLimitFileSizes[i] );
914 if ( nInputs == Gia_ManCiNum(p) )
915 {
916 Vec_Str_t * vRes = Gia_ManSimulateAll( p, vSimsIn, vSimsOut, nExamples, fVerbose );
917 Gia_ManCompareCifar10Values( p, vRes, vSimsOut, pDumpFile, nExamples );
918 Vec_StrFree( vRes );
919 }
920 else
921 printf( "The primary input counts in the AIG (%d) and in the image data (%d) do not match.\n", Gia_ManCiNum(p), nInputs );
922 Vec_WrdFree( vSimsIn );
923 Vec_StrFree( vSimsOut );
924 Abc_PrintTime( 1, "Total checking time", Abc_Clock() - clk );
925}
ABC_INT64_T abctime
Definition abc_global.h:332
Vec_Str_t * Gia_ManSimulateAll(Gia_Man_t *p, Vec_Wrd_t *vSimsIn, Vec_Str_t *vSimsOut, int nExamples, int fVerbose)
Definition giaGen.c:860
void Gia_ManCompareCifar10Values(Gia_Man_t *p, Vec_Str_t *vRes, Vec_Str_t *vSimsOut, char *pDumpFile, int nExamples)
Definition giaGen.c:883
int strncmp()
Here is the call graph for this function:

◆ Gia_ManTestWordFileUnused()

void Gia_ManTestWordFileUnused ( Gia_Man_t * p,
char * pFileName,
char * pDumpFile )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 731 of file giaGen.c.

732{
733 Vec_Wrd_t * vSimsIn;
734 Vec_Str_t * vSimsOut;
735 int nInputs = Gia_ManReadBinaryFile( pFileName, &vSimsIn, &vSimsOut );
736 if ( Gia_ManCiNum(p) == 8*nInputs )
737 Gia_ManCompareValues2( nInputs, p, vSimsIn, vSimsOut, pDumpFile );
738 else
739 printf( "The number of inputs in the AIG (%d) and in the file (%d) does not match.\n", Gia_ManCiNum(p), 8*nInputs );
740 Vec_WrdFree( vSimsIn );
741 Vec_StrFree( vSimsOut );
742}
void Gia_ManCompareValues2(int nInputs, Gia_Man_t *p, Vec_Wrd_t *vSimsIn, Vec_Str_t *vValues, char *pDumpFile)
Definition giaGen.c:680
int Gia_ManReadBinaryFile(char *pFileName, Vec_Wrd_t **pvSimsIn, Vec_Str_t **pvSimsOut)
Definition giaGen.c:617
Here is the call graph for this function: