CH 3 Gate Level Minimization
CH 3 Gate Level Minimization
Prof. Wangrok Oh
1 Introduction
3 Product-of-Sums Simplification
4 Don’t-Care Conditions
7 Exclusive-OR Function
m1 + m2 + m3 = x!y + xy! + xy = x + y
Two-Variable K-Map
y
y
x 0 1
m0 m1
m0 m1 0 x!y! x!y
m2 m3
m2 m3 x 1 xy! xy
(a) (b)
FIGURE 3.1
Two-variable K-map for two variables → The map consists of 4 squares
4 minterms
The map is redrawn in (b) to show the relationship between the
squares and the two variables x and y
Two-variable map becomes another useful way to represent any one
of the 16 Boolean functions of two variables
y y
y y
x 0 1 x 0 1
m0 m1 m0 m1 y
0 0 1
m2 m3 m2 m3
x 1 1 x 1 1 1
x
(a) xy (b) x ! y
FIGURE 3.2
For (b), m1 + m2 + m3 = x0 y + xy 0 + xy = x + y
Representation of functions in the map
The three squares could also have been determined from the intersection of variable
x in the second row and variable y in the second column, which encloses the area
belonging to x or y. In each example, the minterms at which the function is asserted are
marked with a 1.
Three-Variable K-Map
Prof. Wangrok Oh(CNU) The Map Method 7 / 67
numbers are concatenated, they give the binary number 101, whose decimal equivalent
is 5. Each cell of the map corresponds to a unique minterm, so another way of looking at
The Map Method
square m5 = xy!z is to consider it to be in the row marked x and the column belonging
to y!z (column 01). Note that there are four squares in which each variable is equal to 1
and four in which each is equal to 0. The variable appears unprimed in the former four
Three-Variable K-Map
y
yz
x 00 01 11 10
m0 m1 m3 m2
m0 m1 m3 m2 0 x"y"z" x"y"z x"yz x"yz"
m4 m5 m7 m6
m4 m5 m7 m6 x 1 xy"z" xy"z xyz xyz"
z
(a) (b)
FIGURE 3.3
Three-variable
8 minterms K-map
forthree binary variables → The map consists of 8
squares
Note that the minterms are arranged not in a binary sequence but in
a sequence similar to the Gray code
Only one bit changes in value from one adjacent column to the next
There are 4 squares in which each variable is equal to 1 and 4 in
which each is equal to 0
Any two adjacent squares in the map differ by only one variable
z
xy!
FIGURE 3.4
F = xy 0 + x0 y
Map for Example 3.1, F (x, y, z) = "(2, 3, 4, 5) = x!y + xy!
m4 m5 m7 m6
x 1 1 1 1
z
xy!z! xyz!
Note: xy!z! " xyz! # xz!
FIGURE 3.5
F = yz + xz 0
Map for Example 3.2, F (x, y, z) = "(3, 4, 6, 7) = yz + xz! ■
m4 m5 m7 m6
x 1 1 1 1
z
xy!
Note: y!z! " yz! # z!
FIGURE 3.6 F = z 0 + xy 0
Map for Example 3.3, F (x, y, z) = "(0, 2, 4, 5, 6) = z! + xy!
C
C
FIGURE 3.7 X
F !=AB!C !
Map of Example 3.4, A!C ! A!B (1, BC
2, 3,"5, C
7) ! A!B
0
= C +A B
m4 m5 m7 m6
z
(a) (b)
FIGURE 3.8
Four-variable
There aremap
16 minterms and each square assigned to one of midterms
The rows and columns are numbered in a Gray code sequence
Only one digit changing value between two adjacent rows or columns
z
y!
FNote: y 0 + "ww!yz!
= w!y!z! 0
z +#xz 0
w!z!
xy!z! " xyz! # xz!
FIGURE
Prof. Wangrok 3.9
Oh(CNU) The Map Method 15 / 67
The Map Method
hapterExample
3 Gate-Level
(F =Minimization
A0 B 0 C 0 + B 0 CD0 + A0 BCD0 + AB 0 C 0 )
A!B!C!
C
CD
AB 00 01 11 10
A!B!C!D!
m0 m1 m3 m2
A!B!CD!
00 1 1 1
m4 m5 m7 m6
01 1 A!CD!
Prime Implicants
In choosing adjacent squares in a map, we must ensure that
1 All the minterms are covered when we combine the squares
2 The number of terms in the expression is minimized
3 There are no redundant terms (minterms covered by other terms)
Sometimes there may be two or more expressions that satisfy the
criteria
The procedure for combining squares may be made more systematic
if we understand the meaning of two special types of terms
1 Prime implicant: Product term obtained by combining the maximum
possible number of adjacent squares
2 If a minterm is covered by only one prime implicant, that prime
implicant is said to be essential
The prime implicants can be obtained by combining all possible
maximum numbers of squares
C C
CD CD
AB 00 01 11 10 AB 00 01 11 10
m0 m1 m3 m2 A!B!CD! m0 m1 m3 m2
00 1 1 00 1 1 1
A!B!C!D! m4 m5 m7 m6
CD m4 m5 m7 m6
01 1 1 AD 01 1 1
BD
m12 m13 m15 m14 B m12 m13 m15 m14 B B!C
11 1 1 11 1 1
A m8 m9 m11 m10
A m8 m9 m11 m10
10 1 1 10 1 1 1 1
AB!CD!
AB!C!D! D D
Note: A!B!C!D! " A!B!CD! # A!B!D! AB!
AB!C!D! " AB!CD! # AB!D!
A!B!D! " AB!D! # B!D!
(a) Essential prime implicants (b) Prime implicants CD, B!C,
BD and B!D! AD, and AB!
FIGURE 3.11
Simplification
In (a), using prime
two essential primeimplicants
implicants having only two literals
Omitted minterms m3 , m9 , m11 must be considered next
m3 can be covered with CD or BC 0
m9 can be covered with AD or AB 0
m11 can be covered with AD or AB 0 or CD or B 0 C
F = BD + B 0 D0 + CD + AD
= BD + B 0 D0 + CD + AB 0
= BD + B 0 D0 + B 0 C + AD
= BD + B 0 D0 + B 0 C + AB 0
Five-Variable Map
Maps for more than four variables are not as simple to use as maps
for four or fewer variables
A five-variable map needs 32 squares and a six-variable map needs 64
squares
When the number of variables becomes large, it is not easy to find a
simplified expression
C
CD
AB 00 01 11 10
m0 m1 m3 m2 CD
00 1 1 0 1 BCD!
BC!D! m4 m5 m7 m6
01 0 1 0 0
m12 m13 m15 m14 B
11 0 0 0 0
A m8 m9 m11 m10
10 1 1 0 1 AB
D
Note: BC!D! " BCD! # BD!
FIGURE 3.12
Prof. Wangrok Oh(CNU) Product-of-Sums Simplification 22 / 67
Product-of-Sums Simplification
Gate-level implementation of sum-of-products
1 Implemented with a group of AND gates
2 Each AND gate is for each product term
3 The outputs of the AND gates are connected to the inputs of a
single OR gate
Gate-level implementation of product-of-sums
1 Implemented with a group of OR gates
2 Each OR gate is for each sum term
3 The outputs of the OR gates are connected to the inputs of a single
86 Chapter
AND 3 Gate-Level Minimization
gate
B! A!
D! B!
C!
F F
C! D!
A!
D D
(a) F " B!D! # B!C! # A!C!D (b) F " (A! # B!) (C! # D!) (B! # D)
FIGURE 3.13
Gate implementations
Prof. Wangrok Oh(CNU) of the function
Product-of-Sums of Example 3.7
Simplification 23 / 67
Product-of-Sums Simplification
The procedure is also valid when the function is originally expressed
in the product-of-maxterms canonical form
xz!
FIGURE 3.14 Q
F (x, y, z)
Map for the function of Table 3.1
= (0, 2, 5, 7)
For the sum-of-products, we combine the 1’s: F = x0 z + xz 0
For the product-of-sum, we combine the 0’s:: F 0 = xz + x0 z 0
In product-of-maxterms form, it is expressed
Take the complement of F 0 : F as
= (x0 + z 0 )(x + z)
F (x, y, z) = !(0, 2, 5, 7)
In other
Prof. words,
Wangrok Oh(CNU)the 1’s of the function represent
Product-of-Sums the minterms and the 0’s represent
Simplification 24 / 67
Don’t-Care Conditions
y y
yz yz
wx 00 01 11 10 wx 00 01 11 10
m0 m1 m3 m2 m0 m1 m3 m2
00 X 1 1 X 00 X 1 1 X
w!x!
m4 m5 m7 m6
w!z m4 m5 m7 m6
01 0 X 1 0 01 0 X 1 0
m12 m13 m15 m14
x m12 m13 m15 m14
x
11 0 0 1 0 11 0 0 1 0
w m8 m9 m11 m10
w m8 m9 m11 m10
10 0 0 1 0 10 0 0 1 0
z z
yz yz
(a) F " yz # w!x! (b) F " yz # w!z
FIGURE 3.15
Example with don’t-care conditions
Prof. Wangrok Oh(CNU) Don’t-Care Conditions 26 / 67
Don’t-Care Conditions
F = yz + w0 x0 =
P
(0, 1, 2, 3, 7, 11, 15)
F = yz + w0 z =
P
(1, 3, 5, 7, 11, 15)
F = z(w0 + y) =
P
(1, 3, 5, 7, 11, 15)
Inverter x x!
x
AND y xy
OR (x!y!)! " x # y
OR (x!y!)! " x # y
The conversion
FIGURE 3.16 from AND, OR and complement to NAND can be
done
Logicby simple with
operations circuit manipulation
NAND gates techniques that change AND-OR
diagrams to NAND diagrams
x x
y (xyz)! y x! # y! # z! " (xyz)!
z z
(a) AND-invert (b) Invert-OR
FIGURE 3.17
When both symbols
Two graphic symbolsforare mixed inNAND
a three-input the same
gate diagram, the circuit is
said to be in mixed notation
A
B
F
C
D
(a)
A A
B B
F F
C C
D D
(b) (c)
FIGURE 3.18
h i0
0
F = F(AB)
Three ways to implement (CD)0
= AB + CD = AB + CD
xy! z z
xy! z z
(a)
F = xy 0 + 0
(a) x y + z
x x x
y! y! y!
x! x!
F x! F
y F y F
y
z z!
(b)
z! (c)
C
F = A(CD + B) + BC 0
94 Chapter 3 Gate-Level Minimization
D
B
C
A
D
F
B
B
A
C!
F
B (a) AND–OR gates
C!
(a) AND–OR gates
C
D
B!
C
A
D
F
B
B!
C!
A
F
B (b) NAND gates
1 C!FIGURE
Convert all
3.20 AND gates to NAND gates with AND-invert symbols
2 Implementing
Convert all FOR
= A(CD + B)
gates BC!
to+ NAND gates
(b) NAND with invert-OR symbols
gates
FIGURE 3.20
Although
Oh(CNU)it is possible to remove the parentheses and reduce the expression into a standard
Prof. Wangrok Implementing F = A(CD +NAND
B) +and
BC!
NOR Implementation 33 / 67
NAND and NOR Implementation
3 Check all the bubbles in the diagram: For every bubble that is not
compensated by another bubble → Insert an inverter
(AB 0 3.6
F = Section 0
+ ANAND
B)(C + D0 )
and NOR Implementation 95
A
B!
A!
B F
C
D!
(a) AND–OR gates
A
B!
A!
B F
C!
D
(b) NAND gates
FIGURE 3.21
Implementing F = (AB! NAND
Prof. Wangrok Oh(CNU) + A!B)and
(CNOR
+ D!)
Implementation 34 / 67
NAND and NOR Implementation
NOR Implementation
NOR operation is the dual of the NAND operation
All procedures and rules for NOR logic are the duals of the
corresponding procedures and rules developed for NAND logic
The NOR gate is another universal gate that can be used to
96 Chapter 3 Gate-Level Minimization
implement any Boolean function
Inverter x x"
x
OR x!y
y
FIGURE 3.22
Logic operations with NOR gates
x
Prof. Wangrok Oh(CNU) x
NAND and NOR Implementation 35 / 67
y
Example (F = (A +Section
B)(C3.7 Other Two-Level Implementations
+ D)E) 97
A
B
C
F
D
E!
FIGURE 3.24 The OR-AND pattern can easily be detected by the removal of the
Implementing Fbubbles
= (A + along
B)(C +
theD)E
same line
Variable E is complemented to compensate for the third bubble at
A! the input of the second-level gate
B
F
A
B!
C
Prof. Wangrok Oh(CNU) NAND and NOR Implementation 37 / 67
Section 3.7 Other Two-Level Implementations 97
NAND and NOR Implementation
A
B
Multilevel AND-OR diagram to an all-NOR diagram
1 Convert Ceach OR gate to an OR-invert and each AND gate to an
F
invert-AND
D
2 Any bubble that is not compensated by another bubble along the
same lineE! needs an inverter
FIGURE 3.24
Example (F = (AB + A B)(C + D0 ))
0 0
Implementing F = (A + B)(C + D)E
A!
B
F
A
B!
C
D!
FIGURE 3.25
The Fequivalent
Implementing AND-OR
= (AB! + A!B)(C diagram
+ D!) with can be
NOR gates recognized from the NOR
diagram by removing all the bubbles
ToAND–OR
The equivalent compensate for can
diagram thebebubbles in four
recognized from inputs,
the NORitdiagram
is necessary to
by remov-
complement
ing all the bubbles. the corresponding
To compensate input
for the bubbles in literals
four inputs, it is necessary to
complement the corresponding input literals.
A A
B B
F ! (AB " CD)#
C C
D D
(a) Wired-AND in open-collector (b) Wired-OR in ECL gates
AND gate is drawn withTTL NAND
the gates.
lines going through the center of the
gate (AND–OR–INVERT) (OR–AND–INVERT)
AND-OR-INVERT functionSimilarly, the NOR outputs of ECL gates can be tied together to
Prof. Wangrok Oh(CNU) function.
Other Two-Level The logic
Implementations function implemented by the circuit of 39
Fig. 3.2
/ 67
Other Two-Level Implementations
RE 3.26
d logic OR-AND-INVERTER function
Wired-AND logic with two NAND gates
Wired-OR in emitter-coupled logic (ECL) gates
arly, the NOR outputs of ECL gates can be tied together to perform a wired-OR
n. The logic function implemented by the circuit of Fig. 3.26(b) is
Prof. Wangrok Oh(CNU) Other Two-Level Implementations 40 / 67
Other Two-Level Implementations
Nondegenerate Forms
How many two-level combinations of gates are possible?
4 types of gates: AND, OR, NAND and NOR → 16 possible
combinations
The same type of gate can be in the first and second levels
1 8 of these combinations are said to be degenerate forms
2 They degenerate to a single operation
3 AND-AND configuration = AND of all input variables
The remaining eight nondegenerate forms produce an
implementation in sum-of-products form or product-of-sums form
1 AND-OR/OR-AND
2 NAND-NAND/NOR-NOR
3 NOR-OR/NAND-AND
4 OR-NAND/AND-NOR
A A A
B B B
C C C
F F F
D D D
E E E
FIGURE 3.27
AND-OR AND–OR–INVERT
implementation requires
circuits, F = (AB +an
CD expression
in sum-of-products
+ E )!
form
AND-OR-INVERT implementation is similar except for the inversion
C C C
F F F
D D D
E E E
FIGURE 3.28 0
OR–AND–INVERT F = (A
circuits, F = +
3 ( AB)(C +DD)E
+ B )(C + )E 4!
EXAMPLE
Prof. Wangrok Oh(CNU) 3.10 Other Two-Level Implementations 44 / 67
Other Two-Level Implementations
hapterExample
3 Gate-Level Minimization
(Implement a function with the four 2-level forms)
y
yz
x 00 01 11 10
m0 m1 m3 m2
F = x!y!z! + xyz!
0 1 0 0 0
F! = x!y + xy! + z
x!y!z!
m4 m5 m7 m6
xyz!
x 1 0 0 0 1
z
(a) Map simplification in sum of products
The complement of the function is simplified into sum-of-products
x!
by combining the 0’s x!
y F 0 = x0 y +y xy 0 + z
x
Normal output: F = (x0 y + xy 0 + z)
x
0
← AND-OR-INVERT
F F
y! y!
Prof. Wangrok Oh(CNU) Other Two-Level Implementations 45 / 67
00 01 11 10
m0 m1 m3 m2
F = x!y!z! + xyz!
Other Two-Level
x!y!z!
Implementations
0 1 0 0 0
F! = x!y + xy! + z
m4 m5 m7 m6
xyz!
x 1 0 0 0 1
Example (Continued) z
(a) Map simplification in sum of products
AND-NOR and NAND-AND implementations
x! x!
y y
x x
F F
y! y!
z z
AND–NOR NAND–AND
(b) F " (x!y # xy! # z)!
OR-AND-INVERT require a simplified expression of the complement
of the function in product-of-sums form
x x
y y
z z
F F
Prof. Wangrokx!Oh(CNU) x!
Other Two-Level Implementations 46 / 67
x! x!
Other Two-Level
y
Implementations
y
Example
x (Continued) x
F F
y! y!
1 Combine the 1’s in the map: F = x y z + xyz 0 0 0 0
x x
y y
z z
F F
x! x!
y! y!
z z
OR–NAND NOR–OR
(c) F " [(x # y # z) (x! # y! # z)]!
FIGURE 3.29
Other two-level implementations
Prof. Wangrok Oh(CNU) Other Two-Level Implementations 47 / 67
Exclusive-OR Function
Exclusive-OR (XOR)
1 Denoted by the symbol ‘⊕’
2 Performs the Boolean operation: x ⊕ y = xy 0 + x0 y
Exclusive-OR is equal to 1 if x and y differ in value
Exclusive-NOR: Equivalence
(x ⊕ y)0 = xy + x0 y 0
A⊕B = B⊕A
(A ⊕ B) ⊕ C = A ⊕ (B ⊕ C) = A ⊕ B ⊕ C
104 Chapter 3 Gate-Level
Implementation Minimization
of two-input exclusive-OR with AND-OR-NOT gates
x
x!y
Exclusive-OR Function
y
x!y
(x0 + y 0 )x + (x0 + y 0 )y = xy 0 + x0 y = x ⊕ y
Only a limited number of Boolean functions can be expressed in terms of exclusive-OR
operations.
XOR Nevertheless,
emerges this function
quite often duringemerges quite often
the design of during
digitalthesystems
design of digital
systems. It is particularly useful in arithmetic operations and error detection and correc-
tion Useful in arithmetic operations
1 circuits.
2 Error detection and correction circuits
Odd Function
The exclusive-OR operation with three or more variables can be converted into an
ordinary Boolean function by replacing the { symbol with its equivalent Boolean
Prof. expression.
Wangrok Oh(CNU)In particular, the three-variable case can be converted to a Boolean expres-
Exclusive-OR Function 50 / 67
Exclusive-OR Function
Odd Function
Exclusive-OR with three or more variables can be converted into an
ordinary Boolean function by replacing ⊕ with its equivalent Boolean
expression
FIGURE 3.31 C C
(a)aOdd
Map for A ! B ! C function (b) Even function F ! (A ! B ! C)"
function F !exclusive-OR
three-variable
FIGURE 3.31
A A
Map for a three-variable exclusive-OR function
B B
A A
C C
B (a) 3-input odd function B (b) 3-input even function
FIGURE 3.32
C C
Logic diagram of odd and even functions
(a) 3-input odd function (b) 3-input even function
FIGURE 3.32
Logic diagram of odd and even functions
Prof. Wangrok Oh(CNU) Exclusive-OR Function 52 / 67
Exclusive-OR Function
4-variable exclusive-OR
C C
CD CD
AB 00 01 11 10 AB 00 01 11 10
m0 m1 m3 m2 m0 m1 m3 m2
00 1 1 00 1 1
m4 m5 m7 m6 m4 m5 m7 m6
01 1 1 01 1 1
B m12 m13 m15 m14 B
m12 m13 m15 m14
11 1 1 11 1 1
A A m8 m9 m11 m10
m8 m9 m11 m10
10 1 1 10 1 1
D D
(a) Odd function F ! A ! B ! C ! D (b) Even function F ! (A ! B ! C ! D)"
FIGURE 3.33
Map for a four-variable exclusive-OR function
Prof. Wangrok Oh(CNU) Exclusive-OR Function 53 / 67
Exclusive-OR Function
0 0 0
Section 3.8 Exclusive-OR Function 107 0 0 1
Example (3-bit Message with an Even-Parity Bit) 0 1 0
Table 3.3 0 1 1
Even-Parity-Generator Truth Table 1 0 0
1 0 1
Three-Bit Message Parity Bit
1 1 0
x y z P 1 1 1
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0 x
1 0 0 1 x y
1 0 1 0 y P
1 1 0 0 z
1 1 1 1
z P
(a) 3-bit even parity generator (b) 4
For even parity, bit P must be generated to make the total number
FIGURE 3.34
of 1’s even x Logic diagram of a parity generator and checker
P should constitute
y an odd function: P = x ⊕ y ⊕ z
The output
P of the parity checker, denoted by C C will be equal to 1 if
z
an error occurs (odd parity)
P
odd function because it is equal to 1 for those minter
an odd number of 1’s. Therefore, P can be expressed a
(a) 3-bit even parity generator (b) 4-bit even parity checker
function:
Prof. Wangrok Oh(CNU) Exclusive-OR Function 55 / 67
Section 3.8 Exclusive-OR Function 107
Exclusive-OR Function
Table 3.3
Even-Parity-Generator Truth Table
Example (Continued)
Chapter 3 Gate-Level Minimization Three-Bit Message Parity Bit
Table 3.4 x y z P
Even-Parity-Checker Truth Table
0 0 0 0
Four Bits Parity Error
Received 0 Check 0 1 1
0 1 0 1
x y z P C
0 1 1 0
0 0 0 0 1 0 0 0 1
0 0 0 1 1 1 0 1 0
0 0 1 0 1
1 1 0 0
0 0 1 1 0
0 1 0 0 1 1 1 1 1
0 1 0 1 0
0 1 1 0 0
0 1 1 1 1
1 0 0 0 1
1 0 0 1 0
1 0 1 0 0
x
1 x0 1 1 1 y
1 1 0 0 0
1 y1 0 1 1 P C
1 1 1 0 1 z
1 1 1 1 0
z P
(a) 3-bit even parity generator (b) 4-bit even parity checker
represents an odd function. The parity checker can be implemented with exclusive-
OR gates: FIGURE 3.34
C =x⊕y⊕z⊕P
= x{y{
Logic Cdiagram ofza{parity
P generator and checker
The logic diagram of the parity checker is shown in Fig. 3.34(b).
Generator can be implemented with the checker ← z ⊕ 0 = z
It is worth noting that the parity generator can be implemented with the circuit of
Same circuit can be used for both parity generation and checking
Fig. 3.34(b) if the input P is connected to logic 0 and the output is marked with P. This is
because z { 0 = z, causing the value of z to pass through the gate unchanged. The advan-
oddthe
tage of this strategy is that function because
same circuit can beitused
is equal toparity
for both 1 forgeneration
those minterms
and whose numerical values have
checking. an odd number of 1’s. Therefore, P can be expressed as a three-variable exclusive-OR
It is obvious from theOh(CNU)
foregoing example that parity generation and checking circuits
function:
Prof. Wangrok Exclusive-OR Function 56 / 67
Hardware Description Language
Module Declaration
The term module refers to the text enclosed by the keyword pair
module and endmodule
Module is the fundamental descriptive unit in the Verilog language
Combinational logic can be described by
A schematic connection of gates
A set of Boolean equations
A truth table
Each type of description can be developed in Verilog
A w1
G1 G3 D
B
C G2 E
TheOh(CNU)
Prof. Wangrok port list of a module is the interface
Hardware between
Description Language the module and its environment. 59 / 67
Hardware Description Language
Gate Delays
All physical circuits exhibit a propagation delay between the
transition of an input and a resulting transition of an output
When an HDL model of a circuit is simulated, it is some- times
necessary to specify the amount of delay from the input to the
output of its gates
In Verilog, the propagation delay of a gate is specified in terms of
time units and by the symbol #
The numbers associated with time delays in Verilog are dimensionless
The association of a time unit with physical time is made with the
timescale compiler directive
Compiler directives start with the ‘
Directive is specified before the declaration of a module and applies
to all numerical values of time in the code that follows
Example: ‘timescale 1ns/100ps
The first number specifies the unit of measurement for time delays
The second number specifies the precision for which the delays are
rounded off
A
B
C
D
E
FIGURE 3.36
Simulation
In order output of HDL
to simulate Examplewith
a circuit 3.3 an HDL, it is necessary to apply
inputs to the circuit
An probes
HDL(wires)
description thatofprovides
to the outputs the circuit. the
(The stimulus to a design
interaction between is genera-
the signal called a
testtors of the stimulus module and the instantiated circuit module is illustrated in Fig. 4.36.)
bench
Hardware signal generators are not used to verify an HDL model: The entire simula-
tion exercise is done with software models executing on a digital computer under the
direction of an HDL simulator. The waveforms of the input signals are abstractly modeled
(generated) by Verilog statements specifying waveform values and transitions. The initial
keyword is used with a set of statements that begin executing when the simulation is ini-
tialized; the signal activity associated with initial terminates execution when the last state-
ment has finished executing. The initial statements are commonly used to describe
Prof. waveforms in a test bench.
Wangrok Oh(CNU) The set
Hardware of statements
Description to be executed is called a block statement
Language 62 / 67
Hardware Description Language
User-Defined Primitives
System primitives: Verilog descriptions defined by the system
User can create additional primitives by defining them in tabular
form → User-defined primitives (UDPs)
UDP descriptions do not use the keyword pair module and
endmodule
Keyword pair primitive and endprimitive are used for UDPs
Define an UDP with a truth table
1 Declared with the keyword primitive followed by a name and port list
2 There can be only one output and it must be listed first in the port
list and declared with keyword output
3 There can be any number of inputs
4 The order in which they are listed in the input declaration must
conform to the order in which they are given values in the table that
follows
5 The truth table is enclosed within the keywords table and endtable
6 The values of the inputs are listed in order ending with a colon (:)
7 Output is always the last entry in a row and is followed by a
semicolon (;)
8 The declaration of a UDP ends with the keyword endprimitive
A
B UDP_02467 E
C
F
D
FIGURE 3.37
Schematic for Circuit model
1 // Verilog with_UDP_02467
: Circuit instantiation of
Circuit_UDP_02467
2 module C i r c u i t _ w i t h _ U D P _ 0 2 4 6 7 (e ,f ,a ,b ,c , d ) ;
Note that the variables listed on top of the table are part of a comment and are show
3 output e , f ;
only for
4
clarity.
input The system
a ,b ,crecognizes
,d; the variables by the order in which they are listed
in the input
5
declaration. A user-defined primitive can be instantiated in the construction
of other
6 modules (digitalM0circuits),
UDP_02467 (e ,a ,bjust
, c )as
; the system primitives are used. For example
the declaration
7 and (f ,e , d ) ; // Option gate instance name omitted
8 endmodule
Circuit _with _UDP_ 02467 (E, F, A, B, C, D);
will produce a circuit that implements the hardware shown in Figure 3.37.
Although Verilog HDL uses this kind of description for UDPs only, other HDLs and
computer-aided design (CAD) systems use other procedures to specify digital circuit
in Wangrok
Prof. tabular form. The tables can
Oh(CNU) be processed
Hardware by CAD software to derive an efficient
Description Language 67 / gat
67