Next: System Time and Sequential Circuit Elements, Previous: A Simple Example, Up: Introduction to libLCS
Logic gates are provided as primitives in Verilog. In libLCS, all circuit elements which have well defined sets of inputs and outputs are called Modules. Since logic gates also have well defined inputs and outputs, they are also treated as modules.
All logic gate modules in libLCS (except the NOT gate module) are provided as class templates requiring two template parameters. The first template argument denotes the number of inputs to the gate, and the second template parameter denotes the input to output propogation delay of the gate. Since a NOT gate can have only one input, it is provided as a class template taking only one template parameter which represents the input to output propogation delay of the NOT gate. The following is the list of all logic gate class templates provided in libLCS.
template<unsigned int width = 1, unsigned int delay = 0> class And;
template<unsigned int width = 1, unsigned int delay = 0> class Or;
template<unsigned int width = 1, unsigned int delay = 0> class Nand;
template<unsigned int width = 1, unsigned int delay = 0> class Nor;
template<unsigned int width = 1, unsigned int delay = 0> class Xor;
template<unsigned int delay = 0> class Not;
All logic gate module constructors require two arguments. The first argument represents the output bus, and the second argument represents the input bus. For example, if one is desirous of initialising a 5 input XOR gate with zero propogation delay, then he/she should do the following.
Bus<5> inBus; Bus<1> outBus; Xor<5> xorGate(outBus, inBus); // The template parameter for delay is not explicitly mentioned. // Hence, the default value of zero is implied.
Following is a list of all the logic gate modules and the corresponding header file in which they are defined.
lcs/and.h
lcs/or.h
lcs/nand.h
lcs/nor.h
lcs/not.h
lcs/xor.h