ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
demo.c File Reference
#include <stdio.h>
#include <time.h>
Include dependency graph for demo.c:

Go to the source code of this file.

Typedefs

typedef struct Abc_Frame_t_ Abc_Frame_t
 

Functions

void Abc_Start ()
 DECLARATIONS ///.
 
void Abc_Stop ()
 
Abc_Frame_tAbc_FrameGetGlobalFrame ()
 
int Cmd_CommandExecute (Abc_Frame_t *pAbc, const char *sCommand)
 
int main (int argc, char *argv[])
 FUNCTION DEFINITIONS ///.
 

Typedef Documentation

◆ Abc_Frame_t

typedef struct Abc_Frame_t_ Abc_Frame_t

Definition at line 42 of file demo.c.

Function Documentation

◆ Abc_FrameGetGlobalFrame()

Abc_Frame_t * Abc_FrameGetGlobalFrame ( )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 643 of file mainFrame.c.

644{
645 if ( s_GlobalFrame == 0 )
646 {
647 // start the framework
648 s_GlobalFrame = Abc_FrameAllocate();
649 // perform initializations
650 Abc_FrameInit( s_GlobalFrame );
651 }
652 return s_GlobalFrame;
653}
Abc_Frame_t * Abc_FrameAllocate()
Definition mainFrame.c:162
void Abc_FrameInit(Abc_Frame_t *pAbc)
FUNCTION DEFINITIONS ///.
Definition mainInit.c:106
Here is the caller graph for this function:

◆ Abc_Start()

void Abc_Start ( )

DECLARATIONS ///.

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

FileName [demo.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [ABC as a static library.]

Synopsis [A demo program illustrating the use of ABC as a static library.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id
demo.c,v 1.00 2005/11/14 00:00:00 alanmi Exp

]

INCLUDES ///.

FUNCTION DECLARATIONS ///.

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

FileName [main.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [The main package.]

Synopsis [Here everything starts.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Initialization procedure for the library project.]

Description [Note that when Abc_Start() is run in a static library project, it does not load the resource file by default. As a result, ABC is not set up the same way, as when it is run on a command line. For example, some error messages while parsing files will not be produced, and intermediate networks will not be checked for consistancy. One possibility is to load the resource file after Abc_Start() as follows: Abc_UtilsSource( Abc_FrameGetGlobalFrame() );]

SideEffects []

SeeAlso []

Definition at line 52 of file mainLib.c.

53{
54 Abc_Frame_t * pAbc;
55 // added to detect memory leaks:
56#if defined(_DEBUG) && defined(_MSC_VER)
57 _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
58#endif
59 // start the glocal frame
61 // source the resource file
62// Abc_UtilsSource( pAbc );
63}
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
Definition abcapis.h:38
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
Here is the caller graph for this function:

◆ Abc_Stop()

void Abc_Stop ( )

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

Synopsis [Deallocation procedure for the library project.]

Description []

SideEffects []

SeeAlso []

Definition at line 76 of file mainLib.c.

77{
78 Abc_Frame_t * pAbc;
80 // perform uninitializations
81 Abc_FrameEnd( pAbc );
82 // stop the framework
83 Abc_FrameDeallocate( pAbc );
84}
void Abc_FrameDeallocate(Abc_Frame_t *p)
Definition mainFrame.c:204
void Abc_FrameEnd(Abc_Frame_t *pAbc)
Definition mainInit.c:145
Here is the caller graph for this function:

◆ Cmd_CommandExecute()

int Cmd_CommandExecute ( Abc_Frame_t * pAbc,
const char * sCommand )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 193 of file cmdApi.c.

194{
195 int fStatus = 0, argc, loop;
196 const char * sCommandNext;
197 char **argv;
198
199 if ( !pAbc->fAutoexac && !pAbc->fSource )
200 Cmd_HistoryAddCommand(pAbc, sCommand);
201 sCommandNext = sCommand;
202 do
203 {
204 if ( sCommandNext[0] == '#' && Cmd_CommandHandleSpecial( pAbc, sCommandNext ) )
205 break;
206 sCommandNext = CmdSplitLine( pAbc, sCommandNext, &argc, &argv );
207 loop = 0;
208 fStatus = CmdApplyAlias( pAbc, &argc, &argv, &loop );
209 if ( fStatus == 0 )
210 fStatus = CmdCommandDispatch( pAbc, &argc, &argv );
211 CmdFreeArgv( argc, argv );
212 }
213 while ( fStatus == 0 && *sCommandNext != '\0' );
214 return fStatus;
215}
int Cmd_CommandHandleSpecial(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:99
int CmdCommandDispatch(Abc_Frame_t *pAbc, int *argc, char ***argv)
Definition cmdUtils.c:97
const char * CmdSplitLine(Abc_Frame_t *pAbc, const char *sCommand, int *argc, char ***argv)
Definition cmdUtils.c:185
int CmdApplyAlias(Abc_Frame_t *pAbc, int *argc, char ***argv, int *loop)
Definition cmdUtils.c:271
void CmdFreeArgv(int argc, char **argv)
Definition cmdUtils.c:489
void Cmd_HistoryAddCommand(Abc_Frame_t *pAbc, const char *command)
FUNCTION DEFINITIONS ///.
Definition cmdHist.c:50
Here is the caller graph for this function:

◆ main()

int main ( int argc,
char * argv[] )

FUNCTION DEFINITIONS ///.

GLOBAL VARIABLES ///.

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

Synopsis [The main() procedure.]

Description [This procedure compiles into a stand-alone program for DAG-aware rewriting of the AIGs. A BLIF or PLA file to be considered for rewriting should be given as a command-line argument. Implementation of the rewriting is inspired by the paper: Per Bjesse, Arne Boralv, "DAG-aware circuit compression for formal verification", Proc. ICCAD 2004.]

SideEffects []

SeeAlso []

Definition at line 73 of file demo.c.

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}
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()
Here is the call graph for this function: