Next: , Up: Introduction to libLCS

3.1 Basics

In this section, we will go over some of the basic information and concepts which one needs to know inorder to use libLCS correctly. We will assume that the reader has successfully downloaded, built and installed the static library for libLCS in the way presented in the Preliminaries chapter.

3.1.1 The lcs/lcs.h file and the namespace lcs

The only file which a user needs to include inorder to use libLCS is the lcs/lcs.h header file. However, this file includes everything that is there in libLCS. Hence, the consequent compilation process can end up being time consuming. To improve on this, one will have to include only those header files which are relevant to his/her application. Refer to the subsquent sections/chapters to learn about the relevant header files for any particular feature of libLCS.

Another basic point to note is that all constructs in libLCS are defined under the namespace lcs. Further in this userguide, you will notice that the libLCS constructs are illustrated without using the namespace lcs. It should be understood in such cases that a using namespace lcs; statement is being assumed.

3.1.2 Logic States

Like Verilog, libLCS also supports four-state logic. Logic states are provided as an enumerated type LineState. This enumeration is defined is the header file lcs/linestate.h. The following is the description of the four enumerated values corresponding to the four logic states.

Corresponds to the logic state '0' or false.
Corresponds to the logic state '1' or true.
Corresponds to the logic state 'x' or an unknown state.
Corresponds to the logic state 'z' or a high impedence on the line.

3.1.3 Modules and Busses

All circuit elements, which have an input and an output, will be called as modules when reffered to in the context of libLCS. Since logic gates and flipflops have a well defined input and output, they are also called as modules in libLCS (unlike in Verilog where logic gates are reffered to as primitives). Connections between modules are made using constructs called 'busses' ('bus' in singular). They are very similar to the real world abstract concept of a 'bus' as being a carrier of n-bit data for some n. You can now understand as to why the logic states, as described above, are enumerated under an enumerated type with name LineState - they represent the four possible states which the bus lines can take.

3.1.4 Compiling libLCS applications

(This section is relevant only for users of the GNU g++ compiler. Other users should perform corresponding steps as per their choice of a C++ compiler.)

If you have installed the libLCS static library as described in Installing libLCS section, then you will have to link to the static library during compilation in the usual way. For example, if you have implemented your libLCS application in a file named myapp.cpp, then you will have to build your application binary using the following command.
     g++ -o myapp myapp.cpp -lLCS

If you have installed libLCS static library into a different directory, then you should remember to link to the static library by adding the path to the static library file into the list of standard linker paths. This is done in this way:

     g++ -o myapp myapp.cpp -L"$PATH_TO_LIBLCS_STATIC_LIBRAY" -lLCS

It is assumed in the above command that the static library for libLCS has been named libLCS.a.