ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcRunGen.c
Go to the documentation of this file.
1
20
21#include "base/abc/abc.h"
22#include "base/main/main.h"
23#include "base/cmd/cmd.h"
24#include "misc/util/utilTruth.h"
25
26#ifdef WIN32
27#include <process.h>
28#define unlink _unlink
29#else
30#include <unistd.h>
31#endif
32
34
38
42
54int Abc_NtkRunGenOne( Abc_Ntk_t * p, char * pScript )
55{
58 {
60 {
61 Abc_Print( 1, "Something did not work out with the command \"%s\".\n", pScript );
62 return 0;
63 }
64 }
65 else
66 {
69 {
70 Abc_Print( 1, "Something did not work out with the command \"%s\".\n", pScript );
71 return 0;
72 }
74 }
76 return Abc_NtkNodeNum(pTemp);
77}
78void Acb_NtkRunGen( int nInputs, int nMints, int nFuncs, int Seed, int fVerbose, char * pScript )
79{
80 abctime clkStart = Abc_Clock();
81 Vec_Int_t * vNodes = Vec_IntAlloc( 1000 );
82 int i, k, nNodes, nWords = Abc_TtWordNum(nInputs);
83 word * pFun = ABC_ALLOC( word, nWords );
84 Abc_Ntk_t * pNtkNew; char * pTtStr, * pSop;
85 Abc_Random(1);
86 for ( i = 0; i < 10+Seed; i++ )
87 Abc_Random(0);
88 printf( "Synthesizing %d random %d-variable functions with %d positive minterms using script \"%s\".\n", nFuncs, nInputs, nMints, pScript );
89 for ( i = 0; i < nFuncs; i++ )
90 {
91 if ( nMints == 0 )
92 for ( k = 0; k < nWords; k++ )
93 pFun[k] = Abc_RandomW(0);
94 else {
95 Abc_TtClear( pFun, nWords );
96 for ( k = 0; k < nMints; k++ ) {
97 int iMint = 0;
98 do iMint = Abc_Random(0) % (1 << nInputs);
99 while ( Abc_TtGetBit(pFun, iMint) );
100 Abc_TtSetBit( pFun, iMint );
101 }
102 }
103 pTtStr = ABC_CALLOC( char, nInputs > 2 ? (1 << (nInputs-2)) + 1 : 2 );
104 Extra_PrintHexadecimalString( pTtStr, (unsigned *)pFun, nInputs );
105 pSop = Abc_SopFromTruthHex( pTtStr );
106 pNtkNew = Abc_NtkCreateWithNode( pSop );
107 nNodes = Abc_NtkRunGenOne( pNtkNew, pScript );
108 if ( nNodes >= Vec_IntSize(vNodes) )
109 Vec_IntSetEntry( vNodes, nNodes, 0 );
110 Vec_IntAddToEntry( vNodes, nNodes, 1 );
111
112 if ( fVerbose ) {
113 printf( "Function %4d : ", i );
114 printf( "Random function has %d positive minterms ", nMints );
115 printf( "and maps into %d nodes.\n", nNodes );
116 if ( fVerbose )
117 printf( "Truth table : %s\n", pTtStr );
118 }
119 ABC_FREE( pTtStr );
120 ABC_FREE( pSop );
121 }
122 Vec_IntForEachEntry( vNodes, i, k )
123 if ( i )
124 printf( "Nodes %3d : Functions %3d Ratio %5.2f %%\n", k, i, 100.0*i/nFuncs );
125 ABC_FREE( pFun );
126 Abc_PrintTime( 0, "Total time", Abc_Clock() - clkStart );
127}
128
132
133
135
int nWords
Definition abcNpn.c:127
void Acb_NtkRunGen(int nInputs, int nMints, int nFuncs, int Seed, int fVerbose, char *pScript)
Definition abcRunGen.c:78
ABC_NAMESPACE_IMPL_START int Abc_NtkRunGenOne(Abc_Ntk_t *p, char *pScript)
DECLARATIONS ///.
Definition abcRunGen.c:54
ABC_DLL char * Abc_SopFromTruthHex(char *pTruth)
Definition abcSop.c:1060
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL Abc_Ntk_t * Abc_NtkCreateWithNode(char *pSop)
Definition abcNtk.c:1333
word Abc_RandomW(int fReset)
Definition utilSort.c:1022
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
unsigned Abc_Random(int fReset)
Definition utilSort.c:1004
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
ABC_DLL void Abc_FrameSetBatchMode(int Mode)
Definition mainFrame.c:111
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition mainFrame.c:327
ABC_DLL void Abc_FrameReplaceCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
Definition mainFrame.c:538
ABC_DLL int Abc_FrameIsBatchMode()
Definition mainFrame.c:110
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:193
Cube * p
Definition exorList.c:222
void Extra_PrintHexadecimalString(char *pString, unsigned Sign[], int nVars)
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54