Download Two-Level Logic Optimization - Lecture Slides | ECE 474A and more Exams Electrical and Electronics Engineering in PDF only on Docsity!
Two-level Logic Optimization – Part 1
ECE 474a/575a Susan Lysecky 2 of 31
Overview
• Synthesis and optimization of digital circuits
Process by which a higher-level design specification is
converted to a lower-level specification
Several levels of synthesis within digital design
Physical Design
Placement andRouting Layout
Behavioral Synthesis Logic Synthesis
RTL
description
High-Level Synthesis
`timescale 1ns / 1ps module FibGen(clk, rst, enb, out); input clk, rst, enb;output [16:0] out; reg [16:0] out; always @ (posedge rst or posedge clk)begin
Verilog/VHDL, C, SystemC, etc..
Net-list
Logic optimization
User constraints Technology library
Manufacturing and Packaging
Flow of signals or transfer of data between registers and the operations performed on those registers
List of logic gates and the corresponding connections
Lowest level physical specification providing information for the fabrication process
ECE 474a/575a Susan Lysecky 3 of 31
Two-level Logic Optimization
• Two-level logic
Circuit with only two levels (ORed AND gates)
• Basically sum-of-products form
An equation written as an ORing of product terms
F = xy + x’y’
F
x y
x’ y’
F = a’bc + c’ + de
F
a’
c
d e
b
c’
F = ((jk) + l) + mn’
F
j k
m n’
l
Are these two-level logic?
F = (rs) • (tu)
F
r s
t u
technically yes, but not what we mean in terms of logic minimization
ECE 474a/575a Susan Lysecky 4 of 31
Two-level Logic Optimization
• Optimization
Defined as better in all criteria of interest
Previously considered several design criteria
- Delay – the time from inputs changing to new correct stable output
- Size – the number of transistors
We consider size minimization only. In reality requires a balance of many criteria
metrics
- Cost, reliability, time-to-market, etc...
F = xy + x’y’
F
x y
x’ y’
F = xyz + xyz’ + x’y’z’ + x’y’z
F
x
x’
x’
x’
y
y’
y’
y’
z
z’
z’
z’
- Reducing number of gates needed
- Reducing size of gates (i.e number of gate inputs)
ECE 474a/575a Susan Lysecky 7 of 31
Two-Level Size Minimization Using K-maps
General K-map method
1. Convert the function’s equation
into sum-of-products form
2. Place 1s in the appropriate K-
map cells for each term
3. Cover all 1s by drawing the
fewest largest circles, with
every 1 included at least once;
write the corresponding term for
each circle
4. OR all the resulting terms to
create the minimized function.
Example: Minimize G = a + a’b’c’ + b*(c’ + bc’)
Step 3 - Cover 1s
Step 4 - OR terms
Step 1 - Convert to sum-of-products
Step 2 - Place 1’s in the appropriate cells
G = a + a’b’c’ + bc’ + bc’
G = a + c’
a
bc’
1 a’b’c’ 1 1 1 1
G (^) bc a
1 0 0 1
00 01 11 10
1 1
0
1 1 1
G (^) bc a
a
c’
ECE 474a/575a Susan Lysecky 8 of 31
Don’t Care Input Combinations
• Don’t Care Input
Input combination that the
designer doesn’t care what the
output is
- i.e. input condition can never
occur
Thus, make output be 1 or 0 for
those cases in a way that best
minimizes the equation
Represented as X s in K-map
x 0 0 0
00 01 11 10
1 1
0
1 x 1
G (^) bc a
a
a b c Z 0 0 0 x 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 x
abc = 000 and abc = 111 are unused inputs
including this term doesn’t help us
including this term enables better minimization
ECE 474a/575a Susan Lysecky 9 of 31
Two-Level Logic Size Minimization
• Graphical minimizing by hand
5 and 6 variable maps exist, but
hard to use
• May not yield minimum cover
depending on order we choose
Is error prone
• Minimization thus typically
done by automated tools
0 1 0 0
00 01 11 10
1 1
00
01 1 0
0 0 0 0
0 0
11
10 0 0
ef cd 0 0 1 0
00 01 11 10
1 1
00
01 1 0
0 0 1 0
1 0
11
10 1 0
0 0 0 0
00 01 11 10
0 0
00
01 0 0
0 0 0 0
0 0
11
10 0 0
1 0 1 0
00 01 11 10
1 1
00
01 1 0
0 0 1 1
0 0
11
10 0 1
b = 0 b = 1
a = 0
a = 1
ECE 474a/575a Susan Lysecky 10 of 31
Logic Optimization Techniques
• Logic Optimization Techniques
K-maps (Graphical)
Quine-McCluskey (Exact Algorithm)
Espresso (Heuristic)
• Other Generalized Heuristics
Branch-and-bound
Simulated Annealing
Dynamic Programming
many more exists …
ze
ECE 474a/575a Susan Lysecky 13 of 31
Quine-McCluskey
• Developed in the mid-50’s
• Finds the minimized representation of a Boolean function
• Provides systematic way of generating all prime implicants then extracting
a minimum set of primes covering the on-set
• Accomplishes this by repeatedly applying the Uniting theorem
Uniting theorem: ab + ab’ = a(b+b’) = a*1 = a
ECE 474a/575a Susan Lysecky 14 of 31
Review Definitions
• Minterm
product term whose literals include
every variable of the function
exactly once in true or
complemented form
• On-set
All minterms that define when F=
• Off-set
All minterms that define when F=
F(a, b, c) = a’b’c + ab
literals: a, b, c
on-set: a’b’c, abc’, abc
minterms: a’b’c
off-set: a’b’c’, a’bc’, a’bc, ab’c’, ab’c
ab abc
abc’
ECE 474a/575a Susan Lysecky 15 of 31
Review Definitions
• Implicant
Any product term (minterm or other) that
when 1 causes F=
On K-map, any legal (but not necessarily
largest) circle
• Prime implicant
Maximally expanded implicant – any
further expansion would cover 1s not in on-
set
• Essential prime implicant
The only prime implicant that covers a
particular minterm in a function’s on-set
Importance: We must include all essential
PIs in a function’s cover
In contrast, some, but not all, non-essential
PIs will be included
Note: We use K-maps are for illustration purposes only
G (^) bc a
a’b’ ab
4 prime implicants
2 essential prime implicants
F (^) bc a
ab
abc’
abc
a’b’c (^) 4 implicants
F bc a
ab
a’b’c (^) 2 prime Implicants
ECE 474a/575a Susan Lysecky 16 of 31
Quine-McCluskey
Quine-McCluskey Algorithm
1. Find all the prime implicants
2. Find all the essential prime implicants
3. Select a minimal set of remaining prime implicants that covers the
on-set of the function
ECE 474a/575a Susan Lysecky 19 of 31
Quine-McCluskey – Example 1
Step 2: Find all essential prime implicants
- Create prime implicant chart
Columns are minterm indicies, rows are the prime implicants we determined
F = a’b’c’ + a’b’c + ab’c + abc’ + abc
derived in
Step
ECE 474a/575a Susan Lysecky 20 of 31
Quine-McCluskey – Example 1
Step 2: Find all essential prime implicants (cont’)
- Place “X” in a row if the prime implicant covers the minterm
- Essential prime implicants are found by looking for rows with a single “X”
If minterm is covered by one and only one prime implicant – it’s an essential prime implicant
- Add essential prime implicants to the cover
essential prime implicants Cover: F = a’b’ + ac
ECE 474a/575a Susan Lysecky 21 of 31
Quine-McCluskey – Example 1
Step 3: Select a minimal set of remaining prime implicants that covers the on
set of the function
- Step 2 determined essential prime implicants, and added to cover
Essential prime implicants may cover other minterms, cross out all minterms covered by the
prime implicants
Minterm only needs to be covered once
Cover: F = a’b’ + ac
ECE 474a/575a Susan Lysecky 22 of 31
Quine-McCluskey – Example 1
Step 3: Select a minimal set of remaining prime implicants that covers the on
set of the function (cont’)
- Based on which minterms are left, add minimal set of prime implicants to cover
Cover: F = a’b’ + ac
Only minterm 5 remains – either prime
implicant (1,5) or (5,7) will work
ECE 474a/575a Susan Lysecky 25 of 31
Quine-McCluskey – Example 2
Step 1: Find all the prime implicants (cont’)
- Compare each entry in Gi to each entry in Gi+ If they differ by 1 bit, we can apply the uniting theorem and eliminate a literal Add check to minterm/implicant to remind us that it is not a prime implicant
G
G
G
G
G
(2,9)? N
(4,3)? N
no new implicants are
generated – end of step 1
G1 (2,3) 001-
G0 (0,2) 00-
G
G
G
G
G2 (3,7) 0-
(4,9)? N
(3,13)? N
(6,11)? N
(6,13)? N
(9,7)? N
ECE 474a/575a Susan Lysecky 26 of 31
Quine-McCluskey – Example 2
Step 2: Find all essential prime implicants
- Create prime implicant chart
Columns are minterm indicies, rows are the prime implicants we determined
- Place “X” in a row if the prime implicant covers the minterm
- Essential prime implicants are found by looking for rows with a single “X”
Add essential prime implicant to the cover
essential prime implicants
Cover:
F = w’z’ + wz
ECE 474a/575a Susan Lysecky 27 of 31
Quine-McCluskey – Example 2
Step 3: Select a minimal set of remaining prime implicants that covers the on
set of the function
- Cross out all minterms covered by the prime implicants
- Based on which minterms are left, add minimal set of prime implicants to cover
Cover:
F = w’z’ + wz + yz
Minterm 3 and 7 remain – either prime implicant (2,3,6,7) or (3,7,11,15) will work
ECE 474a/575a Susan Lysecky 28 of 31
Quine-McCluskey – Example 3
- What if determining minimum prime implicant cover is not so easy?
- Assume we have the implicant table below
Determine prime implicants, add to cover
essential prime implicants
Cover: F = w’yz’ + x’y’z
ECE 474a/575a Susan Lysecky 31 of 31
Quine-McCluskey – Example 3
- Final cover = essential prime implicants +
minimum prime implicant cover
P2 (9, 13) 10-
P1 (6,7) 011-
P4 (13, 15) 1-
P3 (7, 15) -
Minimum prime implicant cover list: (option 1 - P1P4) w’xy,wyz
(option 2 - P2P3) wx’z, xyz
(option 3 - P3P4) xyz, wyz
Minimized Equation F = w’yz’ + x’yz + xyz + wyz
P = P1P2P3 + P1P4 + P2P3 + P3P
more terms than other solutions
Any of these provide minimum cover
w’yz’, x’y’z
Essential Prime Implicants