abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
demo.c File Reference
#include <stdio.h>
#include <time.h>

Go to the source code of this file.

Functions

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

Function Documentation

void* Abc_FrameGetGlobalFrame ( )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 593 of file mainFrame.c.

594 {
595  if ( s_GlobalFrame == 0 )
596  {
597  // start the framework
599  // perform initializations
601  }
602  return s_GlobalFrame;
603 }
static ABC_NAMESPACE_IMPL_START Abc_Frame_t * s_GlobalFrame
DECLARATIONS ///.
Definition: mainFrame.c:35
Abc_Frame_t * Abc_FrameAllocate()
Definition: mainFrame.c:137
void Abc_FrameInit(Abc_Frame_t *pAbc)
FUNCTION DEFINITIONS ///.
Definition: mainInit.c:94
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

]

PARAMETERS ///.

INCLUDES ///.

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
60  pAbc = Abc_FrameGetGlobalFrame();
61  // source the resource file
62 // Abc_UtilsSource( pAbc );
63 }
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
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;
79  pAbc = Abc_FrameGetGlobalFrame();
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:179
void Abc_FrameEnd(Abc_Frame_t *pAbc)
Definition: mainInit.c:128
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
int Cmd_CommandExecute ( void *  pAbc,
char *  sCommand 
)
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 56 of file demo.c.

57 {
58  // parameters
59  int fUseResyn2 = 0;
60  int fPrintStats = 1;
61  int fVerify = 1;
62  // variables
63  void * pAbc;
64  char * pFileName;
65  char Command[1000];
66  clock_t clkRead, clkResyn, clkVer, clk;
67 
68  //////////////////////////////////////////////////////////////////////////
69  // get the input file name
70  if ( argc != 2 )
71  {
72  printf( "Wrong number of command-line arguments.\n" );
73  return 1;
74  }
75  pFileName = argv[1];
76 
77  //////////////////////////////////////////////////////////////////////////
78  // start the ABC framework
79  Abc_Start();
80  pAbc = Abc_FrameGetGlobalFrame();
81 
82 clk = clock();
83  //////////////////////////////////////////////////////////////////////////
84  // read the file
85  sprintf( Command, "read %s", pFileName );
86  if ( Cmd_CommandExecute( pAbc, Command ) )
87  {
88  fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
89  return 1;
90  }
91 
92  //////////////////////////////////////////////////////////////////////////
93  // balance
94  sprintf( Command, "balance" );
95  if ( Cmd_CommandExecute( pAbc, Command ) )
96  {
97  fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
98  return 1;
99  }
100 clkRead = clock() - clk;
101 
102  //////////////////////////////////////////////////////////////////////////
103  // print stats
104  if ( fPrintStats )
105  {
106  sprintf( Command, "print_stats" );
107  if ( Cmd_CommandExecute( pAbc, Command ) )
108  {
109  fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
110  return 1;
111  }
112  }
113 
114 clk = clock();
115  //////////////////////////////////////////////////////////////////////////
116  // synthesize
117  if ( fUseResyn2 )
118  {
119  sprintf( Command, "balance; rewrite -l; refactor -l; balance; rewrite -l; rewrite -lz; balance; refactor -lz; rewrite -lz; balance" );
120  if ( Cmd_CommandExecute( pAbc, Command ) )
121  {
122  fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
123  return 1;
124  }
125  }
126  else
127  {
128  sprintf( Command, "balance; rewrite -l; rewrite -lz; balance; rewrite -lz; balance" );
129  if ( Cmd_CommandExecute( pAbc, Command ) )
130  {
131  fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
132  return 1;
133  }
134  }
135 clkResyn = clock() - clk;
136 
137  //////////////////////////////////////////////////////////////////////////
138  // print stats
139  if ( fPrintStats )
140  {
141  sprintf( Command, "print_stats" );
142  if ( Cmd_CommandExecute( pAbc, Command ) )
143  {
144  fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
145  return 1;
146  }
147  }
148 
149  //////////////////////////////////////////////////////////////////////////
150  // write the result in blif
151  sprintf( Command, "write_blif result.blif" );
152  if ( Cmd_CommandExecute( pAbc, Command ) )
153  {
154  fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
155  return 1;
156  }
157 
158  //////////////////////////////////////////////////////////////////////////
159  // perform verification
160 clk = clock();
161  if ( fVerify )
162  {
163  sprintf( Command, "cec %s result.blif", pFileName );
164  if ( Cmd_CommandExecute( pAbc, Command ) )
165  {
166  fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
167  return 1;
168  }
169  }
170 clkVer = clock() - clk;
171 
172  printf( "Reading = %6.2f sec ", (float)(clkRead)/(float)(CLOCKS_PER_SEC) );
173  printf( "Rewriting = %6.2f sec ", (float)(clkResyn)/(float)(CLOCKS_PER_SEC) );
174  printf( "Verification = %6.2f sec\n", (float)(clkVer)/(float)(CLOCKS_PER_SEC) );
175 
176  //////////////////////////////////////////////////////////////////////////
177  // stop the ABC framework
178  Abc_Stop();
179  return 0;
180 }
void Abc_Start()
DECLARATIONS ///.
Definition: mainLib.c:52
char * sprintf()
int Cmd_CommandExecute(void *pAbc, char *sCommand)
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
void Abc_Stop()
Definition: mainLib.c:76