- A Logic Circuit Simulation Library in C++

(Topic Guide) Reading bus line states

The lines states of lcs::Bus and lcs::InputBus objects can be read using the overloaded operator[] of the classes lcs::InputBus and lcs::Bus. The usage is very similar to how one would read the element values from a standard data type array. Since busses of type lcs::InputBus are readonly busses, one cannot set the bus line states of these busses. However, one can use the operator [] to set the line states of lcs::Bus objects (see this for more information on setting bus line states).

An example of reading the line states from the lines of a bus is as follows.

lcs::Bus<8> bus(128); // The bus lines are initialised to a binary equivalent of the decimal integer 
                      // 128.
lcs::BitBuff<1> bits; // We shall use this bit-buffer object as a temporary storage facility.

bits[0] = bus[0], bits[0] = bus[5]; // Reading the line states of the bus using the overloaded operator 
                                    // \p lcs::Bus::operator[].

Copyright © 2006, 2007 Siva Chandra