Top Banner
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Week 8 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering
30

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Mar 06, 2018

Download

Documents

dangquynh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN

Week 8 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

Page 2: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

FINITE STATE MACHINE DESIGN PROCEDURE (Moore Machines)

Page 3: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Overview

  Design of systems that input flip flops and combinational logic

  Specifications start with a word description   Create a state table to indicate next states   Convert next states and outputs to output and flip

flop input equations  Reduce logic expressions using truth tables

  Draw resulting circuits.

Lots of opportunities for interesting design

Page 4: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Designing Finite State Machines

 Specify the problem with words  (e.g. Design a circuit that detects three

consecutive 1 inputs)  Assign binary values to states  Develop a state table  Use K-maps to simplify expressions

 Flip flop input equations and output equations

 Create appropriate logic diagram  Should include combinational logic and flip

flops

Page 5: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Example: Detect 3 Consecutive 1 inputs

State S0 : zero 1s detected State S1 : one 1 detected State S2 : two 1s detected State S3 : three 1s detected

0

Note that each state has 2 output arrows Two bits needed to encode state

Page 6: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

State Table for Sequence Detector

  Sequence of outputs, inputs, and flip flop states enumerated in state table

  Present state indicates current value of flip flops

  Next state indicates state after next rising clock edge

  Output is output value on current clock edge

Present State

Next State

A B x A B y 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 1 0 1 1 1 0 1 1 0 0 0 1 1 1 1 1 1 1

Present Output Input

S0 = 00 S1 = 01

S2 = 10 S3 = 11

Page 7: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Finding Expressions for Next State and Output Value   Create K-map directly from state table (3 columns = 3 K-maps)

  Minimize K-maps to find SOP representations

  Separate circuit for each next state and output value

Page 8: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Circuit for Consecutive 1s Detector

  Note location of state flip flops

  Output value (y) is function of state

  This is a Moore machine.

Page 9: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Concept of the State Machine Example: Odd Parity Checker

Assert output whenever input bit stream has odd # of 1's

State Diagram

Symbolic State Transition Table

Encoded State Transition Table

Note: Present state and output are the same value Moore machine

Page 10: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Concept of the State Machine Example: Odd Parity Checker

Next State/Output Functions

NS = PS xor PI; OUT = PS

D FF Implementation

Timing Behavior: Input 1 0 0 1 1 0 1 0 1 1 1 0

Page 11: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Mealy and Moore Machines

Solution 1: (Mealy)

0/0

Even

Odd

1/1 1/0

0/1

0 Even

1 1

0

Reset [0]

Odd [1]

Output

Input Output

Input

Transition Arc

Output is dependent only on current state

O/P is dependent on current state and input in Mealy

Solution 2: (Moore)

Mealy Machine: Output is associated with the state transition - Appears before the state transition is completed (by the next clock pulse).

Moore Machine: Output is associated with the state - Appears after the state transition takes place.

Page 12: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Vending Machine FSM

 Deliver package of gum after 15 cents deposited

 Single coin slot for dimes, nickels

 No change

 Design the FSM using combinational logic and flip flops

Page 13: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Vending Machine FSM

Symbolic State Table

Page 14: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Vending Machine FSM How many flip-flops are needed?

Page 15: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Vending Machine FSM

K-map for Open K-map for D0 K-map for D1

Q1 Q0 D N

Q1

Q0

D N

Q1 Q0 D N

Q1

Q0

D N

Q1 Q0 D N

Q1

Q0

D N

Page 16: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

D Q

Q R

D Q

Q R

Q0

N

N

Q0

Q1 N

Q1 D

D0

D1 Q1

OPEN

D

CLK

CLK

Vending machine FSM implementation based on D flip-flops(Moore).

Q1

Q0

Reset

Reset

Minimized Implementation

Page 17: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Summary

  Finite state machines form the basis of many digital systems

  Designs often start from clear specifications   Develop state diagram and state table   Optimize using combinational design techniques   Mealy or Moore implementations possible

 Can model approach using HDL.

Page 18: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Counters

Page 19: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Overview   Counters are important components in computers

 The increment or decrement by one in response to input

  Two main types of counters  Ripple (asynchronous) counters  Synchronous counters

  Ripple counters  Flip flop output serves as a source for triggering other

flip flops

  Synchronous counters  All flip flops triggered by a clock signal

  Synchronous counters are more widely used in industry.

Page 20: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Shift Register   Cascade chain of Flip-Flops   Bits travel on Clock edges   Serial in – Serial out, can also have parallel

load / read

Page 21: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Binary Ripple Counter

  Reset signal sets all outputs to 0

  Count signal toggles output of low-order flip flop

  Low-order flip flop provides trigger for adjacent flip flop

  Not all flip flops change value simultaneously   Lower-order flops change first

  Focus on D flip flop implementation

Count

Page 22: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Another Asynchronous Ripple Counter

°  Similar to T flip-flop example on previous slide

Page 23: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Asynchronous Counters   Each FF output drives the CLK input of the next FF.   FFs do not change states in exact synchronism with

the applied clock pulses.   There is delay between the responses of successive

FFs.   Ripple counter due to the way the FFs respond one

after another in a kind of rippling effect. A3 A2 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 0

A1 0 0 1 1 0 0 0 0

A0 0 1 0 1 0 1 0 1

Page 24: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Synchronous Counters

Page 25: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Synchronous counters

  Synchronous(parallel) counters   All of the FFs are triggered

simultaneously by the clock input pulses.

  All FFs change at same time

  Remember   If J=K=0, flop maintains value

  If J=K=1, flop toggles

  Most counters are synchronous in computer systems.

  Can also be made from D flops

  Value increments on positive edge

  Note that low-order bit (A0) toggles on each clock cycle

Page 26: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Synchronous UP/Down counters

  Up/Down Counter can either count up or down on each clock cycle

  Up counter counts from 0000 to 1111 and then changes back to 0000

  Down counter counts from 1111 to 0000 and then back to 1111

  Counter counts up or down each clock cycle

  Output changes occur on clock rising edge

Page 27: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Counters with Parallel Load

  Counters with parallel load can have a preset value

  Load signal indicates that data (I3…I0) should be loaded into the counter

  Clear resets counter to all zeros

  Carry output could be used for higher-order bits

Page 28: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Counters with Parallel Load

Clear Clk Load Count Function 0 X X X Clear to 0 1 ↑ 1 X Load inputs 1 ↑ 0 1 Count 1 ↑ 0 0 No Change

Function Table

  If Clear is asserted (0), the counter is cleared

  If Load is asserted data inputs are loaded

  If Count asserted counter value is incremented

Page 29: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Binary Counter with Parallel Load and Asynchronous Preset

If PL’ = 0, load P into flops

Page 30: ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGNdropzone.tamu.edu/~sshakkot/courses/ECEN248/week8.pdf · ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN ... Create a state table

Binary Counter with Parallel Load and Preset

•  Commercial version of binary counter