bool ClockedFlipFlopImplementation::getState( double dt, DigitalComponent::InputMap input, bool & q )
{
- if( RSFlipFlopImplementation::getState( dt, input, q ) )
- return true;
-
bool c = input.get_value("clock");
bool raisingEdge = c && !_clock;
_clock = c;
+ if( RSFlipFlopImplementation::getState( dt, input, q ) )
+ return true;
+
+
if( !raisingEdge ) return false; //signal no change
return onRaisingEdge( input, q );
}
q0 = q = get_output();
- if( _implementation->getState( dt, _input, q ) ) {
+ if( _implementation->getState( dt, _input, q ) && q0 != q ) {
set_output( q );
if(_debug) {
bool Logic::get_output() const
{
OutputMap::const_iterator it = _output.begin();
- return it != _output.end() ? (*it).second->getValue() : false;
+ bool q = it != _output.end() ? (*it).second->getValue() : false;
+ return _inverted ? !q : q;
}
void Logic::update( bool firstTime, double dt )