Академический Документы
Профессиональный Документы
Культура Документы
Dr. I. Damaj 1
Overview
Functions and functional blocks
Rudimentary logic functions
Decoding
Encoding
Selecting
Implementing Combinational Functions Using:
Decoders and OR gates
Multiplexers (and inverter)
ROMs
PLAs
PALs
Lookup Tables
Dr. I. Damaj 2
1
Functions and Functional Blocks
Dr. I. Damaj 3
V CC or V DD
1 F5
= 1 F=
5 1 X F=5 X
(c)
0 F=
5 0 F=
5 0
X F=5 X
Dr. I. Damaj 4
(a) (b) (d)
2
Multiple-bit Rudimentary Functions
Multi-bit Examples:
A F3 A
3 2
1 F2 1 2 4 4 2:1 F(2:1)
F F
0 F1 0 1
0 (c)
A F0 A
(a) (b) 3
A wide line is used to represent 4 3,1:0 F(3), F(1:0)
a bus which is a vector signal F
In (b) of the example, F = (F3, F2, F1, F0) is a bus. (d)
The bus can be split into individual bits as shown in (b)
Sets of bits can be split from the bus as shown in (c)
for bits 2 and 1 of F.
The sets of bits need not be continuous as shown in (d) for bits 3, 1, and 0
of F.
Dr. I. Damaj 5
Enabling Function
The value on the output when it is disable can be Hi-Z (as for three-
state buffers), 0 , or 1
X
F
EN
When disabled, 0 output
(a)
When disabled, 1 output
X
F
EN
(b)
Dr. I. Damaj 6
3
Decoding
Dr. I. Damaj 7
Decoder Examples
A D0 D1
1-to-2-Line Decoder D 0=
5 A
0 1 0
1 0 1 A D 1=
5 A
2-to-4-Line Decoder A0 (a) (b)
A1 A0 D0 D1 D2 D3
A1
0 0 1 0 0 0 D0 = A1 A0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1 D1 = A1 A0
(a)
D2 = A1 A0
Note that the 2-4-line
made up of 2 1-to-2-
D3 = A1 A0
line decoders and 4 AND gates.
Dr. I. Damaj (b) 8
4
Decoder Expansion
General procedure given in book for any decoder with n inputs and
2n outputs.
The output AND gates are driven by two decoders with their
numbers of inputs either equal or differing by 1.
These decoders are then designed using the same procedure until
2-to-1-line decoders are reached.
3-to-8-line decoder
Number of output ANDs = 8
Number of inputs to decoders driving output ANDs = 3
Closest possible split to equal
2-to-4-line decoder
1-to-2-line decoder
2-to-4-line decoder
Number of output ANDs = 4
5
Decoder Expansion - Example 1
D0
A0
D1
A1
D2
2-to-4-Line D3
decoder
D4
A2 D5
1-to-2-Line decoders D6
D7
Dr. I. Damaj 11
4.3 Decoding
Truth Table for 3–to–8-Line Decoder
6
4.3 Decoding
3-to-8-Line Decoder
Dr. I. Damaj 13
EN A 1 A 0 D0 D1 D2 D3 D1
0 X X 0 0 0 0
1 0 0 1 0 0 0 D2
1 0 1 0 1 0 0
1 1 0 0 0 1 0
D3
1 1 1 0 0 0 1 14
Dr. I. Damaj
(a) (b)
7
Encoding
Encoding - the opposite of decoding - the conversion of an m-bit
input code to an n-bit output code with n ≤ m ≤ 2n such that each
valid code word produces a unique output code
An encoder has 2n (or fewer) input lines and n output lines which
generate the binary code corresponding to the input values
Dr. I. Damaj 15
Encoder Example
A decimal-to-BCD encoder
Inputs: 10 bits corresponding to decimal digits
0 through 9, (D0, …, D9)
Outputs: 4 bits with BCD codes
Function: If input bit Di is a 1, then the output
(A3, A2, A1, A0) is the BCD code for i,
The truth table could be formed, but
alternatively, the equations for each of the four
outputs can be obtained directly.
Dr. I. Damaj 16
8
Encoder Example (continued)
Equations:
A3 = D8 + D9
A2 = D4 + D5 + D6 + D7
A1 = D2 + D3 + D6 + D7
A0 = D1 + D3 + D5 + D7 + D9
Dr. I. Damaj 17
Another Example
An encoder is a digital function that performs the inverse operation of a
decoder. It has 2n (or fewer) input lines and n output lines.
Dr. I. Damaj 18
9
Another Example
For the 8-to-3-line encoder, the resultant
equations are:
A0 = D1 + D3 + D5 + D7
A1 = D2 + D3 + D6 + D7
A2 = D4 + D5 + D6 + D7
Dr. I. Damaj 19
Priority Encoder
If more than one input value is 1, then the encoder just designed
does not work.
Dr. I. Damaj 20
10
Priority Encoder
Input D3 has the highest priority, so regardless of the values of
the other inputs, the output for A1A0 is 11.
The valid output (V) is set to 1 only when 1 or more of the inputs
are equal to 1.
Dr. I. Damaj 21
Priority Encoder
Dr. I. Damaj 22
11
Selecting
Dr. I. Damaj 23
Multiplexers
A multiplexer selects information from an input line
and directs the information to an output line
A typical multiplexer has n control inputs (Sn − 1, …
S0) called selection inputs, 2n information inputs (I2n −
1, … I0), and one output Y
A multiplexer can be designed to have m information
inputs with m < 2n as well as n selection inputs
Dr. I. Damaj 24
12
2-to-1-Line Multiplexer
Since 2 = 21, n = 1
The single selection variable S has two values:
S = 0 selects input I0
S = 1 selects input I1
The equation:
Y = S’I0 + SI1
The circuit:
Enabling
Decoder Circuits
I0
Y
S
Dr. I. Damaj I1 25
Dr. I. Damaj 26
13
Example: 4-to-1-line Multiplexer
2-to-22-line decoder
22 ´ 2 AND-OR
Decoder
S1
4 3 2 AND-OR
S0
Decoder
S1
S0
I0
Y
I1
Y
I2
Dr. I. Damaj I3 27
I1
S1
Y
I2
I3
(b)
Gate input cost = 14 compared to 22 (or 18) for gate
implementation
Dr. I. Damaj 28
14
Other Selection Implementations
Transmission Gate Multiplexer
S0
S1
Gate input
cost = 8 I0 TG
(S0 5 0)
compared TG
(S1 5 0)
to 14 for I1
TG
3-state logic
(S0 5 1)
and 18 or 22 Y
TG
for gate logic I2
(S0 5 0)
TG
(S1 5 1)
TG
I3 (S0 5 1)
Dr. I. Damaj 29
15
Decoder and OR Gates
Implement m functions of n variables with:
Sum-of-minterms expressions
One n-to-2n-line decoder
m OR gates, one for each output
Approach:
Find the truth table for the functions
Make a connection to the corresponding OR from the
corresponding decoder output wherever a 1 appears in the truth
table
Dr. I. Damaj 31
Implement the following set of odd parity functions of (A7, A6, A5, A3)
P1 = A7 xor A5 xor A3
P2 = A7 xor A6 xor A3
A7 0 P1
A6 1
P4 = A7 xor A6 xor A5 2
Finding sum of A5 3
minterms expressions A4 4
5 P2
P1 = Σm(1,2,5,6,8,11,12,15) 6
P2 = Σm(1,3,4,6,8,10,13,15) 7
8
P4 = Σm(2,3,4,5,8,9,14,15) 9
Find circuit 10 P4
11
Is this a good idea? 12
13
14
15
Dr. I. Damaj 32
16
Multiplexer Approach 1
Implement m functions of n variables with:
Sum-of-minterms expressions
An m-wide 2n-to-1-line multiplexer
Design:
Find the truth table for the functions.
In the order they appear in the truth table:
Apply the function input variables to the
multiplexer inputs Sn − 1, … , S0
Label the outputs of the multiplexer with the
output variables
Value-fix the information inputs to the multiplexer using
the values from the truth table (for don’t cares, apply
either 0 or 1)
Dr. I. Damaj 33
17
Gray to Binary (continued)
Rearrange the table so Gray Binary
that the input combinations
are in counting order ABC xyz
000 000
Function x is the same as C 001 111
010 011
Functions y and z can 011 100
be implemented using 100 001
a dual 8-to-1-line
multiplexer by: 101 110
110 010
111 101
connecting A, B, and C to the multiplexer select inputs
placing y and z on the two multiplexer outputs
connecting their respective truth table values to the inputs
Dr. I. Damaj 35
0 D00 0 D10
1 D01 1 D11
1 D02 1 D12
0 D03 0 D13
0 D04 1 D14
Out Y Out Z
1 D05 0 D15
1 D06 0 D16
0 D07 1 D17
A S2 A S2 8-to-1
8-to-1
B S1 B S1
C S0 MUX C S0 MUX
Note that the multiplexer with fixed inputs is identical to a ROM with
3-bit addresses and 2-bit data!
Dr. I. Damaj 36
18
Multiplexer Approach 2
Implement any m functions of n + 1 variables by using:
An m-wide 2n-to-1-line multiplexer
A single inverter
Design:
Find the truth table for the functions.
Based on the values of the first n variables, separate the truth
table rows into pairs
For each pair and output, define a rudimentary function of the
final variable (0, 1, X, X’)
Using the first n variables as the index, value-fix the information
inputs to the multiplexer with the corresponding rudimentary
functions
Use the inverter to generate the rudimentary function X’
Dr. I. Damaj 37
19
Gray to Binary (continued)
000 000
F=C F=C
001 111
010 011
F=C F=C
011 100
100 001
F=C F=C
101 110
110 010
F=C F=C
Dr. I. Damaj 111 101 39
C D00 C D10
C D01 C D11
C C
C D02 Out Y C D12 Out Z
C D03 C D13
A S1 8-to-1 A S1 8-to-1
B S0 MUX B S0 MUX
Note that this approach (Approach 2) reduces the cost by almost half
compared to Approach 1.
This result is no longer ROM-like
Extending, a function of more than n variables is decomposed into several
sub-functions defined on a subset of the variables. The multiplexer then
selects among these sub-functions.
Dr. I. Damaj 40
20
Read Only Memory
Dr. I. Damaj 41
Dr. I. Damaj 42
21
Example:
Square of a 3-bit binary input
Dr. I. Damaj 44
22
Programmable Array Logic Example
Equations:
F1 = AB’C’ +A’BC’ +A’B’C + ABC
F2 = AB + BC + AC
AND Inputs
F1 must be Product
factored term A B C D W Outputs
since four
terms 1 0 0 1 — —
2 1 1 1 — — W = A’B’C + ABC
3 — — — — —
Factor out
4 1 0 0 — —
last two F1 = X = AB’C’+A’BC’+W
5 0 1 0 — —
terms as W 6 — — — — 1
7 1 1 — — —
F2 = Y = AB + BC +AC
8 — 1 1 — —
9 1 — 1 — —
10 — — — — —
11 — — — — —
Dr. I. Damaj 12 — — — — — 45
2 W
5 F1
8 F2
10
11
12
Dr. I. Damaj D
X Fuse intact 46
1 Fuse blown
A A B B C C D D W W
23
Another Example
W(A,B,C,D) = Σm(2,12,13)
X(A,B,C,D) = Σm(7,8,9,10,11,12,13,14,15)
Y(A,B,C,D) = Σm(0,2,3,4,5,6,7,8,10,11,15)
Z(A,B,C,D) = Σm(1,2,8,12,13)
Dr. I. Damaj 47
Dr. I. Damaj 48
24
Programmable Logic Array
For small circuits, K-maps can be used to visualize product term sharing and
use of complements
F1 = AB + AC + ABC
F2 = AC + BC
Dr. I. Damaj 50
25
Using Programmable Logic Arrays
Homework
Example 4 - 11
F1 = AB + AC + ABC
F2 = AC + BC
Dr. I. Damaj 51
Lookup Tables
Lookup tables are used for implementing logic in Field-Programmable
Gate Arrays (FPGAs) and Complex Logic Devices (CPLDs)
Lookup tables are typically small, often with four inputs, one output, and
16 entries
Dr. I. Damaj 52
26
Lookup Table Example
Equations to be implemented:
F1(A,B,C,D,E) = A D E + B D E + C D E
F2(A,B,D,E,F) = A E D + B D E + F D E
Dr. I. Damaj 53
Introduction to VHDL
Dr. I. Damaj 54
27
Overview
Part 1 - Basics and Constructs
VHDL basics
Notation
Types & constructs
Signals
Entities and architectures
Libraries and packages
Structural VHDL Example
VHDL Operators
Concurrent VHDL Examples
Part 2 - Behavioral and Hierarchical Description
Part 3 - Finite State Machines
Part 4 - Registers and Counters
Part 5 - Algorithmic State Machine Example: Binary Multiplier
Dr. I. Damaj 55
VHDL Notation - 1
VHDL is:
Case insensitive
Based on the programming language ADA
Strongly-typed language
Comments
-- [end of line]
List separator: ,
Statement terminator: ;
Dr. I. Damaj 56
28
VHDL Notation - 2
Types and values
Determined by use of packages (discussed later) that define various types
and type conversions
Dr. I. Damaj 57
VHDL Notation - 3
More on types
Most frequently used type: std_logic
Provides values needed for simulation, notably X and
operations
Requires additional packages to be used to perform
Dr. I. Damaj 58
29
VHDL Notation - 4
Constants
Binary
Single bit: '0', '1'
Multiple bit: B"110001", B"11_0001" (underline
permitted for readability)
Other bases
Octal O"61", O"6_1"
Hex X"31", X"3_1"
Decimal 49
Real 49E+1
Dr. I. Damaj 59
VHDL Notation - 5
Identifiers
Examples: A, B1, abc, run, stop, c_in
Keywords
Words reserved for special meanings
Cannot be used as identifiers
Examples: entity, architecture, and, if
Shown here in color
Shown in text in bold
Dr. I. Damaj 60
30
VHDL Constructs
Structural:
Describes interconnections of components (entities)
Analogous to logic diagrams or netlists
Concurrent VHDL or Dataflow:
Consists of a collection of statements and processes that
execute concurrently
Sequential VHDL:
Consists of the sequences of statements within processes
Logic described may be combinational or sequential
Dr. I. Damaj 61
Signal Declaration
Signals can be viewed as "wires"
Signals are concurrent and sequential objects
A port declaration is a signal declaration with in or out added
Examples:
signal a, b: std_logic;
signal widget: std_logic_vector(0 to 7);
-- 0 is MSB and 7 is LSB
signal c: std_logic_vector(2 downto 0);
-- 2 is MSB and 0 is LSB
Dr. I. Damaj 62
31
Entities and Architectures
entity
The primary hardware abstraction in VHDL
Provides: the entity name, the inputs and outputs
Analogous to a symbol in a block diagram
architecture
Specifies the relationships between the inputs and outputs of a
design entity
May be a mixture of structural, concurrent and sequential VHDL.
Dr. I. Damaj 63
A package consists of compiled VHDL code for multiple entities and associated
architectures
func_prims provides compiled code for the following delay-free gates: and2, …,
and5, or2, … or5, nand2, …, nand5, nor2, …, nor5, not, xor2, and xnor2 in
which integers 2 through 5 specify the number of gate inputs.
Dr. I. Damaj 64
32
First Example to Illustrate Entities,
Architectures and Constructs
IC7283 - a 1-bit adder from a commercial IC
• C1
B0 •
A0 • • •
S0
• • •
C0 • • •
Dr. I. Damaj 65
33
A Structural VHDL Example (continued)
component NOR2
port(in1,in2: in std_logic;
out1: out std_logic);
end component;
component AND2
port(in1,in2: in std_logic;
out1: out std_logic);
end component;
component XOR2
port(in1,in2: in std_logic; Declarations of 7 signals for use in
out1: out std_logic); interconnecting the gates
end component;
signal N1,N2,N3,N4,N5,N6,N7:
std_logic;
Dr. I. Damaj 67
end structure;
End of architecture and description
Dr. I. Damaj 68
34
VHDL Operators
Dr. I. Damaj 69
Concurrent VHDL
Signal assignment
Uses signal assignment operator <=
A signal is assigned its value after a delay, whether real or
a delta time, an infinitesimal interval required in VHDL
simulator implementations
Examples:
z <= a or b; --z assigned after an
--infinitesimal delta time
z <= a nand b after 10 ns; -- z assigned
-- after inertial delay of 10 ns
widget <= transport ("00" & a & b) after 10 ns;
-- assigned after transport delay of 10 ns;
-- & is the concatenation operator.
Dr. I. Damaj 70
35
Concurrent VHDL Example Using
Boolean Equations
The entity is the same as for the structural VHDL example
Dr. I. Damaj 71
entity IC7283_ws is
port (Z: in std_logic_vector(2 downto 0);
CS: out std_logic_vector(1 downto 0));
end IC7283_ws;
Dr. I. Damaj 72
36
Concurrent VHDL Example Using "with select"
Dr. I. Damaj 73
Priority Encoder
Inputs Outputs
D4 D3 D2 D1 D0 A2 A1 A0 V
0 0 0 0 0 X X X 0
0 0 0 0 1 0 0 0 1
0 0 0 1 X 0 0 1 1
0 0 1 X X 0 1 0 1
0 1 X X X 0 1 1 1
1 X X X X 1 0 0 1
Dr. I. Damaj 74
37
Concurrent VHDL Example Using "when else"
library IEEE
use IEEE.std_logic_1164.all;
entity priority_encoder_we is
port (D: in std_logic_vector (4 downto 0);
A: out std_logic_vector (2 downto 0);
V: out std_logic);
end priority_encoder_we;
architecture dataflow_3 of priority_encoder_we is
begin
A <= "100" when D(4) = '1' -- Can customize condition
else "011" when D(4 downto 3) = "01" -- on each
else "010" when D(4 downto 2) = "001" -- line.
else "001" when D(4 downto 1) = "0001"
else "000" when D = "00001"
else "XXX";
V <= not(D = "00000");
end dataflow_3;
Dr. I. Damaj 75
with select
Has simple form with
condition signal stated only once
when else
Has more complex form, but
Able to implement much more complex decision functions
condensed truth tables with 0, 1, X entries in rows
Dr. I. Damaj 76
38
Problems
4.10, 4.11, 4.12, 4.21, 4.23, 4.24, 4.25, 4.27,
4.30, 4.31, 4.32, 4.33, 4.34, 4.35.
Dr. I. Damaj 77
39