Random behavior

If you have something to say about LogicCircuit program or you know how to improve it please share it here.
Post Reply
ruifmf
Posts: 1
Joined: Fri Oct 11, 2019 1:16 pm

Random behavior

Post by ruifmf »

Hi.
mystatehasnotbeendefined.png
mystatehasnotbeendefined.png (9.64 KiB) Viewed 8330 times
I believe the led should not be lit at power on.
In fact, it is only lit at power on sometimes. It's initial state is random.
I believe there's a uninitialized variable somewhere.

Rui
User avatar
admin
Site Admin
Posts: 407
Joined: Sun Jun 14, 2009 10:53 pm
Contact:

Re: Random behavior

Post by admin »

Hi,
This is what I'd expect from this circuit in the real life. So the program just simulates it. Usually all flip-flops have asynchronous reset or/and set inputs to set them in the initial state after power is on. You can use some hacks to detect the power on moments and reset you circuits. Please read this for more details: viewtopic.php?f=3&t=3
EliasHasle
Posts: 3
Joined: Tue Jul 04, 2023 12:24 am

Re: Random behavior

Post by EliasHasle »

The output state of this circuit is not determined by its inputs. Let's trim away the two input gates with constant output (the AND and the NOT) and just consider the ones involved in the feedback loop. The lowermost input to the AND gate is 1. The lowermost input to the OR gate is 0. We name the output X, and can set up the following equation:

X = (X OR 0) AND 1

Indeed, the second AND gate can also be removed, as AND 1 is redundant:

X = X OR 0

The OR gate can also be removed, as OR 0 is also redundant:

X = X

This tells us nothing about X. In other words, X is free, and the output will be stable whether X starts at 0 or 1.

In real life, X is neither 0 nor 1 when the circuit is powered up, but the physical implementation of logical gates favors 0 and 1. Therefore, any initial, induced or spontaneous imbalance will quickly lead to one of the two stable states.

A different scenario arises when there is no self-consistent X, such as for an inverter (a NOT gate) fed back on itself:

X = NOT X

This is self-contradictory and leads to oscillations in digital logic circuits. If NOT(X) were a physical implementation of 1-X, there would be a valid fixed point at X=0.5 *, but again, digital logic circuits strongly favors the high and low states.

* Corresponding to a truth value of 0.5 for "This sentence is false.". ;-)
Post Reply