COMP 211 Computer Logic Design Lecture 4 Sequential

  • Slides: 35
Download presentation
COMP 211 Computer Logic Design Lecture 4. Sequential Logic 2 Prof. Taeweon Suh Computer

COMP 211 Computer Logic Design Lecture 4. Sequential Logic 2 Prof. Taeweon Suh Computer Science Education Korea University

Clock Oscillators 2 Korea Univ

Clock Oscillators 2 Korea Univ

Clock Oscillators in Digital Systems • Virtually all digital systems are essentially operating synchronous

Clock Oscillators in Digital Systems • Virtually all digital systems are essentially operating synchronous to the clock 3 Korea Univ

Where are Clock Oscillators? 4 Korea Univ

Where are Clock Oscillators? 4 Korea Univ

Clock in Digital Circuit 5 Korea Univ

Clock in Digital Circuit 5 Korea Univ

Synchronous Sequential Logic • Output of sequential logic is determined not only by current

Synchronous Sequential Logic • Output of sequential logic is determined not only by current inputs but also by state stored in registers • When sequential logic is working (updated) at the event (e. g. , rising or falling edge) of clock source, we say that the circuit is synchronous to the clock § In other words, if the state is updated at the event of clock source, the circuit is synchronous sequential logic • Virtually all digital systems are essentially synchronous to the clock § Virtually all digital systems are synchronous sequential logic 6 Korea Univ

Synchronous Sequential Logic • Synchronous sequential logic composition § Every circuit element is either

Synchronous Sequential Logic • Synchronous sequential logic composition § Every circuit element is either a register or a combinational circuit § At least one circuit element is a register § All registers receive the same clock signal § Every cyclic path contains at least one register • Two common synchronous sequential circuits § Finite state machines (FSMs) § Pipelines • will talk in depth about pipelining in computer architecture course next semester 7 Korea Univ

Finite State Machine (FSM) • Finite state machines (FSMs) is composed of 2 components:

Finite State Machine (FSM) • Finite state machines (FSMs) is composed of 2 components: registers and combinational logic § Registers represent one of the finite number of states • k registers can represent one of a finite number (2 K) of unique states • An initial state (in registers) is assigned based on reset input at the (rising or falling) edge of clock • The next state may change depending on the current state as the next input comes in § Based on the current state (and input), output is determined via combinational logic 8 Korea Univ

FSM Quick Example • Vending machine § You are asked to design a vending

FSM Quick Example • Vending machine § You are asked to design a vending machine to sell cokes. • Suppose that a coke costs 300 won • The machine takes only 100 won coins § How would you design a logic with inputs and output? 100 won reset 100 won State 1 State 0 State 2 State 3 / coke out 100 won 9 Korea Univ

Finite State Machine (FSM) • FSM is composed of 100 won § State register

Finite State Machine (FSM) • FSM is composed of 100 won § State register State 1 reset • Stores the current state • Loads the next state at the clock edge State 0 § Combinational logic Current State Inputs State 2 State 3 / coke out • Computes the next state based on current state and input • Computes the outputs based on current state (and input) 100 won Outputs Current State This slide is the Moore FSM example 10 Korea Univ

Finite State Machines (FSMs) • Next state is determined by the current state and

Finite State Machines (FSMs) • Next state is determined by the current state and the inputs • Two types of FSMs differ in the output logic § Moore FSM: outputs depend only on the current state § Mealy FSM: outputs depend on the current state and inputs 11 Korea Univ

Moore and Mealy • Edward F. Moore, 1925 - 2003 § Together with Mealy,

Moore and Mealy • Edward F. Moore, 1925 - 2003 § Together with Mealy, developed automata theory, the mathematical underpinnings of state machines, at Bell Labs. § Not to be confused with Intel founder Gordon Moore § Published a seminal article, Gedanken-experiments on Sequential Machines in 1956 • George H. Mealy § Published “A Method of Synthesizing Sequential Circuits” in 1955 § Wrote the first Bell Labs operating system for the IBM 704 computer 12 Korea Univ

Finite State Machine Example • Let’s design a simplified traffic light controller § Traffic

Finite State Machine Example • Let’s design a simplified traffic light controller § Traffic sensors (sensing human traffic): TA, TB • Each sensor becomes TRUE if students are present • Each sensor becomes FALSE if students are NOT present (i. e. , the street is empty) § Lights: LA, LB • Each light receives digital inputs specifying whether it should be green, yellow, or red Inputs: clk, Reset, TA, TB Outputs: LA, LB 13 Korea Univ

FSM State Transition Diagram • Moore FSM § Circles represent states § Arcs represent

FSM State Transition Diagram • Moore FSM § Circles represent states § Arcs represent transitions between states § Outputs are labeled in each state TA Reset S 0 TA LA: green LB: red S 2 S 3 LA: red LB: green LA: red LB: yellow TB 14 S 1 LA: yellow LB: red TB Korea Univ

FSM State Transition Table Current State Next State Inputs S TA TB S' S

FSM State Transition Table Current State Next State Inputs S TA TB S' S 0 0 X S 1 S 0 1 X S 0 S 1 X X S 2 X 0 S 3 S 2 X 1 S 2 S 3 X X S 0 15 Korea Univ

FSM Encoded State Transition Table Current State Encoding S 0 00 S 1 01

FSM Encoded State Transition Table Current State Encoding S 0 00 S 1 01 S 2 10 S 3 11 Inputs Next State S 1 S 0 TA TB S'1 S'0 0 X 0 1 0 0 1 X 0 0 0 1 X X 1 0 X 0 1 1 1 0 X 1 1 0 1 1 X X 0 0 S'1 = S 1 Å S 0 S'0 = S 1 S 0 TA + S 1 S 0 TB 16 Korea Univ

FSM Output Table Current State Output Encoding green 00 yellow 01 red 10 Outputs

FSM Output Table Current State Output Encoding green 00 yellow 01 red 10 Outputs S 1 S 0 LA 1 LA 0 LB 1 LB 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 17 LA 1 = S 1 LB 1 = S 1 LA 0 = S 1 S 0 LB 0 = S 1 S 0 Korea Univ

FSM Schematic: State Register 18 Korea Univ

FSM Schematic: State Register 18 Korea Univ

FSM Schematic: Next State Logic S'1 = S 1 Å S 0 S'0 =

FSM Schematic: Next State Logic S'1 = S 1 Å S 0 S'0 = S 1 S 0 TA + S 1 S 0 TB 19 Korea Univ

FSM Schematic: Output Logic LA 1 = S 1 LA 0 = S 1

FSM Schematic: Output Logic LA 1 = S 1 LA 0 = S 1 S 0 LB 1 = S 1 LB 0 = S 1 S 0 20 Korea Univ

FSM Timing Diagram 21 Korea Univ

FSM Timing Diagram 21 Korea Univ

FSM State Encoding • In the previous example, the state and output encodings were

FSM State Encoding • In the previous example, the state and output encodings were selected arbitrarily § Different choice would have resulted in a different circuit • Commonly used encoding methods § Binary encoding • Each state is represented as a binary number § For example, to represent four states, we need 2 bits (00, 01, 10, 11) § One-hot encoding • A separate bit is used for each state • Only one bit is HIGH at once (one-hot) § For example, to represent four states, we need 4 bits (0001, 0010, 0100, 1000) § So, it requires more flip-flops • But, it often results in simpler next state and output logic 22 Korea Univ

Moore vs. Mealy FSM • Two types of FSMs differ in the output logic

Moore vs. Mealy FSM • Two types of FSMs differ in the output logic § Moore FSM: outputs depend only on the current state § Mealy FSM: outputs depend on the current state and the inputs 23 Korea Univ

Snail Example • There is a snail § The snail crawls down a paper

Snail Example • There is a snail § The snail crawls down a paper tape with 1’s and 0’s on it § The snail smiles whenever the last four digits it has crawled over are 1101 • Design Moore and Mealy FSMs of the snail’s brain 24 Korea Univ

State Transition Diagrams (1101) Moore FSM: arcs indicate input reset 1 0 1 1

State Transition Diagrams (1101) Moore FSM: arcs indicate input reset 1 0 1 1 0 0 0 11 S 0 0 1 1 1101 S 2 S 3 S 4 0 0 1 0 0 Mealy FSM: arcs indicate input/output reset 0/0 1/0 S 0 0/0 1 1/0 S 1 1/1 11 S 2 0/0 110 S 3 1/0 0/0 25 Korea Univ

Moore FSM State Transition Table 26 Current State Inputs Next State S A S'

Moore FSM State Transition Table 26 Current State Inputs Next State S A S' S 0 0 S 0 1 S 1 0 S 1 1 S 2 0 S 3 S 2 1 S 2 S 3 0 S 0 1 S 4 0 S 4 1 S 2 Korea Univ

Moore FSM State Transition Table Current State Encoding S 0 000 S 1 001

Moore FSM State Transition Table Current State Encoding S 0 000 S 1 001 S 2 010 S 3 011 S 4 100 S'2 = S 1 S 0 A S'1 = S 1 S 0 A + S 1 S 0 + S 2 A Inputs Next State S 2 S 1 S 0 A S'2 S'1 S'0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 0 0 1 0 0 1 0 S'0 = S 2 S 1 S 0 A + S 1 S 0 A 27 Korea Univ

Moore FSM Output Table Current State Output S 2 S 1 S 0 Y

Moore FSM Output Table Current State Output S 2 S 1 S 0 Y S 0 0 0 S 1 0 0 1 0 S 2 0 1 0 0 S 3 0 1 1 0 S 4 1 0 0 1 28 Y = S 2 Korea Univ

Moore FSM Schematic S'2 = S 1 S 0 A S'1 = S 1

Moore FSM Schematic S'2 = S 1 S 0 A S'1 = S 1 S 0 A + S 1 S 0 + S 2 A S'0 = S 2 S 1 S 0 A + S 1 S 0 A Y = S 2 29 Korea Univ

Mealy FSM State Transition and Output Table Current State Inputs Next State Output S

Mealy FSM State Transition and Output Table Current State Inputs Next State Output S A S' Y S 0 0 S 0 1 S 1 0 S 0 0 S 1 1 S 2 0 S 3 0 0 S 2 1 S 2 0 S 3 0 S 0 0 1 S 1 1 30 Korea Univ

Mealy FSM State Transition and Output Table Current State Input Next State Output S

Mealy FSM State Transition and Output Table Current State Input Next State Output S 1 S 0 A S'1 S'0 Y 0 0 0 State Encoding 0 0 1 0 S 0 00 0 1 0 0 S 1 01 0 1 1 1 0 0 S 2 10 1 0 0 1 1 0 S 3 11 1 0 0 1 1 1 0 1 1 S'1 = S 1 S 0 + S 1 S 0 A S'0 = S 1 S 0 A + S 1 S 0 A Y = S 1 S 0 A 31 Korea Univ

Mealy FSM Schematic S'1 = S 1 S 0 + S 1 S 0

Mealy FSM Schematic S'1 = S 1 S 0 + S 1 S 0 A S'0 = S 1 S 0 A + S 1 S 0 A Y = S 1 S 0 A 32 Korea Univ

Moore and Mealy Timing Diagram 33 Korea Univ

Moore and Mealy Timing Diagram 33 Korea Univ

Difference between Moore and Mealy • A Moore machine typically has more states than

Difference between Moore and Mealy • A Moore machine typically has more states than a Mealy machine for a given problem • A Mealy machine’s output rises a cycle sooner because it responds to the input rather than waiting for the state change • When choosing your FSM design style, consider when you want your outputs to respond 34 Korea Univ

FSM Design Procedure • Identify inputs and outputs • Sketch a state transition diagram

FSM Design Procedure • Identify inputs and outputs • Sketch a state transition diagram • Write a state transition table • Select state encodings • For a Moore machine § Rewrite the state transition table with the state encodings § Write the output table • For a Mealy machine § Rewrite the combined state transition table and output table with the state encodings • Write Boolean equations for the next state and output logic • Sketch the circuit schematic 35 Korea Univ