Digital Design & Computer Arch.
Transcript of Digital Design & Computer Arch.
![Page 1: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/1.jpg)
Digital Design & Computer Arch.Lecture 6: Sequential Logic Design
Prof. Onur Mutlu
ETH ZürichSpring 2020
6 March 2020
![Page 2: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/2.jpg)
We Are Almost Done with Thisn Building blocks of modern computers
q Transistorsq Logic gates
n Combinational circuits
n Boolean algebra
n How to use Boolean algebra to represent combinational circuits
n Minimizing logic circuits
2
![Page 3: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/3.jpg)
Agenda for Today and Next Weekn Today
q Wrap up Combinational Logic and Circuit Minimization
q Start (and finish) Sequential Logic
n Next week
q Hardware Description Languages and Verilog n Combinational Logicn Sequential Logic
q Timing and Verification3
![Page 4: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/4.jpg)
Assignment: Required Lecture Videon Why study computer architecture?n Why is it important?n Future Computing Architectures
n Required Assignmentq Watch Prof. Mutlu’s inaugural lecture at ETH and understand itq https://www.youtube.com/watch?v=kgiZlSOcGFM
n Optional Assignment – for 1% extra creditq Write a 1-page summary of the lecture and email us
n What are your key takeaways?n What did you learn?n What did you like or dislike?n Submit your summary to Moodle – Deadline: April 1
4
![Page 5: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/5.jpg)
Extra Assignment: Moore’s Law (I)n Paper reviewn G.E. Moore. "Cramming more components onto integrated
circuits," Electronics magazine, 1965
n Optional Assignment – for 1% extra creditq Write a 1-page review q Upload PDF file to Moodle – Deadline: April 1
n I strongly recommend that you follow my guidelines for (paper) review (see next slide)
5
![Page 6: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/6.jpg)
Extra Assignment 2: Moore’s Law (II)n Guidelines on how to review papers critically
q Guideline slides: pdf pptq Video: https://www.youtube.com/watch?v=tOL6FANAJ8c
q Example reviews on “Main Memory Scaling: Challenges and Solution Directions” (link to the paper)n Review 1n Review 2
q Example review on “Staged memory scheduling: Achieving high performance and scalability in heterogeneous systems” (link to the paper)n Review 1
6
![Page 7: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/7.jpg)
Assignment: Required Readingsn Combinational Logic
q P&P Chapter 3 until 3.3 + H&H Chapter 2n Sequential Logic
q P&P Chapter 3.4 until end + H&H Chapter 3 in fulln Hardware Description Languages and Verilog
q H&H Chapter 4 in fulln Timing and Verification
q H&H Chapters 2.9 and 3.5 + (start Chapter 5)
n By the end of next week, make sure you are done with q P&P Chapters 1-3 + H&H Chapters 1-4
7
![Page 8: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/8.jpg)
Wrap-Up Combinational Logic Circuits and Design
8
![Page 9: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/9.jpg)
Recall: Tri-State Buffern A tri-state buffer enables gating of different signals onto a
wire
n Floating signal (Z): Signal that is not driven by any circuitq Open circuit, floating wire
9
![Page 10: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/10.jpg)
Recall: Example: Use of Tri-State Buffersn Imagine a wire connecting the CPU and memory
q At any time only the CPU or the memory can place a value on the wire, both not both
q You can have two tri-state buffers: one driven by CPU, the other memory; and ensure at most one is enabled at any time
10
![Page 11: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/11.jpg)
Recall: Example Design with Tri-State Buffers
11
CPU
Memory
GateMem
GateCPU
Shared Bus
![Page 12: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/12.jpg)
Recall: Another Example
12
![Page 13: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/13.jpg)
Multiplexer Using Tri-State Buffers
13
![Page 14: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/14.jpg)
Aside: Logic Using Multiplexersn Multiplexers can be used as lookup tables to perform logic
functions
14
![Page 15: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/15.jpg)
Aside: Logic Using Multiplexers (II)n Multiplexers can be used as lookup tables to perform logic
functions
15
![Page 16: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/16.jpg)
Aside: Logic Using Multiplexers (III)n Multiplexers can be used as lookup tables to perform logic
functions
16Read H&H Chapter 2.8
![Page 17: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/17.jpg)
Aside: Logic Using Decoders (I)n Decoders can be combined with OR gates to build logic
functions.
17Read H&H Chapter 2.8
![Page 18: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/18.jpg)
Logic Simplification using Boolean Algebra Rules
18
![Page 19: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/19.jpg)
Recall: Full Adder in SOP Form Logic
19
ai bi Si0 0 00 1 0
10 011 1
carryi carryi+10
00
01111
01
11 1
00
0
0111
01101001
Full Adderai
bi
ci
ai
bi
cici+1
si
![Page 20: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/20.jpg)
Goal: Simplified Full Adder
20
How do we simplify Boolean logic?
![Page 21: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/21.jpg)
Quick Recap on Logic Simplificationn The original Boolean expression (i.e., logic circuit) may not
be optimal
n Can we reduce a given Boolean expression to an equivalent expression with fewer terms?
n The goal of logic simplification:q Reduce the number of gates/inputsq Reduce implementation cost
21
F = ~A(A + B) + (B + AA)(A + ~B)
F = A + B
A basis for what the automated design tools are doing today
![Page 22: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/22.jpg)
Logic Simplificationn Systematic techniques for simplifications
q amenable to automation
22
Key Tool: The Uniting Theorem —
𝑭 =
A's value does NOT change within the ON-set rows
B's value changes within the rows where F==1 (“ON set”)
B's value stays the same within the ON-set rows
A's value changes within the ON-set rows
➙ B is eliminated, A remains
➙ A is eliminated, B remains
If an input (B) can change without changing the output, that input value is not needed
𝑭 = 𝑨$𝑩 + 𝑨𝑩
𝑨$𝑩 + 𝑨𝑩 = 𝑨 $𝑩 + 𝑩 = 𝑨 𝟏 = 𝑨
𝑮 = $𝑨$𝑩 + 𝑨$𝑩 = $𝑨 + 𝑨 $𝑩 = $𝑩
Essence of Simplification:Find two element subsets of the ON-set where only one variable changes its value. This single varying variable can be eliminated!
![Page 23: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/23.jpg)
Logic Simplification:Karnaugh Maps (K-Maps)
23
![Page 24: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/24.jpg)
Karnaugh Maps are Fun…n A pictorial way of minimizing circuits by visualizing
opportunities for simplificationn They are for you to study on your own…
n See Backup Slides n Read H&H Section 2.7n Watch videos of Lectures 5 and 6 from 2019 Digitech
course:q https://youtu.be/0ks0PeaOUjE?list=PL5Q2soXY2Zi8J58xLKBNF
QFHRO3GrXxA9&t=4570q https://youtu.be/ozs18ARNG6s?list=PL5Q2soXY2Zi8J58xLKBN
FQFHRO3GrXxA9&t=220
24
![Page 25: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/25.jpg)
Sequential Logic Circuits and Design
25
![Page 26: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/26.jpg)
What We Will Learn Todayn Circuits that can store information
q Cross-coupled inverterq R-S Latchq Gated D Latchq D Flip-Flopq Register
n Finite State Machines (FSM)q Moore Machineq Mealy Machine
n Verilog implementations of sequential circuits (next week)
26
![Page 27: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/27.jpg)
Circuits that Can Store Information
27
![Page 28: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/28.jpg)
Introductionn Combinational circuit output depends only on current inputn We want circuits that produce output depending on
current and past input values – circuits with memoryn How can we design a circuit that stores information?
28
Sequential Circuit
CombinationalCircuitin
puts
outputs
StorageElement
![Page 29: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/29.jpg)
Capturing Data
29
![Page 30: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/30.jpg)
Basic Element: Cross-Coupled Inverters
n Has two stable states: Q=1 or Q=0. n Has a third possible “metastable” state with both outputs
oscillating between 0 and 1 (we will see this later)n Not useful without a control mechanism for setting Q
30Image source: Harris and Harris, Digital Design and Computer Architecture, 2nd Ed., p.110.
![Page 31: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/31.jpg)
More Realistic Storage Elementsn Have a control mechanism for setting Q
q We will see the R-S latch soonq Let’s look at an SRAM (static random access memory) cell first
n We will get back to SRAM (and DRAM) later
31
wordlinebitline bitline
SRAM cell
![Page 32: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/32.jpg)
The Big Picture: Storage Elementsn Latches and Flip-Flops
q Very fast, parallel accessq Very expensive (one bit costs tens of transistors)
n Static RAM (SRAM)q Relatively fast, only one data word at a timeq Expensive (one bit costs 6+ transistors)
n Dynamic RAM (DRAM)q Slower, one data word at a time, reading destroys content
(refresh), needs special process for manufacturingq Cheap (one bit costs only one transistor plus one capacitor)
n Other storage technology (flash memory, hard disk, tape)q Much slower, access takes a long time, non-volatileq Very cheap
![Page 33: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/33.jpg)
Basic Storage Element:The R-S Latch
33
![Page 34: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/34.jpg)
The R-S (Reset-Set) Latchn Cross-coupled NAND gates
q Data is stored at Q (inverse at Q’)q S and R are control inputs
n In quiescent (idle) state, both S and R are held at 1n S (set): drive S to 0 (keeping R at 1) to change Q to 1n R (reset): drive R to 0 (keeping S at 1) to change Q to 0
n S and R should never both be 0 at the same time
34
S
R Q’
Q Input OutputR S Q1 1 Qprev1 0 10 1 00 0 Forbidden
![Page 35: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/35.jpg)
10
Why not R=S=0?
1. If R=S=0, Q and Q’ will both settle to 1, which breaksour invariant that Q = !Q’
2. If S and R transition back to 1 at the same time, Q and Q’begin to oscillate between 1 and 0 because their final values depend on each other (metastability)
q This eventually settles depending on variation in the circuits (more metastability to come in Lecture 8)
35
S
R Q’
Q Input OutputR S Q1 1 Qprev1 0 10 1 00 0 Forbidden
10
0
01
1
![Page 36: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/36.jpg)
The Gated D Latch
36
![Page 37: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/37.jpg)
The Gated D Latchn How do we guarantee correct operation of an R-S Latch?
37
S
RQ’
Q
![Page 38: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/38.jpg)
The Gated D Latchn How do we guarantee correct operation of an R-S Latch?
q Add two more NAND gates!
q Q takes the value of D, when write enable (WE) is set to 1 q S and R can never be 0 at the same time!
38
S
RQ’
Q
Write Enable
D
![Page 39: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/39.jpg)
The Gated D Latch
39
S
R Q’
Q
Write Enable
D
Input OutputWE D Q0 0 Qprev0 1 Qprev1 0 01 1 1
![Page 40: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/40.jpg)
The Register
40
![Page 41: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/41.jpg)
The Register
41
D
Q
How can we use D latches to store more data?• Use more D latches!• A single WE signal for all latches forsimultaneous writes
D2
Q2
D1
Q1
D0
Q0
3
3
Write Enable
Here we have a register, or a structure that stores more than one bit and can be read from and written to
This register holds 4 bits, and its data is referenced as Q[3:0]
![Page 42: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/42.jpg)
The Register
42
How can we use D latches to store more data?• Use more D latches!• A single WE signal for all latches forsimultaneous writes
Register x (Rx)
D3:0
Q3:0
WE
4
4
Here we have a register, or a structure that stores more than one bit and can be read from and written to
This register holds 4 bits, and its data is referenced as Q[3:0]
![Page 43: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/43.jpg)
Memory
43
![Page 44: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/44.jpg)
Memoryn Memory is comprised of locations that can be written to or
read from. An example memory array with 4 locations:
n Every unique location in memory is indexed with a unique address. 4 locations require 2 address bits (log[#locations]).
n Addressability: the number of bits of information stored in each location. This example: addressability is 8 bits.
n The entire set of unique locations in memory is referred to as the address space.
n Typical memory is MUCH larger (billions of locations)44
Addr(00):
Addr(10):
Addr(01):
Addr(11):
0100 1001
0010 0010
0100 1011
1100 1001
![Page 45: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/45.jpg)
Addressing Memory
45
Let’s implement a simple memory array with: • 3-bit addressability & address space size of 2 (total of 6 bits)
D QWE
1 Bit
Bit2 Bit1 Bit0
Bit2 Bit1 Bit0
Addr(0)
Addr(1)
6-Bit Memory Array
![Page 46: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/46.jpg)
Reading from Memory
46
How can we select the address to read?• Because there are 2 addresses, address size is log(2)=1 bit
![Page 47: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/47.jpg)
Reading from Memory
47
How can we select an address to read?• Because there are 2 addresses, address size is log(2)=1 bit
D[2] D[1] D[0]
Addr[0]
Wordline
![Page 48: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/48.jpg)
Address Decoder
Reading from Memory
48
How can we select an address to read?• Because there are 2 addresses, address size is log(2)=1 bit
D[2] D[1] D[0]
Addr[0]
Wordline
![Page 49: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/49.jpg)
Address Decoder
Reading from Memory
49
How can we select an address to read?• Because there are 2 addresses, address size is log(2)=1 bit
D[2] D[1] D[0]
Addr[0]
Multiplexer
Wordline
![Page 50: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/50.jpg)
Writing to Memory
50
How can we select an address and write to it?
![Page 51: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/51.jpg)
Writing to Memory
51
How can we select an address and write to it?• Input is indicated with Di
Di[2] Di[1] Di[0]Addr[0]
WE
![Page 52: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/52.jpg)
Putting it all Together
52
Di[2] Di[1] Di[0]
D[2] D[1] D[0]
Addr[0]
WE
Let’s enable reading and writing to a memory array
![Page 53: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/53.jpg)
A Bigger Memory Array
53
Di[2] Di[1] Di[0]
D[2] D[1] D[0]
Addr[1:0]
WE
![Page 54: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/54.jpg)
A Bigger Memory Array
54
Di[2] Di[1] Di[0]
D[2] D[1] D[0]
Addr[1:0]
WE
Address Decoder
Multiplexer
![Page 55: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/55.jpg)
Sequential Logic Circuits
55
![Page 56: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/56.jpg)
Sequential Logic Circuitsn We have looked at designs of circuit elements that can
store informationn Now, we will use these elements to build circuits that
remember past inputs
56https://www.easykeys.com/228_ESP_Combination_Lock.aspxhttps://www.fosmon.com/product/tsa-approved-lock-4-dial-combo
SequentialOpens depending on past inputs
CombinationalOnly depends on current inputs
![Page 57: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/57.jpg)
Staten In order for this lock to work, it has to keep track
(remember) of the past events!n If passcode is R13-L22-R3, sequence of states to unlock:
A. The lock is not open (locked), and no relevant operations have been performed
B. Locked but user has completed R13C. Locked but user has completed R13-L22D. Unlocked: user has completed R13-L22-R3
n The state of a system is a snapshot of all relevant elements of the system at the moment of the snapshot
q To open the lock, states A-D must be completed in orderq If anything else happens (e.g., L5), lock returns to state A
57
![Page 58: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/58.jpg)
State Diagram of Our Sequential Lockn Completely describes the operation of the sequential lock
n We will understand “state diagrams” fully later today58Image source: Patt and Patel, “Introduction to Computing Systems”, 2nd ed., page 76.
![Page 59: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/59.jpg)
Another Simple Example of Staten A standard Swiss traffic light has 4 states
A. GreenB. YellowC. RedD. Red and Yellow
n The sequence of these states are always as follows
59
A B C D
![Page 60: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/60.jpg)
Changing State: The Notion of Clock (I)
n When should the light change from one state to another?n We need a clock to dictate when to change state
q Clock signal alternates between 0 & 1
n At the start of a clock cycle ( ), system state changesq During a clock cycle, the state stays constantq In this traffic light example, we are assuming the traffic light stays in
each state an equal amount of time60
A B C D
CLK: 01
![Page 61: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/61.jpg)
Changing State: The Notion of Clock (II)n Clock is a general mechanism that triggers transition from
one state to another in a sequential circuit
n Clock synchronizes state changes across many sequential circuit elements
n Combinational logic evaluates for the length of the clock cycle
n Clock cycle should be chosen to accommodate maximum combinational circuit delayq More on this later, when we discuss timing
61
![Page 62: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/62.jpg)
Finite State Machines
62
![Page 63: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/63.jpg)
Finite State Machinesn What is a Finite State Machine (FSM)?
q A discrete-time model of a stateful systemq Each state represents a snapshot of the system at a given time
n An FSM pictorially shows1. the set of all possible states that a system can be in 2. how the system transitions from one state to another
n An FSM can model q A traffic light, an elevator, fan speed, a microprocessor, etc.
n An FSM enables us to pictorially think of a statefulsystem using simple diagrams
63
![Page 64: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/64.jpg)
Finite State Machines (FSMs) Consist of:n Five elements:1. A finite number of states
n State: snapshot of all relevant elements of the system at the time of the snapshot
2. A finite number of external inputs3. A finite number of external outputs4. An explicit specification of all state transitions
n How to get from one state to another5. An explicit specification of what determines
each external output value
64
![Page 65: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/65.jpg)
Finite State Machines (FSMs)n Each FSM consists of three separate parts:
q next state logicq state registerq output logic
65
CLKM Nk knext
statelogic
outputlogic
inputs outputsstatenextstate
state register
At the beginning of the clock cycle, next state is latched into the state register
![Page 66: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/66.jpg)
Finite State Machines (FSMs) Consist of:n Sequential circuits
q State register(s)n Store the current state and n Load the next state at the clock edge
n Combinational Circuitsq Next state logic
n Determines what the next state will be
q Output logicn Generates the outputs
66
NextState
CurrentState
S’ S
CLK
CL
Next StateLogic
NextState
CL
OutputLogic
Outputs
![Page 67: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/67.jpg)
Finite State Machines (FSMs) Consist of:n Sequential circuits
q State register(s)n Store the current state and n Load the next state at the clock edge
n Combinational Circuitsq Next state logic
n Determines what the next state will be
q Output logicn Generates the outputs
67
NextState
CurrentState
S’ S
CLK
CL
Next StateLogic
NextState
CL
OutputLogic
Outputs
![Page 68: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/68.jpg)
State Register Implementationn How can we implement a state register? Two properties:
1. We need to store data at the beginning of every clock cycle
2. The data must be available during the entire clock cycle
68
CLK: 01
RegisterInput:
RegisterOutput:
Desired behavior
![Page 69: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/69.jpg)
The Problem with Latches
n Currently, we cannot simply wire a clock to WE of a latchq Whenever the clock is high, the latch propagates D to Qq The latch is transparent
69
D QCLK = WE
CLK: 01
RegisterInput:
RegisterOutput:
Recall the Gated D Latch
![Page 70: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/70.jpg)
n Currently, we cannot simply wire a clock to WE of a latchq Whenever the clock is high, the latch propagates D to Qq The latch is transparent
The Problem with Latches
70
D QCLK = WE
CLK: 01
Register Input:
Register Output:
Recall the Gated D Latch
Undesirable!
![Page 71: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/71.jpg)
n Currently, we cannot simply wire a clock to WE of a latchq When the clock is high Q will not take on D’s value ANDq When the clock is low the latch will propagate D to Q
The Problem with Latches
71
D QCLK = WE
CLK: 01
Input:
Output:
Recall the Gated D Latch
How can we change the latch, so that
1) D (input) is observable at Q (output) only at the beginning of next clock cycle?
2) Q is available for the full clock cycle
![Page 72: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/72.jpg)
The Need for a New Storage Element n To design viable FSMs
n We need storage elements that allow us
q to read the current state throughout the current clock cycle
AND
q not write the next state values into the storage elements until the beginning of the next clock cycle.
72
![Page 73: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/73.jpg)
n 1) state change on clock edge, 2) data available for full cycle
D Latch (Slave)D Latch (Master)
The D Flip-Flop
73
DQ
CLK
n When the clock is low, master propagates D to the input of slave (Q unchanged)n Only when the clock is high, slave latches D (Q stores D)
q At the rising edge of clock (clock going from 0->1), Q gets assigned D
CLK:01
![Page 74: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/74.jpg)
The D Flip-Flopn 1) state change on clock edge, 2) data available for full cycle
74
n At the rising edge of clock (clock going from 0->1), Q gets assigned Dn At all other times, Q is unchanged
CLK:01
CLKD Q
Q__
D Flip-Flop
![Page 75: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/75.jpg)
The D Flip-Flopn How do we implement this?
75
n At the rising edge of clock (clock going from 0->1), Q gets assigned Dn At all other times, Q is unchanged
CLK:01
CLKD Q
Q__
D Flip-FlopWe can use these Flip-Flops
to implement the state register!
![Page 76: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/76.jpg)
Rising-Clock-Edge Triggered Flip-Flopn Two inputs: CLK, D
n Functionq The flip-flop “samples” D on the rising edgeof CLK (positive edge)
q When CLK rises from 0 to 1, D passes through to Qq Otherwise, Q holds its previous valueq Q changes only on the rising edge of CLK
n A flip-flop is called an edge-triggered state element because it captures data on the clock edgeq A latch is a level-triggered state element
76
D Flip-FlopSymbols
D QQ
CLK
![Page 77: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/77.jpg)
Registern Multiple parallel flip-flops, each of which storing 1 bit
77
CLK
D Q
D Q
D Q
D Q
D0
D1
D2
D3
Q0
Q1
Q2
Q3
D3:04 4
CLK
Q3:0
This register stores 4 bits
This line represents 4 wires
Condensed
![Page 78: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/78.jpg)
A 4-Bit D-Flip-Flop-Based Register (Internally)
78Image source: Patt and Patel, “Introduction to Computing Systems”, 3rd ed., tentative page 95.
![Page 79: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/79.jpg)
Finite State Machines (FSMs)n Next state is determined by the current state and the inputsn Two types of finite state machines differ in the output
logic:q Moore FSM: outputs depend only on the current state
79
CLKM Nk knext
statelogic
outputlogic
Moore FSM
CLKM Nk knext
statelogic
outputlogic
inputs
inputs
outputs
outputsstate
statenextstate
nextstate
Mealy FSM
![Page 80: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/80.jpg)
Finite State Machines (FSMs)n Next state is determined by the current state and the inputsn Two types of finite state machines differ in the output
logic:q Moore FSM: outputs depend only on the current stateq Mealy FSM: outputs depend on the current state and the
inputs
80
CLKM Nk knext
statelogic
outputlogic
Moore FSM
CLKM Nk knext
statelogic
outputlogic
inputs
inputs
outputs
outputsstate
statenextstate
nextstate
Mealy FSM
![Page 81: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/81.jpg)
Finite State Machine Examplen “Smart” traffic light controller
q 2 inputs: n Traffic sensors: TA , TB (TRUE when there’s traffic)
q 2 outputs: n Lights: LA , LB (Red, Yellow, Green)
q State can change every 5 secondsn Except if green and traffic, stay green
81
TA
LA
TA
LB
TB
TB
LA
LB
Academic Ave.
BravadoBlvd.
Dorms
Fields
DiningHall
Labs
From H&H Section 3.4.1
![Page 82: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/82.jpg)
Finite State Machine Black Boxn Inputs: CLK, Reset, TA , TBn Outputs: LA , LB
82
TA
TB
LA
LB
CLK
Reset
TrafficLight
Controller
![Page 83: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/83.jpg)
Finite State Machine Transition Diagramn Moore FSM: outputs labeled in each state
q States: Circlesq Transitions: Arcs
83
S0LA: greenLB: red
Reset
TA
LA
TA
LB
TB
TB
LA
LB
Academic Ave.
BravadoBlvd.
Dorms
Fields
DiningHall
Labs
![Page 84: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/84.jpg)
Finite State Machine Transition Diagramn Moore FSM: outputs labeled in each state
q States: Circlesq Transitions: Arcs
84
TA
LA
TA
LB
TB
TB
LA
LB
Academic Ave.
BravadoBlvd.
Dorms
Fields
DiningHall
Labs
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
![Page 85: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/85.jpg)
Finite State Machine Transition Diagramn Moore FSM: outputs labeled in each state
q States: Circlesq Transitions: Arcs
85
TA
LA
TA
LB
TB
TB
LA
LB
Academic Ave.
BravadoBlvd.
Dorms
Fields
DiningHall
Labs
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
![Page 86: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/86.jpg)
Finite State Machine Transition Diagramn Moore FSM: outputs labeled in each state
q States: Circlesq Transitions: Arcs
86
TA
LA
TA
LB
TB
TB
LA
LB
Academic Ave.
BravadoBlvd.
Dorms
Fields
DiningHall
Labs
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
![Page 87: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/87.jpg)
Finite State Machine Transition Diagramn Moore FSM: outputs labeled in each state
q States: Circlesq Transitions: Arcs
87
TA
LA
TA
LB
TB
TB
LA
LB
Academic Ave.
BravadoBlvd.
Dorms
Fields
DiningHall
Labs
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
![Page 88: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/88.jpg)
Finite State Machine:State Transition Table
88
![Page 89: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/89.jpg)
FSM State Transition TableCurrentState Inputs NextState
S TA TB S'S0 0 XS0 1 XS1 X XS2 X 0S2 X 1S3 X X
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
59
![Page 90: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/90.jpg)
FSM State Transition TableCurrentState Inputs NextState
S TA TB S'S0 0 X S1S0 1 X S0S1 X X S2S2 X 0 S3S2 X 1 S2S3 X X S0
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
60
![Page 91: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/91.jpg)
FSM State Transition TableCurrentState Inputs NextState
S TA TB S'S0 0 X S1S0 1 X S0S1 X X S2S2 X 0 S3S2 X 1 S2S3 X X S0
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
State Encoding
S0 00
S1 01
S2 10
S3 11
61
![Page 92: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/92.jpg)
FSM State Transition TableCurrentState Inputs NextStateS1 S0 TA TB S’1 S’00 0 0 X 0 10 0 1 X 0 00 1 X X 1 01 0 X 0 1 11 0 X 1 1 01 1 X X 0 0
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
State Encoding
S0 00
S1 01
S2 10
S3 11
62
![Page 93: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/93.jpg)
FSM State Transition TableCurrentState Inputs NextStateS1 S0 TA TB S’1 S’00 0 0 X 0 10 0 1 X 0 00 1 X X 1 01 0 X 0 1 11 0 X 1 1 01 1 X X 0 0
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
State Encoding
S0 00
S1 01
S2 10
S3 11
S’1 =?
63
![Page 94: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/94.jpg)
FSM State Transition TableCurrentState Inputs NextStateS1 S0 TA TB S’1 S’00 0 0 X 0 10 0 1 X 0 00 1 X X 1 01 0 X 0 1 11 0 X 1 1 01 1 X X 0 0
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
State Encoding
S0 00
S1 01
S2 10
S3 11
S’1 =(S1 ∙S0)+(S1 ∙S0 ∙TB)+(S1 ∙S0 ∙TB)
64
![Page 95: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/95.jpg)
FSM State Transition TableCurrentState Inputs NextStateS1 S0 TA TB S’1 S’00 0 0 X 0 10 0 1 X 0 00 1 X X 1 01 0 X 0 1 11 0 X 1 1 01 1 X X 0 0
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
State Encoding
S0 00
S1 01
S2 10
S3 11
S’1 =(S1 ∙S0)+(S1 ∙S0 ∙TB)+(S1 ∙S0 ∙TB)
S’0 =?65
![Page 96: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/96.jpg)
FSM State Transition TableCurrentState Inputs NextStateS1 S0 TA TB S’1 S’00 0 0 X 0 10 0 1 X 0 00 1 X X 1 01 0 X 0 1 11 0 X 1 1 01 1 X X 0 0
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
State Encoding
S0 00
S1 01
S2 10
S3 11
S’1 =(S1 ∙S0)+(S1 ∙S0 ∙TB)+(S1 ∙S0 ∙TB)
S’0 =(S1 ∙S0 ∙TA)+(S1 ∙S0 ∙TB)66
![Page 97: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/97.jpg)
FSM State Transition TableCurrentState Inputs NextStateS1 S0 TA TB S’1 S’00 0 0 X 0 10 0 1 X 0 00 1 X X 1 01 0 X 0 1 11 0 X 1 1 01 1 X X 0 0
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset
State Encoding
S0 00
S1 01
S2 10
S3 11
S’1 =S1 xor S0(Simplified)
S’0 =(S1 ∙S0 ∙TA)+(S1 ∙S0 ∙TB)67
![Page 98: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/98.jpg)
Finite State Machine:Output Table
98
![Page 99: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/99.jpg)
FSM Output Table
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset CurrentState OutputsS1 S0 LA LB0 0 green red0 1 yellow red1 0 red green1 1 red yellow
69
![Page 100: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/100.jpg)
FSM Output Table
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset CurrentState OutputsS1 S0 LA LB0 0 green red0 1 yellow red1 0 red green1 1 red yellow
Output Encoding
green 00
yellow 01
red 10
70
![Page 101: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/101.jpg)
FSM Output Table
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset CurrentState OutputsS1 S0 LA1 LA0 LB1 LB00 0 0 0 1 00 1 0 1 1 01 0 1 0 0 01 1 1 0 0 1
Output Encoding
green 00
yellow 01
red 10
LA1 =S1
71
![Page 102: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/102.jpg)
FSM Output Table
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset CurrentState OutputsS1 S0 LA1 LA0 LB1 LB00 0 0 0 1 00 1 0 1 1 01 0 1 0 0 01 1 1 0 0 1
Output Encoding
green 00
yellow 01
red 10
LA1 =S1LA0 =S1 ∙S0
72
![Page 103: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/103.jpg)
FSM Output Table
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset CurrentState OutputsS1 S0 LA1 LA0 LB1 LB00 0 0 0 1 00 1 0 1 1 01 0 1 0 0 01 1 1 0 0 1
Output Encoding
green 00
yellow 01
red 10
LA1 =S1LA0 =S1 ∙S0LB1 =S1
73
![Page 104: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/104.jpg)
FSM Output Table
S0LA: greenLB: red
S1LA: yellowLB: red
S3LA: redLB: yellow
S2LA: redLB: green
TATA
TB
TB
Reset CurrentState OutputsS1 S0 LA1 LA0 LB1 LB00 0 0 0 1 00 1 0 1 1 01 0 1 0 0 01 1 1 0 0 1
Output Encoding
green 00
yellow 01
red 10
LA1 =S1LA0 =S1 ∙S0LB1 =S1LB0 =S1 ∙S0
74
![Page 105: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/105.jpg)
Digital Design & Computer Arch.Lecture 6: Sequential Logic Design
Prof. Onur Mutlu
ETH ZürichSpring 2020
6 March 2020
![Page 106: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/106.jpg)
We did not cover the remaining slides. They are for your preparation for the
next lecture.
106
![Page 107: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/107.jpg)
Finite State Machine:Schematic
107
![Page 108: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/108.jpg)
FSM Schematic: State Register
108
![Page 109: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/109.jpg)
109
FSM Schematic: State Register
S1
S0
S'1
S'0
CLK
state register
Resetr
![Page 110: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/110.jpg)
110
FSM Schematic: Next State Logic
S1
S0
S'1
S'0
CLK
next state logic state register
Reset
TA
TB
inputs
S1 S0
r
S’1 =S1 xor S0
S’0 =(S1 ∙S0 ∙TA)+(S1 ∙S0 ∙TB)
![Page 111: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/111.jpg)
111
FSM Schematic: Output Logic
S1
S0
S'1
S'0
CLK
next state logic output logicstate register
Reset
LA1
LB1
LB0
LA0
TA
TB
inputs outputs
S1 S0
r
LA1 =S1LA0 =S1 ∙S0LB1 =S1LB0 =S1 ∙S0
![Page 112: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/112.jpg)
112
FSM Timing Diagram
CLK
Reset
TA
TB
S'1:0
S1:0
LA1:0
LB1:0
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10
S1 (01) S2 (10) S3 (11) S0 (00)
t (sec)
??
??
S0 (00)
S0 (00) S1 (01) S2 (10) S3 (11) S1 (01)
??
??
0 5 10 15 20 25 30 35 40 45
Green (00)
Red (10)
S0 (00)
Yellow (01) Red (10) Green (00)
Green (00) Red (10)Yellow (01)
S0LA: yellow
LB: red
S1LA: yellow
LB: red
S2LA: red
LB: green
S3LA: red
LB: yellow
Reset TATA__
__TBTB
![Page 113: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/113.jpg)
113
FSM Timing Diagram
CLK
Reset
TA
TB
S'1:0
S1:0
LA1:0
LB1:0
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10
S1 (01) S2 (10) S3 (11) S0 (00)
t (sec)
??
??
S0 (00)
S0 (00) S1 (01) S2 (10) S3 (11) S1 (01)
??
??
0 5 10 15 20 25 30 35 40 45
Green (00)
Red (10)
S0 (00)
Yellow (01) Red (10) Green (00)
Green (00) Red (10)Yellow (01)
S0LA: yellow
LB: red
S1LA: yellow
LB: red
S2LA: red
LB: green
S3LA: red
LB: yellow
Reset TATA__
__TBTB
![Page 114: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/114.jpg)
114
FSM Timing Diagram
CLK
Reset
TA
TB
S'1:0
S1:0
LA1:0
LB1:0
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10
S1 (01) S2 (10) S3 (11) S0 (00)
t (sec)
??
??
S0 (00)
S0 (00) S1 (01) S2 (10) S3 (11) S1 (01)
??
??
0 5 10 15 20 25 30 35 40 45
Green (00)
Red (10)
S0 (00)
Yellow (01) Red (10) Green (00)
Green (00) Red (10)Yellow (01)
S0LA: yellow
LB: red
S1LA: yellow
LB: red
S2LA: red
LB: green
S3LA: red
LB: yellow
Reset TATA__
__TBTB
![Page 115: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/115.jpg)
115
FSM Timing Diagram
CLK
Reset
TA
TB
S'1:0
S1:0
LA1:0
LB1:0
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10
S1 (01) S2 (10) S3 (11) S0 (00)
t (sec)
??
??
S0 (00)
S0 (00) S1 (01) S2 (10) S3 (11) S1 (01)
??
??
0 5 10 15 20 25 30 35 40 45
Green (00)
Red (10)
S0 (00)
Yellow (01) Red (10) Green (00)
Green (00) Red (10)Yellow (01)
S0LA: yellow
LB: red
S1LA: yellow
LB: red
S2LA: red
LB: green
S3LA: red
LB: yellow
Reset TATA__
__TBTB
![Page 116: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/116.jpg)
116
FSM Timing Diagram
CLK
Reset
TA
TB
S'1:0
S1:0
LA1:0
LB1:0
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10
S1 (01) S2 (10) S3 (11) S0 (00)
t (sec)
??
??
S0 (00)
S0 (00) S1 (01) S2 (10) S3 (11) S1 (01)
??
??
0 5 10 15 20 25 30 35 40 45
Green (00)
Red (10)
S0 (00)
Yellow (01) Red (10) Green (00)
Green (00) Red (10)Yellow (01)
S0LA: yellow
LB: red
S1LA: yellow
LB: red
S2LA: red
LB: green
S3LA: red
LB: yellow
Reset TATA__
__TBTB
![Page 117: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/117.jpg)
117
FSM Timing Diagram
CLK
Reset
TA
TB
S'1:0
S1:0
LA1:0
LB1:0
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10
S1 (01) S2 (10) S3 (11) S0 (00)
t (sec)
??
??
S0 (00)
S0 (00) S1 (01) S2 (10) S3 (11) S1 (01)
??
??
0 5 10 15 20 25 30 35 40 45
Green (00)
Red (10)
S0 (00)
Yellow (01) Red (10) Green (00)
Green (00) Red (10)Yellow (01)
S0LA: yellow
LB: red
S1LA: yellow
LB: red
S2LA: red
LB: green
S3LA: red
LB: yellow
Reset TATA__
__TBTB
![Page 118: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/118.jpg)
118
FSM Timing Diagram
CLK
Reset
TA
TB
S'1:0
S1:0
LA1:0
LB1:0
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10
S1 (01) S2 (10) S3 (11) S0 (00)
t (sec)
??
??
S0 (00)
S0 (00) S1 (01) S2 (10) S3 (11) S1 (01)
??
??
0 5 10 15 20 25 30 35 40 45
Green (00)
Red (10)
S0 (00)
Yellow (01) Red (10) Green (00)
Green (00) Red (10)Yellow (01)
S0LA: yellow
LB: red
S1LA: yellow
LB: red
S2LA: red
LB: green
S3LA: red
LB: yellow
Reset TATA__
__TBTB
![Page 119: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/119.jpg)
119
FSM Timing Diagram
CLK
Reset
TA
TB
S'1:0
S1:0
LA1:0
LB1:0
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10
S1 (01) S2 (10) S3 (11) S0 (00)
t (sec)
??
??
S0 (00)
S0 (00) S1 (01) S2 (10) S3 (11) S1 (01)
??
??
0 5 10 15 20 25 30 35 40 45
Green (00)
Red (10)
S0 (00)
Yellow (01) Red (10) Green (00)
Green (00) Red (10)Yellow (01)
S0LA: yellow
LB: red
S1LA: yellow
LB: red
S2LA: red
LB: green
S3LA: red
LB: yellow
Reset TATA__
__TBTBThis is from H&H Section 3.4.1
![Page 120: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/120.jpg)
120
FSM Timing Diagram
CLK
Reset
TA
TB
S'1:0
S1:0
LA1:0
LB1:0
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10
S1 (01) S2 (10) S3 (11) S0 (00)
t (sec)
??
??
S0 (00)
S0 (00) S1 (01) S2 (10) S3 (11) S1 (01)
??
??
0 5 10 15 20 25 30 35 40 45
Green (00)
Red (10)
S0 (00)
Yellow (01) Red (10) Green (00)
Green (00) Red (10)Yellow (01)
S0LA: yellow
LB: red
S1LA: yellow
LB: red
S2LA: red
LB: green
S3LA: red
LB: yellow
Reset TATA__
__TBTB
![Page 121: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/121.jpg)
121
FSM Timing Diagram
CLK
Reset
TA
TB
S'1:0
S1:0
LA1:0
LB1:0
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10
S1 (01) S2 (10) S3 (11) S0 (00)
t (sec)
??
??
S0 (00)
S0 (00) S1 (01) S2 (10) S3 (11) S1 (01)
??
??
0 5 10 15 20 25 30 35 40 45
Green (00)
Red (10)
S0 (00)
Yellow (01) Red (10) Green (00)
Green (00) Red (10)Yellow (01)
S0LA: yellow
LB: red
S1LA: yellow
LB: red
S2LA: red
LB: green
S3LA: red
LB: yellow
Reset TATA__
__TBTB
See H&H Chapter 3.4
![Page 122: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/122.jpg)
Finite State Machine:State Encoding
122
![Page 123: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/123.jpg)
FSM State Encodingn How do we encode the state bits?
q Three common state binary encodings with different tradeoffs1. Fully Encoded2. 1-Hot Encoded3. Output Encoded
n Let’s see an example Swiss traffic light with 4 statesq Green, Yellow, Red, Yellow+Red
123
![Page 124: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/124.jpg)
FSM State Encoding (II)1. Binary Encoding (Full Encoding):
q Use the minimum number of bits used to encode all statesn Use log2(num_states) bits to represent the states
q Example states: 00, 01, 10, 11q Minimizes # flip-flops, but not necessarily output logic or
next state logic
2. One-Hot Encoding:q Each bit encodes a different state
n Uses num_states bits to represent the statesn Exactly 1 bit is “hot” for a given state
q Example states: 0001, 0010, 0100, 1000q Simplest design process – very automatableq Maximizes # flip-flops, minimizes next state logic
124
![Page 125: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/125.jpg)
FSM State Encoding (III)3. Output Encoding:
q Outputs are directly accessible in the state encoding
q For example, since we have 3 outputs (light color), encode state with 3 bits, where each bit represents a color
q Example states: 001, 010, 100, 110n Bit0 encodes green light output, n Bit1 encodes yellow light outputn Bit2 encodes red light output
q Minimizes output logic q Only works for Moore Machines (output function of state)
125
![Page 126: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/126.jpg)
FSM State Encoding (III)3. Output Encoding:
q Outputs are directly accessible in the state encoding
q For example, since we have 3 outputs (light color), encode state with 3 bits, where each bit represents a color
q Example states: 001, 010, 100, 110n Bit0 encodes green light output, n Bit1 encodes yellow light outputn Bit2 encodes red light output
q Minimizes output logic q Only works for Moore Machines (output function of state)
126
The designer must carefully choosean encoding scheme to optimize the design
under given constraints
![Page 127: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/127.jpg)
Moore vs. Mealy Machines
127
![Page 128: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/128.jpg)
Recall: Moore vs. Mealy FSMsn Next state is determined by the current state and the inputsn Two types of finite state machines differ in the output
logic:q Moore FSM: outputs depend only on the current stateq Mealy FSM: outputs depend on the current state and the
inputs
128
CLKM Nk knext
statelogic
outputlogic
Moore FSM
CLKM Nk knext
statelogic
outputlogic
inputs
inputs
outputs
outputsstate
statenextstate
nextstate
Mealy FSM
![Page 129: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/129.jpg)
Moore vs. Mealy FSM Examplesn Alyssa P. Hacker has a snail that crawls down a paper tape with
1’s and 0’s on it. n The snail smiles whenever the last four digits it has crawled over
are 1101. n Design Moore and Mealy FSMs of the snail’s brain.
129
CLKM Nk knext
statelogic
outputlogic
Moore FSM
CLKM Nk knext
statelogic
outputlogic
inputs
inputs
outputs
outputsstate
statenextstate
nextstate
Mealy FSM
![Page 130: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/130.jpg)
Moore vs. Mealy FSM Examplesn Alyssa P. Hacker has a snail that crawls down a paper tape with
1’s and 0’s on it. n The snail smiles whenever the last four digits it has crawled over
are 1101. n Design Moore and Mealy FSMs of the snail’s brain.
130
CLKM Nk knext
statelogic
outputlogic
Moore FSM
CLKM Nk knext
statelogic
outputlogic
inputs
inputs
outputs
outputsstate
statenextstate
nextstate
Mealy FSM
![Page 131: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/131.jpg)
State Transition Diagrams
131
reset
Moore FSM
S00
S10
S20
S30
S41
0
1 1 0 1
1
01 00
reset
S0 S1 S2 S30/0
1/0 1/0 0/01/1
0/01/0
0/0
Mealy FSMWhat are the tradeoffs?
![Page 132: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/132.jpg)
FSM Design Proceduren Determine all possible states of your machinen Develop a state transition diagram
q Generally this is done from a textual descriptionq You need to 1) determine the inputs and outputs for each state and
2) figure out how to get from one state to anothern Approach
q Start by defining the reset state and what happens from it – this is typically an easy point to start from
q Then continue to add transitions and statesq Picking good state names is very importantq Building an FSM is like programming (but it is not programming!)
n An FSM has a sequential “control-flow” like a program with conditionals and goto’sn The if-then-else construct is controlled by one or more inputsn The outputs are controlled by the state or the inputs
q In hardware, we typically have many concurrent FSMs
132
![Page 133: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/133.jpg)
What is to Come: LC-3 Processor
133
Scanned by CamScanner
![Page 134: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/134.jpg)
What is to Come: LC-3 Datapath
134
![Page 135: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/135.jpg)
Backup Slides:Different Types of Flip Flops
135
![Page 136: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/136.jpg)
Enabled Flip-Flopsn Inputs: CLK, D, EN
q The enable input (EN) controls when new data (D) is storedn Function:
q EN = 1: D passes through to Q on the clock edge q EN = 0: the flip-flop retains its previous state
136
InternalCircuit
D Q
CLKEN
DQ
0
1D QEN
Symbol
![Page 137: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/137.jpg)
Resettable Flip-Flopn Inputs: CLK, D, Reset
q The Reset is used to set the output to 0.n Function:
q Reset = 1: Q is forced to 0 q Reset = 0: the flip-flop behaves like an ordinary D flip-flop
137
Symbols
D QReset
r
![Page 138: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/138.jpg)
Resettable Flip-Flopsn Two types:
q Synchronous: resets at the clock edge onlyq Asynchronous: resets immediately when Reset = 1
n Asynchronously resettable flip-flop requires changing the internal circuitry of the flip-flop (see Exercise 3.10)
n Synchronously resettable flip-flop?
138
InternalCircuit
D Q
CLK
D QReset
![Page 139: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/139.jpg)
Settable Flip-Flopn Inputs: CLK, D, Setn Function:
q Set = 1: Q is set to 1 q Set = 0: the flip-flop behaves like an ordinary D flip-flop
139
Symbols
D QSet
s
![Page 140: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/140.jpg)
Logic Simplification:Karnaugh Maps (K-Maps)
140
![Page 141: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/141.jpg)
Logic Simplificationn Systematic techniques for simplifications
q amenable to automation
141
Key Tool: The Uniting Theorem —
𝑭 =
A's value does NOT change within the ON-set rows
B's value changes within the rows where F==1 (“ON set”)
B's value stays the same within the ON-set rows
A's value changes within the ON-set rows
➙ B is eliminated, A remains
➙ A is eliminated, B remains
If an input (B) can change without changing the output, that input value is not needed
𝑭 = 𝑨$𝑩 + 𝑨𝑩
𝑨$𝑩 + 𝑨𝑩 = 𝑨 $𝑩 + 𝑩 = 𝑨 𝟏 = 𝑨
𝑮 = $𝑨$𝑩 + 𝑨$𝑩 = $𝑨 + 𝑨 $𝑩 = $𝑩
Essence of Simplification:Find two element subsets of the ON-set where only one variable changes its value. This single varying variable can be eliminated!
![Page 142: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/142.jpg)
Complex Casesn One example
n Problemq Easy to see how to apply Uniting Theorem…q Hard to know if you applied it in all the right places…q …especially in a function of many more variables
n Questionq Is there an easier way to find potential simplifications?q i.e., potential applications of Uniting Theorem…?
n Answerq Need an intrinsically geometric representation for Boolean f( ) q Something we can draw, see…
142
𝑪𝒐𝒖𝒕 = &𝑨𝑩𝑪 + 𝑨&𝑩𝑪 + 𝑨𝑩&𝑪 + 𝑨𝑩𝑪
![Page 143: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/143.jpg)
Karnaugh Mapn Karnaugh Map (K-map) method
q K-map is an alternative method of representing the truth table that helps visualize adjacencies in up to 6 dimensions
q Physical adjacency ↔ Logical adjacency
143
2-variable K-map0 1
0 00 01
1 10 11
Numbering Scheme: 00, 01, 11, 10 is called a“Gray Code” — only a single bit (variable) changes
from one code word and the next code word
00 01 11 1000 0000 0001 0011 0010
01 0100 0101 0111 0110
11 1100 1101 1111 1110
10 1000 1001 1011 1010
3-variable K-map 4-variable K-map
00 01 11 100 000 001 011 010
1 100 101 111 110
𝑨𝑩𝑨 𝑩 𝑪𝑫𝑨𝑩𝑪
![Page 144: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/144.jpg)
Karnaugh Map Methods
144
Adjacent
000
001
010
011
110
111
100
101
000
001010
011
110
111
100
101
Adjacent
K-map adjacencies go “around the edges”Wrap around from first to last columnWrap around from top row to bottom row
00 01 11 100 000 001 011 010
1 100 101 111 110
𝑨𝑩𝑪
![Page 145: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/145.jpg)
K-map Cover - 4 Input Variables
145
00 01 11 1000 1 0 0 101 0 1 0 011 1 1 1 110 1 1 1 1
𝑨𝑩𝑪𝑫
Strategy for “circling” rectangles on Kmap:
As big as possible
Biggest “oops!” that people forget:
Wrap-arounds
𝐅(𝐀, 𝐁, 𝐂, 𝐃) =.𝒎(𝟎, 𝟐, 𝟓, 𝟖, 𝟗, 𝟏𝟎, 𝟏𝟏, 𝟏𝟐, 𝟏𝟑, 𝟏𝟒, 𝟏𝟓)
𝐅 = 𝐀 + 9𝑩9𝑫 + 𝐁9𝑪𝑫𝐀 + 9𝑩9𝑫𝐀
![Page 146: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/146.jpg)
Logic Minimization Using K-Mapsn Very simple guideline:
q Circle all the rectangular blocks of 1’s in the map, using the fewest possible number of circlesn Each circle should be as large as possible
q Read off the implicants that were circled
n More formally:q A Boolean equation is minimized when it is written as a sum of
the fewest number of prime implicantsq Each circle on the K-map represents an implicantq The largest possible circles are prime implicants
147
![Page 147: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/147.jpg)
K-map Rulesn What can be legally combined (circled) in the K-map?
q Rectangular groups of size 2k for any integer kq Each cell has the same value (1, for now)q All values must be adjacent
n Wrap-around edge is okay
n How does a group become a term in an expression?q Determine which literals are constant, and which vary across groupq Eliminate varying literals, then AND the constant literals
n constant 1 ➙ use 𝐗, constant 0 ➙ use 9𝑿
n What is a good solution?q Biggest groupings ➙ eliminate more variables (literals) in each term q Fewest groupings ➙ fewer terms (gates) all togetherq OR together all AND terms you create from individual groups
148
![Page 148: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/148.jpg)
K-map Example: Two-bit Comparator
Design Approach:
Write a 4-Variable K-mapfor each of the 3output functions
149
A B C D F1 F2 F30 0 0 0 1 0 00 0 0 1 0 1 00 0 1 0 0 1 00 0 1 1 0 1 00 1 0 0 0 0 10 1 0 1 1 0 00 1 1 0 0 1 00 1 1 1 0 1 01 0 0 0 0 0 11 0 0 1 0 0 11 0 1 0 1 0 01 0 1 1 0 1 01 1 0 0 0 0 11 1 0 1 0 0 11 1 1 0 0 0 11 1 1 1 1 0 0
AF1 AB = CD
BF2 AB < CD
CF3 AB > CD
D
![Page 149: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/149.jpg)
K-map Example: Two-bit Comparator (2)
150
A B C D F1 F2 F30 0 0 0 1 0 00 0 0 1 0 1 00 0 1 0 0 1 00 0 1 1 0 1 00 1 0 0 0 0 10 1 0 1 1 0 00 1 1 0 0 1 00 1 1 1 0 1 01 0 0 0 0 0 11 0 0 1 0 0 11 0 1 0 1 0 01 0 1 1 0 1 01 1 0 0 0 0 11 1 0 1 0 0 11 1 1 0 0 0 11 1 1 1 1 0 0
00 01 11 1000 101 111 110 1
K-map for F1
𝑨𝑩𝑪𝑫
F1 = A'B'C'D' + A'BC'D + ABCD + AB'CD'
𝑨𝑩
𝑫
𝑪
![Page 150: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/150.jpg)
K-map Example: Two-bit Comparator (3)
151
A B C D F1 F2 F30 0 0 0 1 0 00 0 0 1 0 1 00 0 1 0 0 1 00 0 1 1 0 1 00 1 0 0 0 0 10 1 0 1 1 0 00 1 1 0 0 1 00 1 1 1 0 1 01 0 0 0 0 0 11 0 0 1 0 0 11 0 1 0 1 0 01 0 1 1 0 1 01 1 0 0 0 0 11 1 0 1 0 0 11 1 1 0 0 0 11 1 1 1 1 0 0
00 01 11 1000 1 1 101 1 111
10 1
K-map for F2
𝑨𝑩𝑪𝑫
F2 = A'C + A'B'D + B'CD
F3 = ? (Exercise for you)
𝑨𝑩
𝑫
𝑪
![Page 151: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/151.jpg)
K-maps with “Don’t Care”n Don’t Care really means I don’t care what my circuit outputs if this
appears as inputq You have an engineering choice to use DON’T CARE patterns
intelligently as 1 or 0 to better simplify the circuit
152
I can pick 00, 01, 10, 11independently of below
I can pick 00, 01, 10, 11independently of above
A B C D F G
• • •
0 1 1 0 X X0 1 1 11 0 0 0 X X1 0 0 1
• • •
![Page 152: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/152.jpg)
A B C D W X Y Z0 0 0 0 0 0 0 10 0 0 1 0 0 1 00 0 1 0 0 0 1 10 0 1 1 0 1 0 00 1 0 0 0 1 0 10 1 0 1 0 1 1 00 1 1 0 0 1 1 10 1 1 1 1 0 0 01 0 0 0 1 0 0 11 0 0 1 0 0 0 01 0 1 0 X X X X1 0 1 1 X X X X1 1 0 0 X X X X1 1 0 1 X X X X1 1 1 0 X X X X1 1 1 1 X X X X
Example: BCD Increment Functionn BCD (Binary Coded Decimal) digits
q Encode decimal digits 0 - 9 with bit patterns 00002 — 10012q When incremented, the decimal sequence is 0, 1, …, 8, 9, 0, 1
153
These input patterns shouldnever be encountered in practice
(hey -- it’s a BCD number!)So, associated output values are
“Don’t Cares”
![Page 153: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/153.jpg)
00 01 11 1000 1 101 1 111 X X X X10 1 X X
K-map for BCD Increment Function
A B C D+ 1W X Y Z
154
00 01 11 100001 111 X X X X10 1 X X
00 01 11 1000 101 1 1 111 X X X X10 X X
00 01 11 1000 1 101 1 111 X X X X10 X X
W𝑨𝑩
𝑪𝑫X𝑨𝑩
𝑪𝑫
𝑨𝑩𝑪𝑫
𝑨𝑩𝑪𝑫 ZY
Z (without don’t cares) = A'D' + B'C'D’
Z (with don’t cares) = D'
𝑨𝑩
𝑫
𝑪
![Page 154: Digital Design & Computer Arch.](https://reader030.fdocuments.in/reader030/viewer/2022012503/617de426103af9280a31662a/html5/thumbnails/154.jpg)
K-map Summary
n Karnaugh maps as a formal systematic approachfor logic simplification
n 2-, 3-, 4-variable K-maps
n K-maps with “Don’t Care” outputs
n H&H Section 2.7155