- A Logic Circuit Simulation Library in C++

(Topic Guide) The functions lcs::InputBus::notify and lcs::InputBus::stopNotification

[This topic guide is relevant for users desirous of implementing their own functional modules. Implementers of gate level modules and other users will, under normal circumstances, not need to use the functions lcs::InputBus::notify and lcs::InputBus::stopNotification.]

Every functional module will have to be driven by the input busses. The input busses drive a module by notifying it of certain line state events occuring on the lines of the busses. For this, a module has to register with each of the input busses using the function lcs::InputBus::notify. Module implementers should call this funtion in the constructor of their module class. It takes four arguments: 1. The first argument should be the module being registered, which in a module class constructor should be the this argument. 2. The second argument should be the line event which the bus should notify the module of. It should either be lcs::LINE_STATE_CHANGE, or lcs::LINE_POS_EDGE, or lcs::LINE_NEG_EDGE. 3. The third argument is the integer id of the port to which the bus is connected to. The input bus will use this id while notifying the event. 4. The last argument indicates the index of the line, occurrance of an event on which the module is seeking to be notified of. If a negetive value is passed as last argument, all lines in the bus will notify the module of line the event whenever it occurs. If a value beyond the allowed line index for the bus is passed, then an lcs::OutOfRangeException<int> is thrown.

A module which registers itself to be driven by an input bus should, without fail, de-register itself when it is getting destructed. Else, the input bus will try to drive a non-existant module leading to an immediate termination of the simulation with a segmentation fault. Module implementers should ensure de-registering by calling the function lcs::InputBus::stopNotification for all the input busses to the module. This function should be called with exactly the same arguments with which the call to lcs::InputBus::notify was made in the constructor of the module class.

A complete example of implementing a custom module can be found here.

Copyright © 2006, 2007 Siva Chandra