Smatchcube's website 🌍

Exercise 3.31

If we don’t call the procedure during the creation of our gates the initial state of our digital circuit will be wrong.

Let’s see how this can lead to bad results with the example of the half-adder.

Suppose we have these wires:

We monitor the wires e and c:

We create the half-adder:

Then we start the simulation with (propagate) with all signals set to 0 (default value). This message is printed:

We see that the signal of wire e is correctly set to 1 because the invert-output procedure was called when we created the inverter.

If we now set the signal a to 1 we get the desired output:

The printed result is s 13 New-value = 1 because setting signal of wire a to 1 triggered the or-gate then the end-gate resulting in setting the signal of wire s to 1.

Now let’s suppose that accept-action-procedure! was defined as

Then when the inverter was created the invert-output procedure would not be called and the signal of wire e would not be set to 1 as intended. The initial state of the circuit would be wrong so setting the signal of wire a to 1 as we did would not result in signal of wire s to change to 1.