Professional Documents
Culture Documents
Basic Logic Design
Basic Logic Design
i. AND Gate
The symbol and truth table for an AND gate is shown below:
A B A.B
0 0 0
0 1 0
1 0 0
1 1 1
Abbreviations: often a ‘.’ (dot) is used to signify the AND operator when writing Boolean
equations.
A B A+B
0 0 0
0 1 1
1 0 1
1 1 1
Summary: If inputs A OR B are high (or both) then the output is high
Abbreviations: often a ‘+’ is used to signify the OR operator when writing Boolean
equations.
iii. NOT Gate
The symbol and truth table for an NOT gate is shown below:
A A
0 0
0 1
1
2
Summary: Output is NOT what the input is. They are also called 'inverters'.
Abbreviations: Many. Sometimes a line above the thing that is being notted, sometimes a
dash ‘'’ and sometimes an ‘!’ exclamation mark
i. NAND Gate
Made by combining an AND gate and a NOT gate. The equivalent circuit is:
The symbol and truth table for an NAND gate is shown below:
A B A .B
0 0 1
0 1 1
1 0 1
1 1 0
The symbol and truth table for an NAND gate is shown below:
A B A+ B
0 0 1
0 1 0
1 0 0
1 1 0
A B A⊕ B
0 0 0
0 1 1
1 0 1
1 1 0
Summary: A ⊕ B = A .B + A .B
Abbreviations: XOR gates are represented with a ⊕ symbol.
Remember that the optimal solution is not always the solution with the fewest gates. In terms of
cost the optimal solution is generally that solution which has the fewest logic chips, assuming that
the cost of logic chips does not differ greatly for different logic gates. (A chip which contains four
AND gates costs roughly the same as a chip with four OR gates.) This has not always been the case.
A + B = A .B
A .B = A + B
The map takes the form of a table laid out as shown below. The order of the possible variable states
is important. A Grey code must be used. A Grey code is a code in which at most one bit changes in
successive numbers.
CD
00 01 11 10
AB
00
01
11
10
All the combinations which result in'1' as the result are marked in the table and grouped together.
See the class example for further information on grouping and reduction.
i. Examples
Reduce the following equation using both Boolean algebra and Karnaugh Maps to a circuit with the
fewest number of gates.
Y = A .B .C + A .B .C + B .C + A .B
Y = A .B .C + A .B .C + B .C + A .B
Y = A .B .C + A .B .C + A .B .C + A .B .C + A .B .C + A .B .C (Expanding all terms by multiplyin g by
1. i.e. (A + A ))
Y = A .B .C + B .( A .C + A .C + A .C + A .C + A .C ) (Take out the common factor)
( ( ) (
Y = A .B .C + B . A . C + C + A . C + C + C )) (Group terms and take out the common factors)
Y = A .B .C + B (A + A) (Simplify)
Y = A .B .C + B
Y will equal 1 whenever any one of its terms equals 1. Therefore find the values of A, B and C that
make any term equal 1.
AB
00 01 11 10
C
0 1 1
1 1 1 1
Y = A .C + B
Assume that the following logic chips exist and cost the same:
CD4081 quad two input AND gate
CD4011 quad two input NAND gate
CD4071 quad two input OR gate
CD4001 quad two input NOR gate
CD4069 hex inverter
Our solution above gives would need 1 OR gate, 1 AND gate and 1 inverter. This amounts to 3
chips that would be needed.
We could replace the AND gate with a NAND gate followed by an inverter. We can make an
inverter from a NAND gate by tying one input permanently high. Thus we can say:
Y = A .C + B
( ) ( )
= A .C .1 + B .1
This circuit would need one quad NAND chip and one quad OR chip.
If you worked for a large company producing 20000 gadgets per month then this saving alone
would justify your salary...
Exercise:
1. Draw circuit diagrams of the above solutions and check that you are satisfied with their
correctness.
i. Multiplexers
These are basically selector devices. They have k inputs and one output. They have log2k selection
inputs. This is shown for the case of a multiplexer with 4 inputs (k = 4). The action of the
multiplexer can be summarised as follows:
0 1 Output = In1
1 0 Output = In2
1 1 Output = In3
Exercises:
1. Look at the datasheets for the following chips: 74HC157;74HC153;74HC356
2. Are multiplexers combinational or sequential? Why?
ii. Decoders
These are chips which decode a binary number into a '1 of n' output. Typically a decoder has n
inputs and 2n outputs. One (only one) of the outputs will go high depending on the code present on
the input lines. The truth table for a 3 to 8 line decoder is shown here:
In2 In1 In0 Out7 Out6 Out5 Out4 Out3 Out2 Out1 Out0
0 0 0 0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 1 0
0 1 0 0 0 0 0 0 1 0 0
0 1 1 0 0 0 0 1 0 0 0
1 0 0 0 0 0 1 0 0 0 0
1 0 1 0 0 1 0 0 0 0 0
1 1 0 0 1 0 0 0 0 0 0
1 1 1 1 0 0 0 0 0 0 0
Exercises:
1. Look at the datasheets for the following chips: 74HC137; 74HC42; 74HC139
2. Are decoders combinational or sequential? Why?
iii. Adders
This is a circuit which adds two bits together. Basic Boolean arithmetic gives us:
A 0 0 1 1
+B 0 1 0 1
SUM 0 1 1 0 and 1 is carried to the next significant bit
If you examine the answer bit you will see that it is simply the XOR of the input bits. If you
examine the carry bit you will see that it is simply the AND of the input bits. The circuit that
implements this is as follows:
If you look carefully at this circuit you will see that it has one little problem. If you are
implementing a proper addition then you will typically have two inputs, as well as a carry input, and
you will have two outputs, sum and carry. The above circuit does not have any carry input. For this
reason it is called a half adder.
A full adder is a circuit which has three inputs, one of which is a carry input, and it has two outputs,
sum and carry. A full adder may be made by connecting two half adders as follows:
Intuitively this makes sense; the carry in bit is added to the result of the addition of the two input
bits.
In order to make a multi-bit wide adder a series of full adders can be cascaded. The carry outputs
are fed into the3 carry inputs of the next most significant adder. Cascading gates can lead to poor
circuit performance (gates are not infinitely fast) and so other schemes are used in more
sophisticated adders. These schemes generally rely on the fact that the addition of two numbers is a
combinational operation and can be modeled with a truth table, Boolean equations or a Karnaugh
map.
Exercises:
1. Look at the datasheet for 74HC283
2. Draw a four bit wide adder based on full-adders
3. Design a 2 bit wide adder using a Karnaugh map. Your circuit have a 2 bit plus carry
output. You will need to use a few Karnaugh maps.
This device has memory. If you pull S low then Q will go high and stay high until R is pulled low.
This circuit forms a basis for other flip-flop types.
Exercise:
1. What is the difference between the NOR and the NAND implementation?
On the edge of the clock pulse (in this case the positive edge), the input D, is transferred to the
output Q and held there. Typically a Q output is also available. In addition there are set and reset
inputs which can be used to place the flip-flop into a known state.
Exercise:
1. Look up the datasheet for CD4013 and 74HC74.
A JK flip flop operates in a similar manner to a D type, except that it has two additional inputs, J
and K. If the J input is asserted then the flip-flop performs a 'set' operation. If the K input is asserted
then the flip-flop performs a 'reset' operation. If both J and K are asserted then the output simply
toggles state. A JK flip flop is shown here:
Many JK flip flops also have conventional set and reset inputs.
vii. Counters
If you take some D flip flops and connect them as follows you get a basic counter:
Other variations are also common. up/down counters are available and presettable counters are also
available. Some counters (e.g. CD4017) have got decoded outputs, internally containing a counter
and a decoder.
The counter shown above is called a “ripple counter”. The reason for this is that the second flip flop
can only begin toggling when the first counter has completed its state change. This means that the
outputs don't all change at the same instant. This can cause problems in some circuits and for this
reason ripple counters are no longer popular. We will cover non-ripple counter design later. A
zoomed-in view of the transition from state “011” to state “100” is shown here.
Exercises:
1. By writing out a table prove that a count sequence can be made up by cascading toggle
stages.
2. Look up the datasheet on 74HC4040.
Shift Registers are useful for implementing serial to parallel conversion and parallel to serial
conversion. They are used extensively in microprocessors for a variety of operations.
In order to design the combinational circuit to calculate the next state we use a present state/next
state diagram. Suppose we have a system with four states and one input. Our diagram will typically
look like this:
The next state columns will show the state that is to be entered given the current state and input
condition. Once this table has been drawn up standard logic reduction tools are used to calculate the
combinational circuitry.
1. Design a counter that counts in the sequence 0-1-2-0-1-2 etc. The counter must not be a ripple
type.
Because the counter cannot be a ripple type forget about using a ripple counter and making it reset
itself when it reaches 2.
We need to use a present state next state diagram. If we design the circuit using two D flip flops
then there will be four possible states, even though we are only interested in 3 of them. We shall use
'Don't cares' to simplify our circuitry. This counter is made simpler by the fact that there are no
external inputs.
By inspection we can tell that D1 = Q0. Note how the don't care case has simplified this. The
Karnaugh map for D0 is like this:
Q0
0 1
Q1
0 1
1 X
Notice over here that both flip flops are clocked simultaneously, avoiding the ripple effect.
There are four states in this system, one per LED. We can use two bits of information to hold the
system state. The present state/next state diagram is as follows:
Q1Q0
00 01 11 10
DIR
0 1 1
1 1 1
We can represent the operation of a sequential circuit by using an Algorithmic State Machine Chart
(ASM chart). We will do this by using the following elements:
The behaviour of the system is modeled by combining the three types of blocks to form a chart
which defines how the system will work.
i. Examples
1. Show the ASM chart for a two bit counter. The counter has no inputs other than its clock.
00
Zero Output = 00
01
One Output = 01
10
Two
Output = 10
11
Three Output = 11
Notice that we do not explicitly show the clock. We assume that there is a clock signal and we
assume that the system moves from state to state synchronously with the clock.
This was a very simple example. We could have done this easily without the help of an ASM chart.
2. We wish to make a timing system for an athletic event. We are only interested in the first three
runners in. We have a system of transponders which gives us a signal when each of the runner
arrives. We also have a stopwatch system (separate) consisting of three stopwatches, which will
do the timing. All that we need to implement is a system which links the stopwatch to the
transponder system. In addition we would like a display of three LED's which indicates how
many runners must still come in.
In summary we could say that the transponder system has an output called “arr”. This output goes
high briefly when a runner arrives. The stopwatch system has three incoming signals, stor1, stor2
and stor3, each of which triggers a time capture.
Notice over here that we have assigned the states 00, 01, 11, 10. Sometimes a Gray code will yield
better circuitry.
D0
Q1Q0
00 01 11 10
Arr
0 1 1
1 1 1
D1
Q1Q0
00 01 11 10
Arr
0 1 1
1 1 1 1
D1 = Q1 + Arr .Q0
From this we can get the circuit for the state-sequencing system:
The clock inputs on the flip flops are tied together and tied to a clock source (square wave) with a
frequency which is sufficiently high that the circuit responds fast to inputs.
So far we have not taken the conditional outputs into account. This is quite easy:
Stor1 is asserted if state = 00 and Arr = 1 therefore
Stor 1 = Arr .Q1 .Q0
and also
Stor 3 = Arr .Q1 .Q0
Now all that is required is to add in the display for the LED's. We can draw the following table
which maps the system state to the system outputs for the LED's.
This circuit can be simplified by exploiting the commonality between the LED output circuit and
the Stor outputs. This is left as an exercise.
The basis of the technique is to replace each element of the ASM chart with a circuit. Thus we have
the following replacement rules:
Condition
Variable 0 FALSE Exit
Path
Incoming Flow
Variable
Conditional Output
Outgoing Flow
Lastly we must replace the junctions in signal flow with OR gates. Please note that it is not
generally acceptable to simply connect two outputs together. This is because of the possibility of
‘contention’, which occurs when one signal attempts to pull a line high while another output is
asserting a low on the same line.
Entry 1 Entry 2
Exit
Now that we have the ground rules established we can do an example. We will do the example from
page 16. Refer to that example for the ASM chart.
In the above circuit only one thing is missing. That is the power-on-reset circuit. When the system
is powered up it is critical that it goes into the idle state (state 00) and it is also critical that only one
state is active. In practice this means that one flip-flop is set (the idle state flip-flop) and all of the
other flip-flops are cleared. This is achieved by using the set and reset inputs to each flip-flop.
1.5 Conclusion
It takes practice to become proficient at logic design. Half the trick to being a good designer lies in
being able to think about the real system that must be made and converting that to an ASM chart. In
order to get skills in this area consider the following examples:
Redo the “who was first' game from the laboratory. Use both ASM design methods outlined above.