Guest Lecture by David Johnston

Slides:



Advertisements
Similar presentations
ENGIN112 L23: Finite State Machine Design Procedure October 27, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 23 Finite State Machine.
Advertisements

State-machine structure (Mealy)
Multiplexors Sequential Circuits and Finite State Machines Prof. Sin-Min Lee Department of Computer Science.
Circuits require memory to store intermediate data
CS 151 Digital Systems Design Lecture 21 Analyzing Sequential Circuits.
CS 151 Digital Systems Design Lecture 25 State Reduction and Assignment.
Give qualifications of instructors: DAP
Overview Sequential Circuit Design Specification Formulation
ECE 301 – Digital Electronics Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #17)
ECE 331 – Digital Systems Design Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #19)
ENGIN112 L25: State Reduction and Assignment October 31, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 25 State Reduction and Assignment.
CPEN Digital System Design Chapter 5 - Sequential Circuits Sequential Circuit Design C. Gerousis © Logic and Computer Design Fundamentals, 4 rd Ed.,
1 © 2014 B. Wilkinson Modification date: Dec Sequential Logic Circuits Previously, we described the basic building blocks of sequential circuits,
Digital Logic Design Lecture # 19 University of Tehran.
DLD Lecture 26 Finite State Machine Design Procedure.
Sequential Networks and Finite State Machines
Figure 8.1. The general form of a sequential circuit.
ANALYSIS OF SEQUENTIAL CIRCUITS
COMP541 Sequential Logic – 2: Finite State Machines
Digital Design Lecture 9
ECE 301 – Digital Electronics
Reading: Hambley Chapters
Instructor: Alexander Stoytchev
FINITE STATE MACHINES (FSMs)
332:437 Lecture 12 Finite State Machine Design
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
KU College of Engineering Elec 204: Digital Systems Design
Sequential circuit design
Instructor: Alexander Stoytchev
CSE 140L Discussion Finite State Machines.
Instructor: Alexander Stoytchev
Sequential circuit design
Digital Logic & Design Dr. Waseem Ikram Lecture No. 31.
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
CSE 370 – Winter Sequential Logic-2 - 1
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Sequential circuit design
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
KU College of Engineering Elec 204: Digital Systems Design
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Sequential Circuit Analysis & Design
Guest Lecture by David Johnston
Figure 8.1. The general form of a sequential circuit.
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Lecture 18 Logistics Last lecture Today HW5 due today (with extra 10%)
Lecture 22 Logistics Last lecture Today HW7 is due on Friday
Dr. Tassadaq Hussain Introduction to Verilog – Part-4 Expressing FSM in Verilog (contd) and FSM State Encoding Dr. Tassadaq Hussain.
EGR 2131 Unit 12 Synchronous Sequential Circuits
ECE 352 Digital System Fundamentals
Instructor: Alexander Stoytchev
Lecture 22 Logistics Last lecture Today HW7 is due on Friday
ECE 352 Digital System Fundamentals
Announcements Assignment 7 due now or tommorrow Assignment 8 posted
Instructor: Alexander Stoytchev
CSE 370 – Winter Sequential Logic-2 - 1
Presentation transcript:

Guest Lecture by David Johnston CprE 281: Digital Logic Guest Lecture by David Johnston http://www.ece.iastate.edu/~alexs/classes/

Moore Machines CprE 281: Digital Logic Iowa State University, Ames, IA Copyright © 2013

The machine’s current state decides the current output. Moore Machine Summary The machine’s current state and current input are used to decide which next state to transition into. The machine’s current state decides the current output.

Let’s finish implementing our previous example.

C: z = 1 Reset B: z = 0 A: z = 0 w = 1 We need to find both the next state logic and the output logic implied by this machine.

Next state Present Output state A B C z w = w = 1 C: z = 1 Reset B: z = 0 A: z = 0 w = 1 Next state Present Output state z w = w = 1 A B C

Next state Present Output state A A B B A C C A C 1 z w = w = 1 Reset B: z = 0 A: z = 0 w = 1 Next state Present Output state z w = w = 1 A A B B A C C A C 1

Let’s use two flip flops to hold the state machine’s state.

Let Q(t) = y2y1 and Q(t+1) = Y2Y1. w Next State Logic Output Logic z Y y 2 2 Clock

So, we need to find logic expressions for Y1(w, y1, y2), Y2(w, y1, y2), and z(y1, y2). Y y 1 1 w Next State Logic Output Logic z Y y 2 2 Clock

Next state Present Output state z w = w = 1 A A B B A C C A C 1 Suppose we encoded our states in the same order in which they were labeled: A ~ 00 B ~ 01 C ~ 10

The finite state machine will never reach a state encoded as 11. Next state Present Output state z w = w = 1 A A B B A C C A C 1 Next state Present Output state w = w = 1 z A 00 The finite state machine will never reach a state encoded as 11. B 01 C 10 11

Next state Present Output state A A B B A C C A C 1 z w = w = 1 w = 1 A A B B A C C A C 1 Present Next state state w = 1 Output y Y 2 z A 00 01 B 10 C 11 dd d We arbitrarily chose these as our state encodings. We could have used others.

Present Next state state w = 1 Output y Y 2 z 00 01 10 11 dd d q(t) = y2y1 and q(t+1) = Y2Y1 w y2 y1 Y2 Y1 1 Present Next state state w = 1 Output y Y 2 z 00 01 10 11 dd d y2 y1 z 1

Y 1 y y w y2 y1 Y2 Y1 1 d 2 1 w 00 01 11 10 d 1 1 d Y 2 y y 2 1 w 00 01 11 10 d 1 1 d 1 y2 y1 z 1 d z y 1 y 2 1 1 1 d

Don’t care conditions simplify the combinatorial logic. 2 1 Ignoring don't cares Using don't cares w 00 01 11 10 d Y = wy y Y = wy y 1 1 2 1 1 2 1 1 d Y 2 y y 2 1 w 00 01 11 10 d Y = wy y + wy y Y = wy + wy 2 1 2 1 2 2 1 2 1 1 d 1 = w ( y + y ) 1 2 z y 1 y 2 1 z = y y z = y 1 2 2 1 1 d Don’t care conditions simplify the combinatorial logic.

Lastly, we add a reset signal, which forces the machine back to its start state, which is state 00 in this case.

Summary: Designing a Moore Machine Obtain the circuit specification. Derive a state diagram. Derive the state table. Decide on a state encoding. Encode the state table. Derive the output logic and next-state logic. Add a reset signal.

An Alternative State Encoding

Our previous design decisions led us to: Y 1 y y z 2 1 Y 2 y y y 2 1 1 y w 00 01 11 10 w 2 1 00 01 11 10 d d 1 1 d 1 1 d 1 1 d 1 Can we do better?

A Better State Encoding Next state Present Output state z w = w = 1 A A B B A C C A C 1 Suppose we encoded our states another way: A ~ 00 B ~ 01 C ~ 11

A Better State Encoding Next state Present Output state z w = w = 1 A A B B A C C A C 1 Next state Present Output state w = w = 1 A ~ 00 B ~ 01 C ~ 11 z

A Better State Encoding Next state Present Output state z w = w = 1 A A B B A C C A C 1 Present Next state state w = 1 Output y 2 Y z A 00 01 B 11 C 10 dd d

What Are Our Logic Expressions? Present Next state state w = 1 Output y 2 Y z A 00 01 B 11 C 10 dd d

What Are Our Logic Expressions? Present Next state state w = 1 Output y 2 Y z A 00 01 B 11 C 10 dd d Warning: This table does not enumerate y2y1, in the standard way, so be careful when filling out the K-Map. Y2 y y Y1 y y z 2 1 2 1 y 1 w y w 00 01 11 10 00 01 11 10 2 1 1 1 1

What Are Our Logic Expressions? Present Next state state w = 1 Output y 2 Y z A 00 01 B 11 C 10 dd d Warning: The present state variables, y1y2, do not follow our standard enumeration, so be careful when filling out the K-Map. Y2 Y1 y y y y z y 2 1 2 1 1 w y 2 00 01 11 10 w 00 01 11 10 1 d d 1 1 1 1 d 1 1 1 1 d d 1 Y2(w, y2, y1) = wy1 Y1(w, y2, y1) = w z(y2, y1) = y2

Original State Encodings New State Encodings: Y1 Y 1 y y y y 2 1 2 1 w 00 01 11 10 w 00 01 11 10 d d 1 1 d 1 1 1 1 d Y2 Y 2 y y y y 2 1 2 1 w w 00 01 11 10 00 01 11 10 d d 1 1 1 d 1 1 1 d z y z y 1 1 y y 2 1 2 1 1 1 d 1 d 1

Improved Result Y1(w, y2, y1) = w Y2(w, y2, y1) = wy1 z(y2, y1) = y2 Y Q z Y2(w, y2, y1) = wy1 Q z(y2, y1) = y2 Y y 1 1 w D Q Clock Q Resetn

Some may be better than others. Main Idea Different state assignments of the same Moore machine generally lead to different circuits. Some may be better than others.

Another Moore Machine: Register Swap Controller

Design a Moore machine control circuit for swapping the contents of registers R1 and R2 by using R3 as a temporary.

If an output is not given, then assume that it is 0. D: R 3 out 1 = in Done , w C: 2 B: A: No Transfer Reset If an output is not given, then assume that it is 0.

How many logic expressions do we need to find? How many flip-flops are we going to use?

, D: R 3 1 = Done w C: 2 B: A: No Transfer Reset W Z Next State Logic out 1 = in Done , w C: 2 B: A: No Transfer Reset W Z Next State Logic Q(t+1) Flip-Flop Array Q(t) Output Logic Clock

, D: R 3 1 = Done w C: 2 B: A: No Transfer Reset R1out w in Done , w C: 2 B: A: No Transfer Reset R1out w Next State Logic Y[1:2] Flip-Flop Array y[1:2] Output Logic R1in R2out R2in R3out Clock R3in Done

Present Next state Outputs state w = 0 w = 1 A B C D , D: R 3 1 = Done in Done , w C: 2 B: A: No Transfer Reset Present Next state Outputs state Done w = 0 w = 1 R1out R1in R2out R2in R3out R3in A B C D

Present Next state Outputs state w = 0 w = 1 A A B B C C 1 1 C D D 1 1 3 out 1 = in Done , w C: 2 B: A: No Transfer Reset Present Next state Outputs state w = 0 w = 1 R1out R1in R2out R2in R3out R3in Done A A B B C C 1 1 C D D 1 1 D A A 1 1 1

Consider two encoding schemes. As we saw before, we can expect that some state encodings will be better than others. Consider two encoding schemes.

Present Next state Outputs state w = 0 w = 1 A A B B C C 1 1 C D D 1 1 Naïve State Encoding Present Next state Outputs state Done w = 0 w = 1 R1out R1in R2out R2in R3out R3in A A B B C C 1 1 C D D 1 1 D A A 1 1 1 Present Next state state Outputs A 00 1 B 01 10 C 11 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done

Present Next state state Outputs A 00 1 B 01 10 C 11 D w = 0 w = 1 1 B 01 10 C 11 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done w y2 y1 Y2 Y1 1

Present Next state state Outputs A 00 1 B 01 10 C 11 D w = 0 w = 1 1 B 01 10 C 11 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done w y2 y1 Y2 Y1 1

Present Next state state Outputs A 00 1 B 01 10 C 11 D w = 0 w = 1 1 B 01 10 C 11 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done

Alternative State Encoding Present Next state Outputs state Done w = 0 w = 1 R1out R1in R2out R2in R3out R3in A A B B C C 1 1 C D D 1 1 D A A 1 1 1 Present Next state state Outputs A 00 1 B 01 11 C 10 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done

Present Next state state Outputs A 00 1 B 01 11 C 10 D Y Y y y y y w 1 B 01 11 C 10 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done Y Y 1 y y 2 y y 2 1 2 1 w w 00 01 11 10 00 01 11 10 1 1

Present Next state state Outputs A 00 1 B 01 11 C 10 D Y Y y y y y w 1 B 01 11 C 10 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done Y Y 1 y y 2 y y 2 1 2 1 w w 00 01 11 10 00 01 11 10 1 1 1 1 1 1 1 1 1 Y = y Y = wy + y y 1 2 1 2 2 1

One-Hot State Encoding

So far, we have been encoding states in a way that minimizes flip-flops. But we can sometimes decrease the complexity of our combinational logic if we encode states more sparsely.

Vehicle Speed Controller Next state Present Output state z w = w = 1 A A B B A C C A C 1 Let’s use three flip-flops and using the following one- hot state encoding scheme: A ~ 001 B ~ 010 C ~ 100

Vehicle Speed Controller Next state Present Output state z w = w = 1 A A B B A C C A C 1 Next State Present state Output w = w = 1 z y y y 3 2 1 Y Y Y Y Y Y 3 2 1 3 2 1 A 001 B 010 C 100 1

Vehicle Speed Controller Next state Present Output state z w = w = 1 A A B B A C C A C 1 Next State Present state Output w = w = 1 z y y y 3 2 1 Y Y Y Y Y Y 3 2 1 3 2 1 A 001 001 010 B 010 001 100 C 100 001 100 1

Next State Present state Output w = w = 1 z y y y Y Y Y Y Y Y 001 001 1 Next State Present state Output w = w = 1 z y y y 3 2 1 Y Y Y Y Y Y 3 2 1 3 2 1 001 001 010 010 001 100 100 001 100 1

Next State Present state Output w = w = 1 z y y y Y Y Y Y Y Y 001 001 d 1 Next State Present state Output w = w = 1 z y y y 3 2 1 Y Y Y Y Y Y 3 2 1 3 2 1 001 001 010 010 001 100 100 001 100 1

Next State Present state Output w = w = 1 z y y y Y Y Y Y Y Y 001 001 1 Next State Present state Output w = w = 1 z y y y 3 2 1 Y Y Y Y Y Y 3 2 1 3 2 1 001 001 010 010 001 100 100 001 100 1

w = y3 Y3 = wy1 Y2 = wy1 Y1 = w Next State Present state Output w = w 1 Next State Present state Output w = w = 1 z y y y 3 2 1 Y Y Y Y Y Y 3 2 1 3 2 1 001 001 010 010 001 100 100 001 100 1 w = y3 Y3 = wy1 Y2 = wy1 Y1 = w

Register Swap Controller Present Next state Outputs state w = 0 w = 1 R1out R1in R2out R2in R3out R3in Done A A B B C C 1 1 C D D 1 1 D A A 1 1 1

Register Swap Controller Present Next state Outputs state w = 0 w = 1 R1out R1in R2out R2in R3out R3in Done A A B B C C 1 1 C D D 1 1 D A A 1 1 1 Let’s use four flip-flops and the following one-hot state encoding scheme: A ~ 0001 B ~ 0010 C ~ 0100 D ~ 1000

Register Swap Controller Present Next state Outputs state Done w = 0 w = 1 R1out R1in R2out R2in R3out R3in A A B B C C 1 1 C D D 1 1 D A A 1 1 1 Present Next State Outputs State w = 0 w = 1 y4y3y2y1 Y4Y3Y2Y1 Y4Y3Y2Y1 R1out R1in R2out R2in R3out R3in Done A 001 B 010 1 1 C 100 1 1 D 1 000 1 1 1

Register Swap Controller Present Next state Outputs state w = 0 w = 1 R1out R1in R2out R2in R3out R3in Done A A B B C C 1 1 C D D 1 1 D A A 1 1 1 Present Next State Outputs State w = 0 w = 1 y4y3y2y1 Y4Y3Y2Y1 Y4Y3Y2Y1 R1out R1in R2out R2in R3out R3in Done A 001 0001 0010 B 010 0100 0100 1 1 C 100 1000 1000 1 1 D 1 000 0001 0001 1 1 1

What next state logic do we need? Y4(w, y4, y3, y2, y1) Y3(w, y4, y3, y2, y1) Y2(w, y4, y3, y2, y1) Y1(w, y4, y3, y2, y1) Present Next State Outputs State w = 0 w = 1 y4y3y2y1 Y4Y3Y2Y1 Y4Y3Y2Y1 R1out R1in R2out R2in R3out R3in Done A 001 0001 0010 B 010 0100 0100 1 1 C 100 1000 1000 1 1 D 1 000 0001 0001 1 1 1

What output logic do we need? R1out(y4, y3, y2, y1) R1in(y4, y3, y2, y1) R2out(y4, y3, y2, y1) R2in(y4, y3, y2, y1) R3out(y4, y3, y2, y1) R3in(y4, y3, y2, y1) Done(y4, y3, y2, y1) Present Next State Outputs State w = 0 w = 1 y4y3y2y1 Y4Y3Y2Y1 Y4Y3Y2Y1 R1out R1in R2out R2in R3out R3in Done A 001 0001 0010 B 010 0100 0100 1 1 C 100 1000 1000 1 1 D 1 000 0001 0001 1 1 1

Questions?

THE END