Download project. The report

Transcript
76
A Graph Matching Search Algorithm for an Electronic Circuit Repository
The cr directory includes a Makefile that can be used to build the circuit repository library, some
demonstration applications, and the test cases. Entering make in the cr directory will start this
process. It is possible to run the automatic tests by entering make run tests. The test programs
will terminate with an error message if any test fails. The final test carries out circuit comparisons
on random circuits, and will run until Control-C is pressed. This is the test described in Section
3.3.4.
B.3
Using the circuit repository software from a C program
The circuit repository software can be used from your program by copying all source and header files
into an appropriate place and adding them to your build process. However, this is not recommended
unless your program is written in C++. The recommended method for C programs is as follows:
1. Add a line to the main Makefile in your program so that the Makefile in the cr directory is
called as part of your build process.
When the cr Makefile is called, a code library called libcr.a is produced in the cr directory.
This contains all of the circuit repository code, including a C interface that will allow all the
features of the circuit repository to be used from C.
2. Add the libcr.a code library to the linker command for your program so that the circuit
repository software is linked in with your code.
3. Add the linker switch -lstdc++, so that the standard C++ code library is included in the
link process.
4. Add the cr/include directory to your include path, so that the interface.h header file can
be included by your programs. (The source of interface.h can be seen on page 96).
5. In all the modules where you wish to use circuit repository functions, the file interface.h
should be included. The functions that are provided by this header are documented in the
following section.
B.4
A note on handles
With only two exceptions, the circuit repository interface functions require you to supply a handle,
of type CR Handle. You should allocate CR Handle as a variable, and pass it by reference:
CR_Handle handle ;
rc = CR_Create_Handle ( & handle ) ;
Handles must be initialised before any other use by CR Create Handle (page 83), and should be
destroyed by CR Free Handle (page 85) after the last use.
B.5
A note on error codes
All of the functions provided by the circuit repository return an error code of type CR Error Code.
The error code indicates success or failure. Table B.1 lists all the possible error codes and their
meanings. If you wish to report error codes to the user in plain English, you may want to consider
passing them to CR Get Error String (page 87), which translates them into text along with a short
explanation of the possible cause of each.