Professional Documents
Culture Documents
Architecture
Nicola Gigante
Free University of Bozen-Bolzano
A.A. 2022/2023
Logical circuits
Digital logical circuits
Surprisingly, behind the sophisticated and complex behavior of modern
computers, lie three very simple components that can be described in
purely logical terms.
These components are the «logic gates», simple electronic circuits that
implement the elementary logic functions.
Logical levels
An electronic circuits works in terms of continuous an analog physical measures
• Voltage, current intensity, magnetic fields, etc.
In our analysis of digital circuits we will abstract from their concrete electronic
implementation, focusing only on their logical behavior.
Logic gates
The «logic gates» are three kinds of simple logical circuits.
A A
A⋅B A+B
B A A
B
The AND gate gives output 1 The OR gate gives ouput 1 The NOT gate negates its input.
(true) if and only if both its if and only if at least one
inputs are 1. of its inputs is 1.
Logic gates
The «logic gates» are three kinds of simple logical circuits.
A A
A⋅B A+B
B A A
B
A B A⋅B A B A+B A A
0 0 0 0 0 0 0 1
0 1 0 0 1 1 1 0
1 0 0 1 0 1
1 1 1 1 1 1
Logic gates
Logic gates are implemented with transistors, the fundamental
component of modern electronics.
called a «minterm». 0 0 0 0
0 0 1 0
0 1 0 1
Starting from the minterms we can obtain the 0 1 1 1
corresponding Boolean expression, and then 1 0 0 0
the circuit. 1 0 1 1
1 1 0 0
#BC& + A
F=A #BC + AB
#C 1 1 1 0
From truth tables to circuits
#BC& + A
F=A #BC + AB
#C
A B C F
A B C 0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 0
Derived logic gates
We can obtain some «derived» logic gates by negating the output of
elementary gates.
A A
A⋅B A+B
B B
A B A⋅B A B A+B
0 0 1 0 0 1
0 1 1 0 1 0
1 0 1 1 0 0
1 1 0 1 1 0
XOR gate
Another derived logic gate is the XOR gate, that is, «eXclusive OR».
A B A XOR B
0 0 0
0 1 1
1 0 1
1 1 0
XOR gate
Another derived logic gate is the XOR gate, that is, «eXclusive OR».
AND OR NOT
0⋅𝑋 =0 0+𝑋 =𝑋 𝑋( = 𝑋
1⋅𝑋 =𝑋 1+𝑋 =1
𝑋⋅𝑋 =𝑋 𝑋+𝑋 =𝑋
𝑋 ⋅ 𝑋( = 0 𝑋 + 𝑋( = 1
Boolean algebra
Let’s delve into details of the laws of Boolean algebra.
Each of these laws can be verified by checking its truth table.
• De Morgan laws:
𝐴𝐵 = 𝐴̅ + 𝐵+
𝐴 + 𝐵 = 𝐴̅ ⋅ 𝐵+
𝑋+𝑋⋅𝑌 =𝑋
𝑋 + 𝑋+ ⋅ 𝑌 = 𝑋 + 𝑌
𝑋 𝑋+𝑌 =𝑋
𝑋 𝑋+ + 𝑌 = 𝑋 ⋅ 𝑌
𝑋 + 𝑌 𝑋 + 𝑌+ = 𝑋
Simplification of Boolean expressions
The laws of Boolean algebra are useful to simplify Boolean expressions
so to obtain equivalent, but cheaper, versions of their corresponding
logical circuits.
Examples:
𝑋& ⋅ 𝑌 ⋅ 𝑋 ⋅ 𝑍 = 𝑋& ⋅ 𝑌 + 𝑋 ⋅ 𝑍 = 𝑋& ⋅ 𝑌 + 𝑋 ⋅ 𝑍
𝐴̅ ⋅ 𝐵 ⋅ 𝐶 + 𝐴 ⋅ 𝐵 ⋅ 𝐶 = 𝐵 ⋅ 𝐶 ⋅ 𝐴̅ + 𝐴 = 𝐵 ⋅ 𝐶
𝐴 ⋅ 𝐵& ⋅ 𝐶 + 𝐴 ⋅ 𝐵 ⋅ 𝐶 ⋅ 𝐷
# = 𝐴 ⋅ 𝐶 ⋅ 𝐵& + 𝐵 ⋅ 𝐷# = 𝐴 ⋅ 𝐶 ⋅ 𝐵& + 𝐷
#
= 𝐴 ⋅ 𝐶 ⋅ 𝐵& + 𝐴 ⋅ 𝐶 ⋅ 𝐷
#
Example
Let us design a «multiplier», that is a logical circuit with four inputs
𝑋! , 𝑋" , 𝑌! , 𝑌" and four outputs 𝑍# , 𝑍$ , 𝑍! , 𝑍" that implements the
arithmetic function 𝑍 = 𝑋×𝑌.
1. Fill the truth table
2. Obtain the Boolean expression of each of the four outputs
3. Simplify the resulting expressions using Boolean algebra
4. Draw the circuit
𝐴 𝐴
𝐴̅ 𝐴̅
𝐴 ⋅ 𝐴 = 𝐴̅ 𝐴 + 𝐴 = 𝐴̅
Universal logic gates
The NAND and NOR gates are called «universal gates» because any
circuit can be built using only gates of one of these kinds.
𝐴
𝐵 𝐴⋅𝐵
𝐴⋅𝐵 =𝐴⋅𝐵
Universal logic gates
The NAND and NOR gates are called «universal gates» because any
circuit can be built using only gates of one of these kinds.
𝐴
𝐴+𝐵
𝐴 + 𝐵 = 𝐴 + 𝐵 = 𝐴̅ ⋅ 𝐵(
Karnaugh maps
Simplifying a Boolean expression using the laws of Boolean algebra can
be at times very complex.
𝐹 = 𝐴 ⋅ 𝐵 + 𝐴̅ ⋅ 𝐵 ⋅ 𝐶̅ ⋅ 𝐷 + 𝐴̅ ⋅ 𝐵 ⋅ 𝐶 ⋅ 𝐷 + 𝐴 ⋅ 𝐵& ⋅ 𝐶̅ ⋅ 𝐷
#
Each term contains only the variables that do not change in the
groups’ cells, straight or negated depending on how they appear in
the raw/column head.
𝐴 ⋅ 𝐵 ⋅ 𝐶̅ ⋅ 𝐷
) + 𝐴 ⋅ 𝐵( ⋅ 𝐶̅ ⋅ 𝐷
) = 𝐴 ⋅ 𝐶̅ ⋅ 𝐷
)
Karnaugh maps A B C D F
0 0 0 0 1
Note that in Karnaugh maps, the cells at the border are adjacent 0 0 0 1 0
with each other. For example: 0 0 1 0 1
0 0 1 1 0
AB 00 01 11 10 0 1 0 0 0
CD
00 1 1 0 1 0 1 0
0 1 1 0 0
01
0 1 1 1 0
11
1 0 0 0 1
10 1 1
1 0 0 1 0
1 0 1 0 1
1 0 1 1 0
𝐹 = 𝐵( ⋅ 𝐷
) 1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0
Example
A circuit has four inputs 𝐴! , 𝐴" , 𝐴# , 𝐴$ representing a natural number 𝐴
encoded in binary, ranging from 0 to 15.
Example: if the 𝐷# is active, the 𝑂! , 𝑂" lines will have value 11.
Encoder implementation
𝐷! 𝐷" 𝐷# 𝐷$ 𝑂# 𝑂$
Let’s build a 2 bits encoder. 0 0 0 0 0 0
0 0 0 1 0 0
𝐷! 𝐷"
00 01 11 10 0 0 1 0 0 1
𝐷# 𝐷$
0 0 1 1 0 1
00 1 1 1
0 1 0 0 1 0
01 1 1 1 𝑂# = 𝐷" + 𝐷!
𝑂# 0 1 0 1 1 0
11 1 1 1 0 1 1 0 1 0
10 1 1 1 0 1 1 1 1 0
1 0 0 0 1 1
𝐷! 𝐷" 1 0 0 1 1 1
00 01 11 10
𝐷# 𝐷$ 1 0 1 0 1 1
00 1 1
1 0 1 1 1 1
01 1 1 1 1 0 0 1 1
𝑂$ 𝑂$ = D! + 𝐷" 𝐷#
11 1 1 1 1 1 0 1 1 1
1 1 1 0 1 1
10 1 1 1
1 1 1 1 1 1
Encoder implementation
Let’s build a 2 bits encoder.
𝐷! 𝐷"
00 01 11 10
𝐷# 𝐷$
00 1 1 1 𝐷(
01 1 1 1 𝑂#
𝑂# 𝑂# = 𝐷" + 𝐷!
11 1 1 1 𝐷)
10 1 1 1
𝑂$
𝐷! 𝐷"
00 01 11 10 𝐷#
𝐷# 𝐷$
00 1 1
01 1 1
𝑂$ 𝑂$ = D! + 𝐷" 𝐷#
11 1 1 1
10 1 1 1
Decoder
A decoder inverts the work of an encoder.
An encoder with 𝑛 bits has 𝑛 inputs and 2% outputs, and interpreting
the inputs as the bits of a natural numbers, it activates the
corresponding output.
For example, if the inputs 𝐷! e 𝐷" are 11, the active output is 𝑂# .
Multiplexer
A multiplexer has the purpose of transport, alternatively, more data lines
over the same single line. It has 𝑛 «selection» inputs that tell which of the 2%
«data» inputs are reported to the output.
𝐷(
𝐷)
𝑂
𝐷#
𝐷$
𝑆# 𝑆$
For example, if the 𝑆# , 𝑆$ inputs have value 11, the output 𝑂 will repor the
data present at the 𝐷! input.
Multiplexer
To build a multiplexer we can use AND gates as «switches».
𝐷(
𝐷)
𝐷# 𝑂
𝐷$
𝑆# 𝑆$
Demultiplexer
A demultiplexer inverts the work of a multiplexer. A single input line is
reported to one of the 2% output lines depending on the value of the 𝑛
selection lines. 𝑂(
𝐷 𝑂)
𝑂#
𝑂$
𝑆# 𝑆$
For example, if the 𝑆! , 𝑆" lines hold 11, the line 𝐷 is reported to the 𝑂#
output.
Comparators
A comparator has as inputs two 𝑛 bits words and gives as output 1 if
the two words are equal. Example, 4 bits comparator:
𝐴$
𝐵$
𝐴#
𝐵#
𝐴)
𝐵)
𝐴(
𝐵(
Adder
Adders implement the arithmetic sum operation.
We already saw that a simple XOR gate can give us the result of the sum
between two bits. An additional AND gate can give us the carry as well.
A
S
B
𝐶*+# 𝑆* 𝐶*+# 𝑆*
𝐴* 𝐶* 𝐴* 𝐶*
𝐵* 𝐵*
𝐶,*
𝐶-./
𝐴$ 𝐵$ 𝐴# 𝐵# 𝐴) 𝐵) 𝐴( 𝐵(
Arithmetic-Logic Unit
An ALU is the component that performs arithmetic and logic operations
inside a CPU. It typically includes:
• A full-adder to execute additions and subtractions
• Elementary logic gates for logical operations
• Other arithmetic circuits (es. a multiplier)
• A decoder to select the output of the right component depending on
the operation to be performed
Arithmetic-Logic Unit
Recap
We saw how to build complex logical circuits starting from the basic logic
gates.
• Elementary (OR,AND,NOT) and universal (NAND,NOR) logic gates
• Boolean algebra
• Karnaugh maps
• Encoders and decoders
• Multiplexers and demultiplexers
• Comparators
• Adders
• ALUs