ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
demo.c
Go to the documentation of this file.
1
20
21#include <stdio.h>
22#include <time.h>
23
27
28#if defined(ABC_NAMESPACE)
29namespace ABC_NAMESPACE
30{
31#elif defined(__cplusplus)
32extern "C"
33{
34#endif
35
36// procedures to start and stop the ABC framework
37// (should be called before and after the ABC procedures are called)
38void Abc_Start();
39void Abc_Stop();
40
41// procedures to get the ABC framework and execute commands in it
43
45int Cmd_CommandExecute( Abc_Frame_t * pAbc, const char * sCommand );
46
47#if defined(ABC_NAMESPACE)
48}
49using namespace ABC_NAMESPACE;
50#elif defined(__cplusplus)
51}
52#endif
53
57
73int main( int argc, char * argv[] )
74{
75 // parameters
76 int fUseResyn2 = 0;
77 int fPrintStats = 1;
78 int fVerify = 1;
79 // variables
80 Abc_Frame_t * pAbc;
81 char * pFileName;
82 char Command[1000];
83 clock_t clkRead, clkResyn, clkVer, clk;
84
86 // get the input file name
87 if ( argc != 2 )
88 {
89 printf( "Wrong number of command-line arguments.\n" );
90 return 1;
91 }
92 pFileName = argv[1];
93
95 // start the ABC framework
96 Abc_Start();
98
99clk = clock();
101 // read the file
102 sprintf( Command, "read %s", pFileName );
103 if ( Cmd_CommandExecute( pAbc, Command ) )
104 {
105 fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
106 return 1;
107 }
108
110 // balance
111 sprintf( Command, "balance" );
112 if ( Cmd_CommandExecute( pAbc, Command ) )
113 {
114 fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
115 return 1;
116 }
117clkRead = clock() - clk;
118
120 // print stats
121 if ( fPrintStats )
122 {
123 sprintf( Command, "print_stats" );
124 if ( Cmd_CommandExecute( pAbc, Command ) )
125 {
126 fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
127 return 1;
128 }
129 }
130
131clk = clock();
133 // synthesize
134 if ( fUseResyn2 )
135 {
136 sprintf( Command, "balance; rewrite -l; refactor -l; balance; rewrite -l; rewrite -lz; balance; refactor -lz; rewrite -lz; balance" );
137 if ( Cmd_CommandExecute( pAbc, Command ) )
138 {
139 fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
140 return 1;
141 }
142 }
143 else
144 {
145 sprintf( Command, "balance; rewrite -l; rewrite -lz; balance; rewrite -lz; balance" );
146 if ( Cmd_CommandExecute( pAbc, Command ) )
147 {
148 fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
149 return 1;
150 }
151 }
152clkResyn = clock() - clk;
153
155 // print stats
156 if ( fPrintStats )
157 {
158 sprintf( Command, "print_stats" );
159 if ( Cmd_CommandExecute( pAbc, Command ) )
160 {
161 fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
162 return 1;
163 }
164 }
165
167 // write the result in blif
168 sprintf( Command, "write_blif result.blif" );
169 if ( Cmd_CommandExecute( pAbc, Command ) )
170 {
171 fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
172 return 1;
173 }
174
176 // perform verification
177clk = clock();
178 if ( fVerify )
179 {
180 sprintf( Command, "cec %s result.blif", pFileName );
181 if ( Cmd_CommandExecute( pAbc, Command ) )
182 {
183 fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
184 return 1;
185 }
186 }
187clkVer = clock() - clk;
188
189 printf( "Reading = %6.2f sec ", (float)(clkRead)/(float)(CLOCKS_PER_SEC) );
190 printf( "Rewriting = %6.2f sec ", (float)(clkResyn)/(float)(CLOCKS_PER_SEC) );
191 printf( "Verification = %6.2f sec\n", (float)(clkVer)/(float)(CLOCKS_PER_SEC) );
192
194 // stop the ABC framework
195 Abc_Stop();
196 return 0;
197}
198
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
Definition abcapis.h:38
ABC_DLL void Abc_Start()
FUNCTION DECLARATIONS ///.
Definition mainLib.c:52
ABC_DLL void Abc_Stop()
Definition mainLib.c:76
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:193
int main(int argc, char *argv[])
FUNCTION DEFINITIONS ///.
Definition demo.c:73
int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:193
Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
void Abc_Start()
DECLARATIONS ///.
Definition mainLib.c:52
void Abc_Stop()
Definition mainLib.c:76
char * sprintf()