This section is under construction. See also the Examples of Using libLCS for more information.
1. Display the line states of lcs::Bus and lcs::InputBus objects
2. Setting and reading the line states of a bus
lcs::Bus<3> bus; cout << bus;
The above code will print xxx
on the stdout device. Each x
denotes the lcs::UNKNOWN
state of the 3 lines of the bus. Similarly, the following code will print 101
on the stdout device.
lcs::Bus<3> bus; bus = 5; cout << bus;
const
lcs::LineState variable, corresponding to the line index passed to the operator. Hence, the line state can be read as follows.
lcs::InputBus<8> bus; lcs::LineState bit0 = bus[0], bit5 = bus[5];
in case of a lcs::Bus object, a reference to a lcs::Line object corresponding to the line index passed to the operator is returned . The lcs::Line class is provided with overloaded assignment operators which facilitates an intuitive way to set the lines states of a lcs::Bus object as follows.
lcs::Bus<3> bus; b[0] = lcs::HIGH; b[1] = lcs::LOW;
The lcs::Line class and the lcs::LineState enumerations are also provided with bitwise logical operators which facilitate bitwise logic operations like in the following snippet (see the API reference of lcs::Line and lcs::LineState for more information):
lcs::Bus<5> bus; lcs::LineState result = (bus[0] & bus[1]) ^ (bus[2] | bus[3]) & (bus[4] ^ bus[0]);
An overloaded assignment operator for lcs::Bus class is provided using which one can assign integers directly to busses. The binary equivalent of the integer is mapped in a little-endian format onto the lines of the bus. Note that, throughout libLCS, the bus lines are conceptually understood to be little-endian with lower indices representing the LSB bits. An example of assigning integers to an lcs::Bus object is as follows.
lcs::Bus<4> bus; bus = 13; cout << bus;
The above code snippet will print 1101
on the stdout device.