Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams

Slides:



Advertisements
Similar presentations
Give qualifications of instructors: DAP
Advertisements

Finite State Machine Chapter 10 RTL Hardware Design by P. Chu.
Fundamentals of Digital Signal Processing יהודה אפק, נתן אינטרטור אוניברסיטת תל אביב.
CS 151 Digital Systems Design Lecture 37 Register Transfer Level
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.
3/20/20091 More State Machines. Multiple processes.
Dr. Turki F. Al-Somani VHDL synthesis and simulation – Part 3 Microcomputer Systems Design (Embedded Systems)
Sequencing and Control Mano and Kime Sections 8-1 – 8-7.
Finite State Machines Discussion D8.1 Example 36.
ECE C03 Lecture 141 Lecture 14 VHDL Modeling of Sequential Machines Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Algorithmic State Machine (ASM) Charts
George Mason University ECE 448 – FPGA and ASIC Design with VHDL Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts,
George Mason University ECE 448 – FPGA and ASIC Design with VHDL Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448.
IC-UNICAMP MC 603/ Finite State Machines Mixed Style RTL Modeling Extraído da George Mason Univ. ECE 545 Lecture 5.
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches.
CS/EE 3700 : Fundamentals of Digital System Design Chris J. Myers Lecture 8: Synchronous Sequential Circuits Chapter 8.
Data Flow Modeling of Combinational Logic Simple Testbenches
Finite State Machines VHDL ET062G & ET063G Lecture 6 Najeem Lawal 2012.
VHDL Introduction. V- VHSIC Very High Speed Integrated Circuit H- Hardware D- Description L- Language.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
George Mason University ECE 545 – Introduction to VHDL ECE 545 Lecture 5 Finite State Machines.
CprE / ComS 583 Reconfigurable Computing
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
George Mason University Design of Controllers Finite State Machines and Algorithmic State Machine (ASM) Charts ECE 545 Lecture 14.
1 ECE 545—Digital System Design with VHDL Lecture 6 Behavioral VHDL Coding (for Synthesis): Finite State Machines and ASMs 9/30/08.
George Mason University Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL Code ECE 448 Lecture 6.
VHDL Discussion Finite State Machines
VHDL Discussion Finite State Machines IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
CEC 220 Digital Circuit Design VHDL in Sequential Logic Wednesday, March 25 CEC 220 Digital Circuit Design Slide 1 of 13.
Controllers ENGIN 341 – Advanced Digital Design University of Massachusetts Boston Department of Engineering Dr. Filip Cuckov.
Algorithmic State Machines Sorting Signed & Unsigned Data Types
Hao Zheng Comp Sci & Eng USF CDA 4253 FPGA System Design Chapter 5 Finite State Machines.
ENG241 Digital Design Week #7 Sequential Circuits (Part B)
1 ECE 545 – Introduction to VHDL Algorithmic State Machines Sorting Example ECE 656 Lecture 8.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
ECE DIGITAL LOGIC LECTURE 20: REGISTERS AND COUNTERS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/19/2015.
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
ECE DIGITAL LOGIC LECTURE 21: FINITE STATE MACHINE Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/24/2015.
George Mason University Design of Controllers using Algorithmic State Machine (ASM) Charts ECE 545 Lecture 12.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
Digital Design with SM Charts
George Mason University Finite State Machines Refresher ECE 545 Lecture 11.
Sequential statements (1) process
Finite State Machines (part 1)
Week #7 Sequential Circuits (Part B)
Describing Combinational Logic Using Processes
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL Code.
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
Hao Zheng Comp Sci & Eng USF
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
RTL Design Methodology
Sequential-Circuit Building Blocks
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
VHDL (VHSIC Hardware Description Language)
ECE 545 Lecture 12 Design of Controllers Finite State Machines and Algorithmic State Machine (ASM) Charts.
ECE 545 Lecture 10 Design of Controllers Finite State Machines and Algorithmic State Machine (ASM) Charts.
ECE 545 Lecture 9 Design of Controllers Finite State Machines and Algorithmic State Machine (ASM) Charts.
VHDL Introduction.
ECE 545 Lecture 11 Design of Controllers Finite State Machines and Algorithmic State Machine (ASM) Charts.
Behavioral Modeling of Sequential-Circuit Building Blocks
Figure 8.1. The general form of a sequential circuit.
Finite State Machines (part 1)
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL Code.
RTL Design Methodology Transition from Pseudocode & Interface
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL code ECE 448 – FPGA and ASIC Design.
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Sequntial-Circuit Building Blocks
(Sequential-Circuit Building Blocks)
Presentation transcript:

Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams ECE 448 Lecture 7 Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams

Required reading P. Chu, FPGA Prototyping by VHDL Examples Chapter 5, FSM

Recommended reading S. Brown and Z. Vranesic, Fundamentals of Digital Logic with VHDL Design Chapter 8, Synchronous Sequential Circuits Sections 8.1-8.5 Section 8.10, Algorithmic State Machine (ASM) Charts

Finite State Machines in VHDL Style 1

Present State Register Moore FSM process(clock, reset) Inputs Next State function Next State clk Present State Register Present State reset concurrent statements Output function Outputs

Present State Register Mealy FSM process(clock, reset) Inputs Next State function Next State Present State clk Present State Register reset Output function Outputs concurrent statements

ASM Chart of Moore Machine reset S0 input 1 S1 1 input S2 output 1 input

Moore FSM in VHDL (1) LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY FSM_Moore_1 IS PORT ( clk : IN STD_LOGIC ; reset : IN STD_LOGIC ; input : IN STD_LOGIC ; output : OUT STD_LOGIC) ; END FSM_Moore_1 ;

Moore FSM in VHDL (2) ARCHITECTURE behavioral of FSM_Moore_1 IS TYPE state IS (S0, S1, S2); SIGNAL Present_State: state; BEGIN U_Moore: PROCESS (clk, reset) IF(reset = '1') THEN Present_State <= S0; ELSIF rising_edge(clk) THEN CASE Present_State IS WHEN S0 => IF input = '1' THEN Present_State <= S1; ELSE END IF;

Moore FSM in VHDL (3) WHEN S1 => IF input = '0' THEN Present_State <= S2; ELSE Present_State <= S1; END IF; WHEN S2 => IF input = '1' THEN Present_State <= S0; END CASE; END PROCESS; Output <= '1' WHEN Present_State = S2 ELSE '0'; END behavioral;

ASM Chart of Mealy Machine reset S0 input 1 output S1 1 input

Mealy FSM in VHDL (1) LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY FSM_Mealy_1 IS PORT ( clk : IN STD_LOGIC ; reset : IN STD_LOGIC ; input : IN STD_LOGIC ; output : OUT STD_LOGIC) ; END FSM_Mealy_1 ;

Mealy FSM in VHDL (2) ARCHITECTURE behavioral of FSM_Mealy_1 IS TYPE state IS (S0, S1); SIGNAL Present_State: state; BEGIN U_Mealy: PROCESS(clk, reset) IF(reset = '1') THEN Present_State <= S0; ELSIF rising_edge(clk) THEN CASE Present_State IS WHEN S0 => IF input = '1' THEN Present_State <= S1; ELSE END IF;

Mealy FSM in VHDL (3) WHEN S1 => IF input = '0' THEN Present_State <= S0; ELSE Present_State <= S1; END IF; END CASE; END PROCESS; Output <= '1' WHEN (Present_State = S1 AND input = '0') ELSE '0'; END behavioral;

Finite State Machines in VHDL Style 2

Alternative Coding Style Process(Present State, Input) Present State Next State Process(clk, reset) Based on RTL Hardware Design by P. Chu

ASM Chart of Moore Machine reset S0 input 1 S1 1 input S2 output 1 input

Moore FSM in VHDL (1) LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY FSM_Moore_2 IS PORT ( clk : IN STD_LOGIC ; reset : IN STD_LOGIC ; input : IN STD_LOGIC ; output : OUT STD_LOGIC) ; END FSM_Moore_2 ;

Moore FSM in VHDL (1) ARCHITECTURE behavioral of FSM_Moore_2 IS TYPE state IS (S0, S1, S2); SIGNAL Present_State, Next_State: state; BEGIN U_Moore: PROCESS (clk, reset) IF(reset = '1') THEN Present_State <= S0; ELSIF rising_edge(clk) THEN Present_State <= Next_State; END IF; END PROCESS;

Moore FSM in VHDL (2) Next_State_Output: PROCESS (Present_State, input) BEGIN Next_State <= Present_State; output <= '0'; CASE Present_State IS WHEN S0 => IF input = '1' THEN Next_State <= S1; ELSE Next_State <= S0; END IF;

Moore FSM in VHDL (3) WHEN S1 => IF input = '0' THEN Next_State <= S2; ELSE Next_State <= S1; END IF; WHEN S2 => output <= '1' ; IF input = '1' THEN Next_State <= S0; END CASE; END PROCESS; END behavioral;

ASM Chart of Mealy Machine reset S0 input 1 output S1 1 input

Mealy FSM in VHDL (1) LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY FSM_Mealy_2 IS PORT ( clk : IN STD_LOGIC ; reset : IN STD_LOGIC ; input : IN STD_LOGIC ; output : OUT STD_LOGIC) ; END FSM_Mealy_2 ;

Mealy FSM in VHDL (1) ARCHITECTURE behavioral of FSM_Mealy_2 IS TYPE state IS (S0, S1); SIGNAL Present_State, Next_State: state; BEGIN U_Mealy: PROCESS(clk, reset) IF(reset = '1') THEN Present_State <= S0; ELSIF rising_edge(clk) THEN Present_State <= Next_State; END IF; END PROCESS;

Mealy FSM in VHDL (2) Next_State_Output: PROCESS (Present_State, input) BEGIN Next_State <= Present_State; output <= '0'; CASE Present_State IS WHEN S0 => IF input = '1' THEN Next_State <= S1; ELSE Next_State <= S0; END IF;

Mealy FSM in VHDL (3) WHEN S1 => IF input = '0' THEN Next_State <= S0; Output <= '1' ; ELSE Next_State <= S1; END IF; END CASE; END PROCESS; END behavioral;

Control Unit Example: Arbiter (1) reset r1 g1 r2 Arbiter g2 r3 g3 clock

ASM Chart for Control Unit - Example 4

VHDL code of arbiter – Style 1 (1) LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY arbiter IS PORT ( Clk, Reset : IN STD_LOGIC ; r : IN STD_LOGIC_VECTOR(1 TO 3) ; g : OUT STD_LOGIC_VECTOR(1 TO 3) ) ; END arbiter ; ARCHITECTURE Behavior OF arbiter IS TYPE State_type IS (Idle, gnt1, gnt2, gnt3) ; SIGNAL y : State_type ;

VHDL code of arbiter – Style 1 (2) BEGIN PROCESS ( Reset, Clk ) IF Reset = '1' THEN y <= Idle ; ELSIF rising_edge(Clk) THEN CASE y IS WHEN Idle => IF r(1) = '1' THEN y <= gnt1 ; ELSIF r(2) = '1' THEN y <= gnt2 ; ELSIF r(3) = '1' THEN y <= gnt3 ; ELSE y <= Idle ; END IF ; WHEN gnt1 => IF r(1) = '0' THEN y <= Idle ; ELSE y <= gnt1 ;

VHDL code of arbiter – Style 1 (3) WHEN gnt2 => IF r(2) = '0' THEN y <= Idle ; ELSE y <= gnt2 ; END IF ; WHEN gnt3 => IF r(3) = '0' THEN y <= Idle ; ELSE y <= gnt3 ; END CASE ; END PROCESS ; g(1) <= '1' WHEN y = gnt1 ELSE '0' ; g(2) <= '1' WHEN y = gnt2 ELSE '0' ; g(3) <= '1' WHEN y = gnt3 ELSE '0' ; END Behavior ;

VHDL code of arbiter – Style 2 (1) LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY arbiter IS PORT ( Clk, Reset : IN STD_LOGIC ; r : IN STD_LOGIC_VECTOR(1 TO 3) ; g : OUT STD_LOGIC_VECTOR(1 TO 3) ) ; END arbiter ; ARCHITECTURE Behavior OF arbiter IS TYPE State_type IS (Idle, gnt1, gnt2, gnt3) ; SIGNAL y, y_next : State_type ;

VHDL code of arbiter – Style 2 (2) BEGIN PROCESS ( Reset, Clk ) IF Reset = '1' THEN y <= Idle ; ELSIF rising_edge(Clk) THEN y <= y_next; END IF; END PROCESS;

VHDL code of arbiter – Style 2 (3) PROCESS ( y, r ) BEGIN y_next <= y; g <= "000"; CASE y IS WHEN Idle => IF r(1) = '1' THEN y_next <= gnt1 ; ELSIF r(2) = '1' THEN y_next <= gnt2 ; ELSIF r(3) = '1' THEN y_next <= gnt3 ; ELSE y_next <= Idle ; END IF ; WHEN gnt1 => g(1) <= '1' ; IF r(1) = '0' THEN y_next <= Idle ; ELSE y_next <= gnt1 ;

VHDL code of arbiter – Style 2 (4) WHEN gnt2 => g(2) <= '1' ; IF r(2) = '0' THEN y_next <= Idle ; ELSE y_next <= gnt2 ; END IF ; WHEN gnt3 => IF r(3) = '0' THEN y_next <= Idle ; ELSE y_next <= gnt3 ; END CASE ; END PROCESS ; END Behavior ;

Problem 1 Assuming ASM chart given on the next slide, supplement timing waveforms given in the answer sheet with the correct values of signals State, g1, g2, g3, in the interval from 0 to 575 ns.

ASM Chart

Reset Clk r1 r2 r3 State g1 g2 g3 0 ns 100 ns 200 ns 300 ns 400 ns

Problem 2 Assuming state diagram given on the next slide, supplement timing waveforms given in the answer sheet with the correct values of signals State and c, in the interval from 0 to 575 ns.

Reset X 1 a c Y c 1 b Z c 1 b

Clk a b State c Reset 0 ns 100 ns 200 ns 300 ns 400 ns 500 ns

ASM Summary by Prof. Chu ASM (algorithmic state machine) chart Flowchart-like diagram Provides the same info as a state diagram More descriptive, better for complex description ASM block One state box One or more optional decision boxes: with 1 (T) or 0 (F) exit path One or more conditional output boxes: for Mealy output

ASM Chart Rules Difference between a regular flowchart and an ASM chart: Transition governed by clock Transition occurs between ASM blocks Basic rules: For a given input combination, there is one unique exit path from the current ASM block Any closed loop in an ASM chart must include a state box Based on RTL Hardware Design by P. Chu

Incorrect ASM Charts Based on RTL Hardware Design by P. Chu

Generalized FSM Based on RTL Hardware Design by P. Chu