Lecture L5.1 Mealy and Moore Machines

Slides:



Advertisements
Similar presentations
Counters Discussion D8.3.
Advertisements

FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
FSM examples.
Arbitrary Waveform Discussion 5.5 Example 34.
1 VLSI DESIGN USING VHDL Part II A workshop by Dr. Junaid Ahmed Zubairi.
Multiplication Discussion Multiplier Binary Multiplication 4 x 4 Multiplier.
A Simple Microcontroller VHDL Tutorial R. E. Haskell and D. M. Hanna T6: VHDL State Machines.
Logic Design Fundamentals - 3 Discussion D3.2. Logic Design Fundamentals - 3 Basic Gates Basic Combinational Circuits Basic Sequential Circuits.
Registers VHDL Tutorial R. E. Haskell and D. M. Hanna T2: Sequential Logic Circuits.
RS-232 Port Discussion D7.1. Loop feedback RS-232 voltage levels: +5.5 V (logic 0) -5.5 V (logic 1)
Integer Square Root.
6/27/20061 Sequence Detectors Lecture Notes – Lab 5 Sequence detection is the act of recognizing a predefined series of inputs A sequence detector is a.
6/12/20151 Sequence Detectors Lecture Notes – Lab 4 Sequence detection is the act of recognizing a predefined series of inputs A sequence detector is a.
Designing State Machines Lecture L9.2 Handout Section 9.2.
Structural VHDL VHDL Tutorial R. E. Haskell and D. M. Hanna T3: ALU Design.
Counters Discussion D5.3 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
Finite State Machines Discussion D7.1 Mealy and Moore Machines.
Multiplication Discussion Multiplier Binary Multiplication 4 x 4 Multiplier.
Logic Design Review – 3 Basic Sequential Circuits Lecture L14.3 Verilog.
7-Segment Display DIO1 Board. Digilab2 – DIO1 Boards Four 7-segment displays A0A1A2A3.
Lecture L6.2 VHDL Multiply Operator (*)
Lab 2 4-Bit Adder Digilent Spartan 3 Board Lecture L2.3.
Division Lecture L6.3. Division
Ring Counter Discussion 11.3 Example 32.
Finite State Machines Mano and Kime Sections 4-4, 4-5, 4-8.
Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise “010”true if b < a.
Finite State Machines Discussion D8.1 Example 36.
Division Discussion D11.3. Division
Sequential Multiplication Lecture L6.4. Multiplication 13 x = 8Fh 1101 x
Shift Registers Discussion D5.2 Example Bit Shift Register qs(3) qs(2) qs(1) qs(0) if rising_edge(CLK) then for i in 0 to 2 loop s(i) := s(i+1);
7-Segment Display DIO1 Board Verilog.
Random-Access Memory Distributed and Block RAM Discussion D10.3 Example 41.
Sequential Logic in Verilog
LAB 9 Finite State Machine (FSM) Ui Luu Glendale Community College Bassam Matar Chandler-Gilbert Community College.
Finite State Machines VHDL ET062G & ET063G Lecture 6 Najeem Lawal 2012.
ELEC / Computer Architecture and Design Fall 2009 ELEC / Computer Architecture and Design Fall 2009 Modeling for Synthesis.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
Finite state machines Modelling FSM in VHDL. Types of automata (FSM) A sequential automaton has: –Inputs –States (a finite number of states) –Outputs.
 Seattle Pacific University EE Logic System DesignCounters-1 Shift Registers DQ clk DQ DQ ShiftIn Q3Q3 Q2Q2 DQ Q1Q1 Q0Q0 A shift register shifts.
CEC 220 Digital Circuit Design VHDL in Sequential Logic Wednesday, March 25 CEC 220 Digital Circuit Design Slide 1 of 13.
George Mason University Controllers for Keccak_F and AES ECE 545 Lecture 11 Addendum.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
Prime Numbers Lecture L6.1 Sieve of Eratosthenes.
Registers and Counters Discussion D8.1. Logic Design Fundamentals - 3 Registers Counters Shift Registers.
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
Exp#7 Finite State Machine Design in Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Sequential statements (1) process
Figure 8.1. The general form of a sequential circuit.
Main Project : Simple Processor Mini-Project : Vending Machine Memory
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
Part IV: VHDL CODING.
Supplement on Verilog Sequential circuit examples: FSM
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
HDL Compiler Unsupport (Do NOT use in your verilog code)
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
A Greatest Common Divisor (GCD) Processor
Fibonacci Sequence Lecture L4.1 Lab 3.
Multiplication Discussion 11.1.
COE 202 Introduction to Verilog
Supplement on Verilog Sequential circuit examples: FSM
Figure 8.1. The general form of a sequential circuit.
Fast, Asynchronous SRAM
The Verilog Hardware Description Language
RS-232 Port Discussion D12.1.
Finite state machines Modelling FSM in VHDL.
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Presentation transcript:

Lecture L5.1 Mealy and Moore Machines Finite State Machines Lecture L5.1 Mealy and Moore Machines

Canonical Sequential Network State Register Combinational Network x(t) s(t+1) s(t) z(t) clk init present state input next output

Mealy Machine init s(t+1) State Register C1 next C2 s(t) present z(t) clk init present state input next C2

Moore Machine init C2 z(t) s(t+1) State Register C1 next s(t) present clk init present state input next C2

VHDL Canonical Sequential Network init Combinational Network s(t+1) s(t) State Register next state present state x(t) present input process(clk, init) present output clk z(t) process(present_state, x)

VHDL Mealy Machine process(present_state, x) init s(t+1) State Register next state s(t) present state z(t) x(t) present input process(present_state, x) clk process(clk, init)

VHDL Moore Machine init C2 z(t) s(t+1) State Register C1 next s(t) present state x(t) present input process(present_state, x) process(present_state) clk process(clk, init)

Example Detect input sequence 1101 din fsm clk dout clr din dout 1 0 1 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0

Easy Solution: Use Shift Register dout 1 1 1 din Q0 Q1 Q2 Q3 D Q D Q D Q D Q CLK !Q CLK !Q CLK !Q CLK !Q CLK

More General: Use State Diagram Detect input sequence 1101 S1 1 1 S0 S11 CLR 1 1 S1101 1 S110 1

fsm.vhd din fsm clk dout clr

fsm.vhd

fsm.vhd

fsm.vhd S0 S1 S11 S110 S1101 1 CLR

fsm.vhd S0 S1 S11 S110 S1101 1 CLR

fsm.vhd

fsmx.vhd fsmx LD1 din fsm SW1 dout clr LD8 bn IBUFG clk BTN4 clk_pulse mclk clkdiv

clk_pulse entity cclk clr BTN4 clk_pulse clk entity clk_pulse is port ( BTN4, cclk, clr: in std_logic; clk: out std_logic ); end clk_pulse; cclk clr BTN4 clk_pulse clk

clk_pulse cclk BTN4 delay1 delay3 delay2 clk

cclk BTN4 delay1 delay3 delay2 clk BTN4 clk

clk_pulse architecture architecture clk_pulse_arch of clk_pulse is signal delay1, delay2, delay3: std_logic; begin process(clk, clr) if clr = '1' then delay1 <= '0'; delay2 <= '0'; delay3 <= '0'; elsif clk'event and clk='1' then delay1 <= BTN4; delay2 <= delay1; delay3 <= delay2; end if; end process; clk <= delay1 and delay2 and (not delay3); end clk_pulse_arch ;

fsmx.vhd entity fsmx is port( mclk : in STD_LOGIC; bn : in STD_LOGIC; SW1 : in STD_LOGIC; BTN4 : in STD_LOGIC; led: out std_logic; ldg : out STD_LOGIC; LD : out STD_LOGIC_VECTOR(1 to 2) ); end fsmx;

fsmx.vhd

fsmx.vhd component clk_pulse port( BTN4 : in std_logic; cclk : in std_logic; clr : in std_logic; clk : out std_logic); end component; signal clr, clk, cclk, bnbuf: std_logic; signal clkdiv: std_logic_vector(23 downto 0);

fsmx.vhd U0: clk_pulse port map (BTN4 => BTN4, cclk => cclk, clr =>clr, clk => clk); U1: fsm port map (clr =>clr, clk => clk, din => SW1, dout => LD(2)); LD(1) <= SW1;

Detect input sequence 1101

fsmv.v Verilog // Finite state machine -- detect sequence 1101 module fsm(clk,clr,din,dout); input clk, clr, din; output dout; reg dout; reg[4:0] present_state, next_state; parameter S0 = 5'b00001, S1 = 5'b00010, S11 = 5'b00100, S110 = 5'b01000, S1101 = 5'b10000; always @(posedge clk or posedge clr) begin if (clr == 1) present_state <= S0; else present_state <= next_state; end

fsmv.v (cont.) S1 always @(present_state or din) begin S0 S1 S11 S110 S1101 1 CLR always @(present_state or din) begin case(present_state) S0: if(din == 1) next_state <= S1; else next_state <= S0; S1: if(din == 1) next_state <= S11; S11: if(din == 0) next_state <= S110; else next_state <= S11; S110: if(din == 1) next_state <= S1101; S1101: if(din == 1) default next_state <= S0; endcase end fsmv.v (cont.)

fsmv.v (cont.) always @(present_state) begin if(present_state == S1101) dout = 1; else dout = 0; end endmodule

clk_pulse.v module clk_pulse(BTN4, cclk, clr, clk); input cclk, clr, BTN4; output clk; wire clk; reg delay1, delay2, delay3; always @(posedge cclk or posedge clr) begin if (clr == 1) delay1 <= 0; delay2 <= 0; delay3 <= 0; end else delay1 <= BTN4; delay2 <= delay1; delay3 <= delay2; assign clk = delay1 & delay2 & (!delay3); endmodule clk_pulse.v

fsmvx.v Top-level design module fsmx(mclk, bn, SW1, BTN4, led, ldg, LD); input mclk, bn, SW1, BTN4; output ldg, led; output [1:2] LD; wire [1:2] LD; wire clr, cclk, bnbuf; reg [26:0] clkdiv; IBUFG U00 (.I (bn), .O (bnbuf)); assign led = bnbuf; assign clr = bnbuf; assign ldg = 1; // enable 74HC373 latch

fsmvx.v (cont.) // Divide the master clock (50Mhz) always @(posedge mclk) begin clkdiv <= clkdiv + 1; end assign cclk = clkdiv[17]; // 190 Hz clk_pulse U0(.BTN4(BTN4),.cclk(cclk),.clr(clr),.clk(clk)); fsm U1(.din(SW1),.dout(LD[2]),.clr(clr),.clk(clk)); assign LD[1] = SW1; endmodule