Some VHDL Details 10/8/08 ECE - 561 Lecture 8.

Slides:



Advertisements
Similar presentations
VHDL Lecture 1 Megan Peck EECS 443 Spring 08.
Advertisements

Give qualifications of instructors: DAP
1 Lecture 13 VHDL 3/16/09. 2 VHDL VHDL is a hardware description language. The behavior of a digital system can be described (specified) by writing a.
L18 – VHDL for other counters and controllers. Other counters  More examples Gray Code counter Controlled counters  Up down counter  Ref: text Unit.
History TTL-logic PAL (Programmable Array Logic)
CS 151 Digital Systems Design Lecture 37 Register Transfer Level
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.
Dr. Turki F. Al-Somani VHDL synthesis and simulation – Part 3 Microcomputer Systems Design (Embedded Systems)
Introduction to VHDL (part 2)
L16 – Testbenches for state machines. VHDL Language Elements  More examples HDL coding of class examples Testbench for example  Testing of examples.
VHDL Introduction. V- VHSIC Very High Speed Integrated Circuit H- Hardware D- Description L- Language.
1/8/ L20 Project Step 8 - Data Path Copyright Joanne DeGroat, ECE, OSU1 State Machine Design with an HDL A methodology that works for documenting.
Digital Design with VHDL Presented by: Amir Masoud Gharehbaghi
Copyright © 1997 Altera Corporation & 提供 What is VHDL Very high speed integrated Hardware Description Language (VHDL) –is.
L16 – VHDL for State Machines with binary encoding.
2-Jun-16EE5141 Chapter 3 ä The concept of the signal ä Process concurrency ä Delta time ä Concurrent and sequential statements ä Process activation by.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
Introduction to VHDL Spring EENG 2920 Digital Systems Design Introduction VHDL – VHSIC (Very high speed integrated circuit) Hardware Description.
VHDL Very High Speed Integrated Circuit Hardware Description Language Shiraz University of shiraz spring 2011.
Hardware Description Languages Digital Logic Design Instructor: Kasım Sinan YILDIRIM.
Hardware languages "Programming"-language for modelling of (digital) hardware 1 Two main languages: VHDL (Very High Speed Integrated Circuit Hardware Description.
15-Dec-15EE5141 Chapter 4 Sequential Statements ä Variable assignment statement ä Signal assignment statement ä If statement ä Case statement ä Loop statement.
VHDL Discussion Finite State Machines
VHDL Discussion Finite State Machines IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
1 Part III: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
CEC 220 Digital Circuit Design VHDL in Sequential Logic Wednesday, March 25 CEC 220 Digital Circuit Design Slide 1 of 13.
VHDL for Sequential Logic
ENG241 Digital Design Week #7 Sequential Circuits (Part B)
Relational Operators Result is boolean: greater than (>) less than (=) less than or equal to (
VHDL 7: use of signals v.5a1 VHDL 7 Use of signals In processes and concurrent statements.
55:032 - Intro. to Digital DesignPage 1 VHDL and Processes Defining Sequential Circuit Behavior.
ECE DIGITAL LOGIC LECTURE 21: FINITE STATE MACHINE Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/24/2015.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
1/20/ L8 Language Overview III Copyright Joanne DeGroat, ECE, OSU1 Language Overview III The finish of a grand tour of the language.
CWRU EECS 318 EECS 318 CAD Computer Aided Design LECTURE 6: State machines Instructor: Francis G. Wolff Case Western Reserve University.
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
1 Introduction to Engineering Spring 2007 Lecture 19: Digital Tools 3.
State Machine Design with an HDL
Sequential statements (1) process
Combinational logic circuit
Introduction To VHDL 홍 원 의.
Basic Language Concepts
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL Code.
B e h a v i o r a l to R T L Coding
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
Sequential Design.
Using CAD Tools to implement Digital Circuits
The finish of a grand tour of the language.
VHDL 5 FINITE STATE MACHINES (FSM)
In processes and concurrent statements
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
VHDL Hierarchy in XILINX
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
Synthesis مرتضي صاحب الزماني.
The continuation of a grand tour of the language.
VHDL (VHSIC Hardware Description Language)
State Machine Design with an HDL
Behavioral Modeling of Sequential-Circuit Building Blocks
Figure 8.1. The general form of a sequential circuit.
Finite State Machines (part 1)
Lesson 3 Advanced Topics in VHDL
The continuation of a grand tour of the language.
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.
Finite state machines Modelling FSM in VHDL.
Sequntial-Circuit Building Blocks
The finish of a grand tour of the language.
System Controller Approach
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

Some VHDL Details 10/8/08 ECE - 561 Lecture 8

Lecture Overview Language Elements Examples of VHDL of FSMs The Entity The Architecture Types needed for FSM modeling Signal Declaration Sequential Statements – what goes inside process Examples of VHDL of FSMs 10/8/08 ECE - 561 Lecture 8

The Entity Will only use formal_port_clause entity_declaration::= entity identifier is entity_header entity_declarative_part [begin entity_statement_part] end [identifier]; entity_header::= [formal_generic_clause] [formal_port_clause] Will only use formal_port_clause Will not use entity_declarative_part Will never have entity_statement_parts 10/8/08 ECE - 561 Lecture 8

The Entity ENTITY your_descriptor IS PORT(x,y,z : IN BIT; o1,o2,o3 : OUT BIT; clk : IN BIT); END your_descriptor; Only need to have inputs, outputs, and the clock in the Entity when doing a FSM. 10/8/08 ECE - 561 Lecture 8

Signal types The input and output signals will typically be of the following types for FSM modeling BIT, or BIT_VECTOR STD_LOGIC or STD_LOGIC_VECTOR BIT and BIT_VECTOR signals have a value of ‘0’ or ‘1’ STDSTD_LOGIC or STD_LOGIC_VECTOR signals have a value of ‘U’, ‘L’, ‘0’, ‘W’, ‘X’, ‘H’, ‘1’, ‘Z’, ‘-’ 10/8/08 ECE - 561 Lecture 8

The Architecture The declarative part first architecture identifier of entity_name is architecture_declarative_part begin architecture_statement_part end [identifier]; The declarative part first architecture_declarative_part::= {architecture_declarative_item} 10/8/08 ECE - 561 Lecture 8

Architectural Declarative Items For FSM modeling will have two typical lines An Enumeration Type for specifying the states TYPE state_type IS (ST_1, ST_2, …., ST-n); A declaration of a signal of that type for the current and next state SIGNAL state, next_state : state_type; These could be initialized if desired. 10/8/08 ECE - 561 Lecture 8

Initialization when declard To initialize the initial value of state and next_state at declaration SIGNAL state,next_state: state_type :=ST_0; By default the initial value of an enumeration type is the leftmost value of the set of value for the type. So here it would be ST_0 10/8/08 ECE - 561 Lecture 8

So Far ARCHITECTURE one OF your_descriptor IS BEGIN TYPE state_type IS (INIT,L1,L2,L3,R1,R2,R3,LR3); SIGNAL state, next_state : state_type := INIT; BEGIN You may have a few other signals to connect up some internal signals. These are like wires on a circuit board. 10/8/08 ECE - 561 Lecture 8

The Process The VHDL PROCESS statement This is a sequential statement of the language The code within the process is executed sequentially – similar to C, C++, C# Each process is independent on the other processes and each executes concurrently 10/8/08 ECE - 561 Lecture 8

The PROCESS Statement The process label is optional. process [ (sensitivity_list) ] process_declarative_part begin process_statement_part -- {sequential statement} end process [process_label]; The process label is optional. The sensitivity list is very important for FSM modeling You will typically not have any declarations to make that have scope just over this process The process_statement_part is any sequential language structure 10/8/08 ECE - 561 Lecture 8

The sequential statements Sequential Statements are like the statements of any procedural programming language. They are executed sequentially according to the control flow of the code. Time introduced using special language statements. Only in the F/F process. 10/8/08 ECE - 561 Lecture 8

The F/F process Have seen a process for a simple D F/F with no preset or clear PROCESS BEGIN WAIT UNTIL clk=‘1’ and clk’event; state <= next_state; END PROCESS; This process is very good provided all you need is a F/F and no preset or clear But what if you need them? As is often the case. 10/8/08 ECE - 561 Lecture 8

A more robust D F/F A D F/F with preset and clear Both preset and clear are active low PROCESS (clk,preset,clear) BEGIN IF (preset = ‘1’) THEN state <= P_STATE; --or preset state ELSIF (clear = ‘1’) THEN state <= INIT; -- or state for clear ELSIF (clk = ‘1’ AND clk’event) THEN – was a rising edge state <= next_state; END PROCESS; F/F with asynchronous preset and clear. 10/8/08 ECE - 561 Lecture 8

Features of F/F Process Will set to the correct state for PRESET and/or CLEAR being asserted (active low signals) If PRESET and CLEAR are both asserted at the same time priority is to PRESET the F/F. Could be modified to CLEAR the F/F. Only changes state on the rising clock edge. For a falling edge it would be ELSIF (clk = ‘1’ AND clk’event) THEN 10/8/08 ECE - 561 Lecture 8

Sequential Language Structures IF STATEMENT if condition then sequence_of_statements {elsif condition then sequence_of_statements} [else sequence_of_statements] end if; IF a=‘1’ THEN y<=q; ELSIF b=‘1’ THEN y<=z AFTER 4 NS; ELSE y <= ‘0’; END IF; 10/8/08 ECE - 561 Lecture 8

Case Statement CASE STATEMENT case expression is when choices => sequence_of_statements; end case; CASE state IS WHEN “00” => state <= “01”; WHEN “01” => state <= “10”; WHEN others => state <= “11”; END CASE; 10/8/08 ECE - 561 Lecture 8

Signal Assignment Statements Used for assignment of state state <= next_state Also have binary logic Have X, Y, and Z as signal of TYPE BIT Z <= X or Y; Z <= X and Y; Z <= X nor Y; Z <= X nand Y; Z <= X xor Y; Z <= X xnor Y; X <= not Y; Can use ( ) ‘s for more complex binary logic equations 10/8/08 ECE - 561 Lecture 8

Language structures not typically used for FSMs More complex WAIT statements or WAIT statements on complex conditions Variables Procedure Calls Assertion Statements Loops Next and Exit statements RETURN statement which is used in procedures and functions Null statement 10/8/08 ECE - 561 Lecture 8

A complete view of the T-Bird FSM The I/O interface of the controller ENTITY tl_cntrlr IS PORT ( rts,lts, haz : IN BIT; clk : IN BIT; lc, lb, la : OUT BIT; rc, rb, ra : OUT BIT); END tl_cntrlr; 10/8/08 ECE - 561 Lecture 8

T-BIRD FSM Start the ARCHITECTURE ARCHITECTURE state_machine OF tl_cntrlr IS TYPE state_type IS (idle,l1,l2,l3,r1,r2,r3,lr3); SIGNAL state, next_state : state_type; BEGIN --specify F/F process PROCESS wait until clk=‘1’ AND clk’event; state <= next_state; END PROCESS; 10/8/08 ECE - 561 Lecture 8

The Next State Process PROCESS (state, lts, rts, haz) BEGIN CASE state IS WHEN idle => IF (haz=‘1’ OR (lts=‘1’ AND rts=‘1’)) THEN next_state <= lr3; ELSIF (haz=‘0’ OR (lts=‘0’ AND rts=‘1’)) THEN next_state <= r1; ELSIF (haz=‘0’ OR (lts=‘1’ AND rts=‘0’)) THEN next_state <= l1; ELSE next_state <= idle; END IF; 10/8/08 ECE - 561 Lecture 8

Next State Proces Continued WHEN l1 => IF (haz = ‘1’) then next_state <= lr3; ELSE next_state <= l2; END IF; WHEN l2 => ELSE next_state <= l3; WHEN l3 => next_state <= idle; 10/8/08 ECE - 561 Lecture 8

Next State Proces Continued WHEN r1 => IF (haz = ‘1’) then next_state <= lr3; ELSE next_state <= r2; END IF; WHEN r2 => ELSE next_state <= r3; WHEN r3 => next_state <= idle; WHEN lr3 => next_state <= idle; END CASE; END PROCESS; 10/8/08 ECE - 561 Lecture 8

The Output Process -- State Machine Output Process (Moore Machine) BEGIN CASE (state) IS WHEN idle => lc<=‘0’;lb<=‘0’; la<=‘0’; ra<=‘0’; rb<=‘0’; rc<=‘0’; WHEN l1 => lc<=‘0’;lb<=‘0’; la<=‘1’; ra<=‘0’; rb<=‘0’; rc<=‘0’; WHEN l2 =>lc<=‘0’;lb<=‘1’; la<=‘1’; ra<=‘0’; rb<=‘0’; rc<=‘0’; WHEN l3 => lc<=‘1’;lb<=‘1’; la<=‘1’; ra<=‘0’; rb<=‘0’; rc<=‘0’; WHEN r1 => lc<=‘0’;lb<=‘0’; la<=‘0’; ra<=‘1’; rb<=‘0’; rc<=‘0’; WHEN r2 => lc<=‘0’;lb<=‘0’; la<=‘0’; ra<=‘1’; rb<=‘1’; rc<=‘0’; WHEN r3 => lc<=‘0’;lb<=‘0’; la<=‘0’; ra<=‘1’; rb<=‘1’; rc<=‘1’; WHEN lr3 => lc<=‘1’;lb<=‘1’; la<=‘1’; ra<=‘1’; rb<=‘1’; rc<=‘1’; END CASE; END PROCESS; END state_machine; 10/8/08 ECE - 561 Lecture 8

From a state Table Had a state table 10/8/08 ECE - 561 Lecture 8

The VHDL Entity Start with the inputs and outputs ENTITY ex_1_fsm IS PORT ( x,y : IN BIT; clk : IN BIT; fsm_out : OUT BIT); END ex_1_fsm; 10/8/08 ECE - 561 Lecture 8

The ARCHITECTURE ARCHITECTURE fsm OF ex_1_fsm IS TYPE state_type IS (s0,s1,s2,s3); SIGNAL state, next_state : state_type; BEGIN -- the F/F Process PROCESS wait until clk=‘1’ AND clk’event; state <= next_state; END PROCESS; 10/8/08 ECE - 561 Lecture 8

The Next State Process PROCESS (state,x,y) BEGIN CASE state IS WHEN s0 => IF (x=‘1’ AND y=‘1’) THEN next_state <= s2; ELSIF (x /= y) THEN next_state <= s1; END IF; WHEN s1 => IF (x=‘1’ AND y=‘1’) THEN next_state <= s3; ELSIF (x /= y) THEN next_state <= s2; WHEN s2 => IF (x=‘1’ AND y=‘1’) THEN next_state <= s0; ELSIF (x /= y) THEN next_state <= s3; WHEN s4 => IF (x=‘1’ AND y=‘1’) THEN next_state <= s1; ELSIF (x /= y) THEN next_state <= s0; END CASE; END PROCESS; 10/8/08 ECE - 561 Lecture 8

The Output Process PROCESS (state) BEGIN CASE state IS WHEN s0 => fms_out <= ‘1’; WHEN s1 => fms_out <= ‘0’; WHEN s2 => fms_out <= ‘0’; WHEN s4 => fms_out <= ‘0’; END CASE; END PROCESS; END fsm; -- end the architecture 10/8/08 ECE - 561 Lecture 8

Another Example Had this state table 10/8/08 ECE - 561 Lecture 8

The Entity Start with the inputs and outputs ENTITY ex2fsm IS PORT ( x : IN BIT; clk : IN BIT; unlk,hint : OUT BIT); END ex2fsm; 10/8/08 ECE - 561 Lecture 8

The Architecture ARCHITECTURE fsm OF ex2fsm IS TYPE state_type IS (A,B,C,D,E,F,G,H); SIGNAL state, next_state : state_type; BEGIN -- the F/F Process PROCESS wait until clk=‘1’ AND clk’event; state <= next_state; END PROCESS; 10/8/08 ECE - 561 Lecture 8

The Next State Process PROCESS (state,x) BEGIN CASE state IS WHEN A => IF (x=‘0’) THEN next_state <= B; --have 0 ELSE next_state <= A; END IF; WHEN B => IF (x=‘0’) THEN next_state <= B; ELSE next_state <= C; END IF; WHEN C => IF (x=‘0’) THEN next_state <= B; ELSE next_state <= D; END IF; WHEN D => IF (x=‘0’) THEN next_state <= E; ELSE next_state <= A; END IF; WHEN E => IF (x=‘0’) THEN next_state <= B; ELSE next_state <= F; END IF; WHEN F => IF (x=‘0’) THEN next_state <= B; ELSE next_state <= G; END IF; WHEN G => IF (x=‘0’) THEN next_state <= E; ELSE next_state <= H; END IF; WHEN H => IF (x=‘0’) THEN next_state <= B; ELSE next_state <= A; END IF; END CASE; END PROCESS 10/8/08 ECE - 561 Lecture 8

The Output Process PROCESS (state,x) BEGIN CASE state IS WHEN A => unlk <= ‘0’; IF (x=‘0’) THEN hint <= ‘1’; ELSE hint <= ‘0’; END IF; WHEN B => unlk <= ‘0’; IF (x=‘1’) THEN hint <= ‘1’; WHEN C => unlk <= ‘0’; IF (x=‘1’) THEN hint <= ‘1’; WHEN D => unlk <= ‘0’; IF (x=‘0’) THEN hint <= ‘1’; WHEN E => unlk <= ‘0’; IF (x=‘1’) THEN hint <= ‘1’; WHEN F => unlk <= ‘0’; IF (x=‘1’) THEN hint <= ‘1’; WHEN G => unlk <= ‘0’; IF (x=‘1’) THEN hint <= ‘1’; WHEN H => IF(x=‘0”) THEN unlk <= ‘1’; hint = ‘1’; ELSE unlk=‘0’; hint=‘0’; END IF; END CASE; END PROCESS; END fsm; -- end the architecture 10/8/08 ECE - 561 Lecture 8

10/8/08 ECE - 561 Lecture 8

10/8/08 ECE - 561 Lecture 8

10/8/08 ECE - 561 Lecture 8

10/8/08 ECE - 561 Lecture 8

10/8/08 ECE - 561 Lecture 8