Combinational Digital Logic

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

COMP2340

+ Lecture 4

Combinational Logic
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
+
Topics

• Adders
• Half Adder
• Full Adder
• Decoders
• Multiplexers

2
+
Combinational Logic

• This circuit can be represented as a new device that accepts


three inputs (X, Y, and Z) and produces an output defined by the
function F(X, Y, Z) = X + Y • Z

X Our circuit
with X+Y•Z
Y
details
Z hidden

• This new “device” can now be used along with gates and other
devices in circuits. 3
+
Combinational Logic

• Combinational logic circuits give us many useful


devices. There are several such devices that are
found in almost all computers. These include:
• Adders
• Multiplexers and De-multiplexers
• Encoders and Decoders
• Comparators and Shifters
• The basic devices are used to construct other
more complex devices such as the Arithmetic
and Logic Unit (ALU)
4
+
Adders

• Addition is a basic operation of a computer system


• At the Digital Logic Level, addition is accomplished
using a device that is called an adders.
• An Adder is built from digital logic gates
• We will construct a simple adder that just add two
bits
• We will then take the simple 1-bit adder that we have
constructed to build a 4-bit adder.
• This exercise will demonstrate how digital logic
systems are built from the bottom always using
simpler circuits as building blocks for more complex
circuits.
5
+
Adders

• Addition of two bits is shown


in the Truth Table to the right
• From the table we see that
digital logic circuit which
performs addition on two bits:
• Takes two inputs, X and Y
• Implements two functions
• Sum
• Carry
6
+
Adders

• Here is our circuit. It is called


a Half Adder.

7
+
Combinational Logic

• When we use a digital logic device in a circuit,


we omit the details (the gates) and use a
schematic symbol instead.
• The schematic for a Half Adder is simply a
rectangular box with that is labeled “Half Adder” ,
“H/A”.

X Sum
H/A
Y Carry 8
+
Combinational Logic

• Addition of two 4-bit values occurs by


adding corresponding bits
• A carry (0 or 1) is included in each
addition.
10 01 01 1
• A Half Adder does only a part of what
is required to add two numbers
• For each position, the job that is
0 0 1 1
required for a full addition is to
• Add two input bits to an input
carry,
• And generate an output sum
and an output carry.
+
Combinational Logic

• A device that can do a full addition


will therefore need three inputs and
will have two outputs
• Called a full adder (shown to the
right)
• Truth table shown below
• By close examination we note that
the Sum output can be calculated by
adding X to Y then adding the result
of this addition to the Carry In value.
+
Combinational Logic

• The sum from a full adder can be attained from


two half adders by interconnecting them as
follows: 1-Bit Full Adder

X Sum Sum
X Sum X

H/A H/A
? Carry
Y
Y Carry
? Y Carry

Carry In
+
Combinational Logic

• To determine how to
establish the value of the
carry we note from the
truth table
• Carry Out is 1 whenever
there is a Carry from either
the first part of the addition
OR the second part.
• We therefore generate the
Carry Out from the Full
Adder by OR’ing the Carry
from each Half Adder in
our circuit.
+
Combinational Logic

• The sum from a full adder can be attained from


two half adders by interconnecting them as
follows: 1-Bit Full Adder

X Sum Sum
X Sum X

H/A H/A
Y Y
Y Carry Carry

Carry In Carry
+
Combinational Logic

• Here’s our completed 1-bit Full Adder showing


full details of all gates used.
+
Combinational Logic

• It is important to note that there are many other


possible implementations of an adder.
• For example, we could have used NAND gates
(or NOR gates) only since each is a Universal
Gate.
• Any circuit whose Truth Table is exactly as that of
a Full Adder can be called a Full Adder.
+
Combinational Logic

• Just as we combined half adders to make a full


adder, full adders can be connected in series to
make an n-bit adder.

• This circuit adds corresponding bits from each n-bit


word
• The Carry Out from one adder is connected to the
Carry In of the adder that follows
+
Combinational Logic

• The simple n-bit we described here is called a


Ripple Carry Adder
• The Carry ripples through the circuit from Full
Addern to Full Addern+1
• This type of adder is very basic and will be slow
for a large number of bits.
• Cannot complete addition of bits at position n until
calculation at position n-1 is complete (n > 1)
+
Combinational Logic
• Decoders are another important type of
combinational circuit.
• A Decoder takes an n-bit number as its input
• The device has 2n output lines
• Each value of the input will select exactly one
output line
• An Active High Decoder places a 1 on the selected line while
all other lines are set to zero.
• An Active Low Decoder does the opposite. It places a 0 on
the selected line while placing a 1 on all other lines.
• We will work mostly with Active High decoders.
+
Combinational Logic

This is a block
diagram for a
decoder.

•Typically the lines are selected in counting order


•Line 0 (usually at the top of the diagram is selected when
input is all 0’s
•Line 2n -1 is selected when all bits in the input are 1
•In many cases the order of selection is explicitly given by
labelling each output line with the value that will select it.
+
Combinational Logic

• This is what a 2-to-4 decoder looks like on the


inside.

If x = 0 and y = 1,
which output line
is enabled?
+
Combinational Logic

• The schematic symbol for this 2-to-4 decoder


would look like this:

I0 00 The value
I1 2-to4 01 on this wire
Active Hi will be 1 if
10
Decoder I0=1; I1=0
11
+
Combinational Logic

• A multiplexer does just the


opposite of a decoder.
• It selects a single output
from several inputs.
• The particular input chosen
for output is determined by
the value of the multiplexer’s
control lines.
This is a block
• To be able to select among n diagram for a
inputs, log2n control lines are multiplexer.
needed.
+
Combinational Logic

• This is what a 4-to-1 multiplexer looks like on the


inside.
+
Combinational Logic

• Multiplexers and Decoders are useful for controlling


circuits where:
• One of several values is to selected as an output
• To enable output from one of several devices (or
locations) while disabling all other devices (or
locations)
• For example decoders are commonly used to
select one of 2n memory addresses using an n-
bit address.
+
Combinational Logic

•Consider the following use of a 2-to-4 1 bit Multiplexer.


A B • All functions are
f1(A,B)
f1 00 evaluated
• Only one is
f2 f2(A,B) 01 Out
selected by a
4-Way combination of
MUX
S0, S1
f3(A,B)
f3 10
• This is how a 4
function 1-bit
f4 f4(A,B) Arithmetic and
11
Logic Unit (ALU)
S0 S1 is constructed
+
Combinational Logic
• Here is a simple 4 function 1-bit ALU along with a table
of its operations
A B
00

S0 S1 Out
01 Out
4-Way 0 0 A OR B
MUX
0 1 B
10
1 0 NOT A

1 1 Sum(A,B)

1-bit f4(A,B)
11
Adder
S0 S1
+
Combinational Logic
◼ An n-bit ALU can be made using n 1-bit
ALUs just as a n-bit Adder is made
4 4
◼ The block diagram at right is for a 4-bit
ALU Carry In 4 function F0
F1
◼ The slash and number beside each line ALU
says that the line really represents 4 wires
4
◼ The wires F0 and F1 are set to select one ZNCV
operation Out
◼ The Z, N, C,V wires output special status
information from the ALU at the end of the
operation
◼ For example the wire labeled C is the Carry
Out from the ALU
◼ The wire labeled V carries a 1 when there is a
2’s complement overflow
◼ We will discuss these status wires more when
we study micro-architectures.
+
Combinational Logic

• Combinational logic circuits produce a specified output


(almost) at the instant when input values are applied
• The outputs depend entirely on the inputs that are applied
• When the inputs are removed
• Thus, it is said that a combinational logic circuits does not
remember its inputs
• Next, we will look at some circuits that remember inputs -
sequential logic circuits.
• We will learn then how registers (and other parts of memory)
are constructed
+ Summary
Combinational Logic
Lecture 4

◼ Adders
◼ Half Adder
◼ Full Adder

◼ Decoders

◼ Multiplexers

© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.

You might also like