I recently was constructing boolean logic for all sorts of examples from Morris Mano's "Digital Logic and Circuit Design". I noticed that it is possible to construct a boolean logic wrt the inputs which depends on the current state. My question is that is it possible to construct a boolean logic which depend on the previous states too. For example, I wonder if we can construct a boolean logic such that the output will change only when one input changes from 0 to 1 in that time step. Suppose we have 2 inputs p and q, with an output z. When q transits from 0 to 1 ,if p = 0, z = 1 and if p = 1, z = 0. Otherwise, if q transits from 1 to 0, or remains the same as the previous state, no change in output occurs.
-
$\begingroup$ All knowledge of previous state is current state. You may differentiate between observable state (outputs) and internal state. $\endgroup$– greybeardCommented Sep 25, 2022 at 4:41
-
$\begingroup$ @greybeard ohh.. okay. Thanks. So is it possible that we can also include the information of the state which was previous to our prior state, without adding other variables? $\endgroup$– P. PatilCommented Sep 25, 2022 at 4:50
-
$\begingroup$ What do you mean by "construct a boolean logic"? $\endgroup$– D.W. ♦Commented Sep 25, 2022 at 4:59
-
$\begingroup$ @D.W. by "constructing a boolean logic", I mean generating a boolean expression ( for example, c = a + b ) $\endgroup$– P. PatilCommented Sep 25, 2022 at 5:01
-
$\begingroup$ I encourage you to edit the question accordingly. $\endgroup$– D.W. ♦Commented Sep 25, 2022 at 5:56
2 Answers
Designing pure functions (i.e. output depends only on input) is called combinational logic, and designing stateful logic (i.e. a finite state machine) is called sequential logic. If you're working your way through Mano's book, I promise you will get to it.
The traditional way to design a basic sequential circuit is to start with a state diagram, and assign each state to a binary number which is stored in flip-flops. You then design a combinational circuit whose inputs include the previous state and whose output includes the appropriate inputs to the flip-flops to transition it them to the desired state.
For this, you need the truth table for the flip-flops that you are using. As an example, this is the truth table for a JK flip-flop:
Q Q' | J K
---------+--------
0 0 | 0 X
0 1 | 1 X
1 0 | X 1
1 1 | X 0
So, for example, to transition from state 0
to state 1
, the J line must be 1, and the K signal can be anything. You can either "reset" (J=1, K=0) or
"toggle" (J=1, K=1); either will work. The previous state of the flip-flop is an input to the combinational circuit, and the J and K signals are outputs of the combinational circuit.
Pulse-triggered JK flip-flops are especially popular for basic sequential design because the pulse-triggered design avoid timing hazards, and the "don't care" inputs often make the combinational circuitry simpler.
There is an art in how to assign binary values to states. Sometimes, it is worth using more flip-flops to simplify the combinational circuitry, especially in high-speed circuits where edge-triggered flip-flops may be more appropriate than pulse-triggered ones to minimise propagation delay.
A final note on terminology: Older texts use the term "master-slave" to refer to pulse-triggered flip-flops. For obvious reasons, that phrase is falling out of favour. That older terminology describes how it has traditionally been built (with two RS flip flops), rather than what it actually does.
If we want to build a circuit that depends on previous states, the way we do that is to keep a copy of the previous state. That way, it is part of the current state. Indeed, the circuit can only depend on the input and current state; it can't depend on past information that hasn't been stored in the current state. This may involve introducing additional variables (or registers) to store that information about the past.