LAB 9 Finite State Machine (FSM) Ui Luu Glendale Community College Bassam Matar Chandler-Gilbert Community College.

Slides:



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

Digital Alarm System Experiment 9. Experiment 8: What You May Have Missed Continued use of structural modelingContinued use of structural modeling VHDL.
1 VLSI DESIGN USING VHDL Part II A workshop by Dr. Junaid Ahmed Zubairi.
Ring Counter Discussion D5.3 Example 32. Ring Counter if rising_edge(CLK) then for i in 0 to 2 loop s(i)
Top-level VHDL Designs
A Simple Microcontroller VHDL Tutorial R. E. Haskell and D. M. Hanna T6: VHDL State Machines.
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.
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.
Dr. Turki F. Al-Somani VHDL synthesis and simulation – Part 3 Microcomputer Systems Design (Embedded Systems)
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.
Lab 3 & 4 Discussion EE414/514 VHDL Design September 25.
7-Segment Displays VHDL Tutorial R. E. Haskell and D. M. Hanna T4: Xilinx LogiBLOX.
ECE 448: Spring 12 Lab 4 – Part 2 Finite State Machines Basys2 FPGA Board.
Capacitance Sensor Project
Lecture #5 In this lecture we will introduce the sequential circuits.
1 Part V: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
Copyright (c) 2003 by Valery Sklyarov and Iouliia Skliarova: DETUA, IEETA, Aveiro University, Portugal.
1 Copyright (c) 2003 by Valery Sklyarov and Iouliia Skliarova: DETUA, IEETA, Aveiro University, Portugal.
VHDL Introduction. V- VHSIC Very High Speed Integrated Circuit H- Hardware D- Description L- Language.
George Mason University ECE 545 – Introduction to VHDL ECE 545 Lecture 5 Finite State Machines.
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
Combinational Building Blocks: Encoders and Decoders Experiment 6.
ECE 448: Spring 11 Lab 3 Part 1 Sequential Logic for Synthesis.
ENG2410 Digital Design LAB #5 Modular Design and Hierarchy using VHDL.
displayCtrlr Specification
CascadedBCDCntr&Display Aim : Capture, simulate and implement a 2-digit, loadable BCD up/down counter, with chip enable I/P (CE) and chip enable O/P (CEO).
Lab 4 Report Comments: Procedure Ordering in lab reportProcedure Ordering in lab report report should follow logical flow of what you did in experiment:
ECE 448: Spring 11 Lab 3 Part 2 Finite State Machines.
Reaction Timer Project
Finite State Machine (FSM) Nattha Jindapetch December 2008.
VHDL Discussion Finite State Machines
VHDL Discussion Finite State Machines IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
Copyright (c) 2003 by Valery Sklyarov and Iouliia Skliarova: DETUA, IEETA, Aveiro University, Portugal.
 Seattle Pacific University EE Logic System DesignCounters-1 Shift Registers DQ clk DQ DQ ShiftIn Q3Q3 Q2Q2 DQ Q1Q1 Q0Q0 A shift register shifts.
CS/EE 3700 : Fundamentals of Digital System Design
CEC 220 Digital Circuit Design VHDL in Sequential Logic Wednesday, March 25 CEC 220 Digital Circuit Design Slide 1 of 13.
Teaching Digital Logic courses with Altera Technology
Slide 1 3.VHDL/Verilog Description Elements. Slide 2 To create a digital component, we start with…? The component’s interface signals Defined in MODULE.
ECE DIGITAL LOGIC LECTURE 20: REGISTERS AND COUNTERS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/19/2015.
55:032 - Intro. to Digital DesignPage 1 VHDL and Processes Defining Sequential Circuit Behavior.
ECE 3450 M. A. Jupina, VU, 2016 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
Registers and Counters Discussion D8.1. Logic Design Fundamentals - 3 Registers Counters Shift Registers.
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
LAB #5 Modular Design and Hierarchy using VHDL
Sequential statements (1) process
Finite State Machines (part 1)
Lecture L5.1 Mealy and Moore Machines
LAB #4 Xilinix ISE Foundation Tools VHDL Design Entry “A Tutorial”
Describing Combinational Logic Using Processes
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
Part IV: VHDL CODING.
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
VHDL (VHSIC Hardware Description Language)
Fibonacci Sequence Lecture L4.1 Lab 3.
Lecture #5 In this lecture we will introduce the sequential circuits.
Behavioral Modeling of Sequential-Circuit Building Blocks
Figure 8.1. The general form of a sequential circuit.
Finite State Machines (part 1)
The Verilog Hardware Description Language
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Sequntial-Circuit Building Blocks
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
(Sequential-Circuit Building Blocks)
Presentation transcript:

LAB 9 Finite State Machine (FSM) Ui Luu Glendale Community College Bassam Matar Chandler-Gilbert Community College

Learning Objectives  Create a top-level HDL structure  Write VHDL code to describe a Finite State Machine  Apply VHDL codes previously developed in workshop #1 (source codes are provided in this lab template): ( TIMER_DISPLAY.vhd, MEM16.vhd, SECURITY.ucf module) for timer display  Implement INDICATORS.vhd (to provide visual feedback for NEXYS2 on board switches & buttons)  Verify system operations using NEXYS2 evaluation board

Security Monitor System I/O

Security System State Diagram

Nexys2 Hardware

TIMER_DISPLAY Module TIMER_DISPLAY module objectives : Provides 1 second CLK_DIV signal to Finite State Machine Provides control signals to display timer using NEXYS2 onboard 7-segment LED display

CLK_DIV signal Functional Requirement: Provides 1 second CLK_DIV signal to Finite State Machine Code Implementation: process (CLK,REG) begin if rising_edge(CLK) then REG <= REG + 1; CLK_DIV_INT<='0'; end if; if REG = X"2FAF080" then -- For 1 Hz use X"2FAF080" = 50,000,000 (Decimal) MHz / 50,000,000 = 1 Hz CLK_DIV_INT<='1'; REG<=X" "; end if; end process;

TIMER_DISPLAY Functional Description When RUN_TIMER (from FSM) = 1:  Timer counts up at 1 second rate  Display the timer count at 7-Segment LED When RUN_TIMER = 0:  Timer resets to 0

TIMER_DISPLAY Implementation (Note: This implementation was covered in Workshop May,2011) process (CLK,CLK_DIV_INT,RUN_TIMER) begin if RUN_TIMER = '0' then Q_INT '0'); elsif rising_edge(CLK) then if (CLK_DIV_INT='1') then -- Note: CLK_DIV_INT provides 1-second clock Q_INT <= Q_INT + '1'; end if; end process; -- Outputs: ADDR(3 downto 0) <= Q_INT (3 downto 0); ANODE_CONTROL <= "1110"; -- Enable 1st digit only, active Low CLK_DIV <=CLK_DIV_INT;

Review NEXYS2 I/O Device (Ref. Nexys2_m.pdf)

MEM16.vhd entity MEM16 is Port ( ADDR : in STD_LOGIC_VECTOR (3 downto 0); DATA : out STD_LOGIC_VECTOR (7 downto 0)); end MEM16; architecture Behavioral of MEM16 is type ROM_ARRAY is array (0 to 15) of std_logic_vector(7 downto 0); constant MY_ROM :ROM_ARRAY :=( -- Cathode Control for 7-SEGMENT LED Digit (0-F): 0 => X"03", --0 note: Cathode control is active Low 1 => X"9F", => X"25", => X"0D", => X"99", => X"49", => X"41", => X"1F", => X"01", => X"09", => X"11", --A 11 => X"C1", --B 12 => X"63", --C 13 => X"85", --D 14 => X"61", --E 15 => X"71" --F ); begin DATA <= MY_ROM(conv_integer(ADDR)); end Behavioral;

FSM / IO port assignments (Reference: System Block Diagram) entity FSM is Port ( CLK : in STD_LOGIC; CLK_DIV:in STD_LOGIC; ARM : in STD_LOGIC; FRONT_DOOR : in STD_LOGIC; REAR_DOOR : in STD_LOGIC; WINDOW : in STD_LOGIC; RUN_TIMER:out STD_LOGIC; SIREN : out STD_LOGIC); end FSM;

Type & Signal names Declarations type SECURITY_STATE is (ARMED,DISARMED,WAIT_DELAY, ALARM); signal CURR_STATE,NEXT_STATE: SECURITY_STATE; signal START_COUNT,COUNT_DONE: std_logic; signal SENSORS:std_logic_vector (2 downto 0); --combine inputs signal TIMER_CNTR: std_logic_vector (2 downto 0) := (others => '0');

FSM / Reading Sensors & SYNC Process SENSORS <= FRONT_DOOR & REAR_DOOR & WINDOW; SYNC: process (CLK,ARM) begin if ARM = '0' then CURR_STATE <= DISARMED; elsif rising_edge (CLK) then CURR_STATE <= NEXT_STATE; end if; end process SYNC;

Implement Security System State Diagram (Figure 2) STATE_MACHINE: process (CURR_STATE,SENSORS,ARM,COUNT_DONE) begin START_COUNT <= '0'; -- establish default case (CURR_STATE) is when DISARMED => if ARM = '1' then NEXT_STATE <= ARMED; else NEXT_STATE <= DISARMED; end if; -- Output: SIREN <= '0'; RUN_TIMER <= '0'; when ARMED => if (SENSORS /= "000") then NEXT_STATE <= WAIT_DELAY; else NEXT_STATE <= ARMED; end if; -- Output: SIREN <= '0'; RUN_TIMER <= '0'; when WAIT_DELAY => START_COUNT <= '1'; if (COUNT_DONE = '1') then NEXT_STATE <= ALARM; elsif (ARM ='0') then NEXT_STATE <= DISARMED; else NEXT_STATE <= WAIT_DELAY; end if; -- Output: SIREN <= '0'; RUN_TIMER <= '1'; when ALARM => if (ARM = '0') then NEXT_STATE <= DISARMED; else NEXT_STATE <= ALARM; end if; -- Output: SIREN <= '1'; RUN_TIMER <= '0'; end case; end process STATE_MACHINE;

DELAY_TIMER Process DELAY_TIMER: process(CLK_DIV,CURR_STATE,START_COUNT,TIMER_CNTR) begin COUNT_DONE <= '0'; -- default value if (rising_edge (CLK_DIV) and (START_COUNT = '1')) then TIMER_CNTR <= TIMER_CNTR + 1; end if; -- *** Note: START_COUNT is set to 1 by the STATE_MACHINE when CURR_STATE = WAIT_DELAY if (CURR_STATE/=WAIT_DELAY) then -- Note: /= means NOT equal to TIMER_CNTR <= "000"; end if; if (TIMER_CNTR = "111") then-- Note: this timer times out at 7 seconds just for convenience COUNT_DONE <= '1'; end if; end process DELAY_TIMER;

INDICATORS.vhd (provides visual feedback for NEXYS2 on board switches & buttons) entity INDICATORS is Port ( ARM : in STD_LOGIC; FRONT_DOOR : in STD_LOGIC; REAR_DOOR : in STD_LOGIC; WINDOW : in STD_LOGIC; ARM_SIG : out STD_LOGIC; FRONT_DOOR_SIG : out STD_LOGIC; REAR_DOOR_SIG : out STD_LOGIC; WINDOW_SIG : out STD_LOGIC); end INDICATORS; architecture Behavioral of INDICATORS is begin ARM_SIG<=ARM; FRONT_DOOR_SIG <= FRONT_DOOR; REAR_DOOR_SIG <= REAR_DOOR; WINDOW_SIG <= WINDOW; end Behavioral;

SECURITY.ucf (I/O assignments for NEXYS2-1200) # SECURITY.ucf # 7/6/2011: Operation verified with NEXYS NET "CLK" LOC = B8; NET "ARM" LOC = G18; # Switch 0 NET "FRONT_DOOR" LOC = H13; # Button 3 NET "REAR_DOOR" LOC = E18; # Button 2 NET "WINDOW" LOC = D18; # Button 1 NET "ARM_IND" LOC = J14; #LED 0 NET "FRONT_DOOR_IND" LOC = K14; #LED3 NET "REAR_DOOR_IND" LOC = K15; #LED2 NET "WINDOW_IND" LOC = J15; #LED1 NET "CATHODE[0]" LOC = C17; #DP NET "CATHODE[1]" LOC = H14; #CG NET "CATHODE[2]" LOC = J17; #CF NET "CATHODE[3]" LOC = G14; #CE NET "CATHODE[4]" LOC = D16; #CD NET "CATHODE[5]" LOC = D17; #CC NET "CATHODE[6]" LOC = F18; #CB NET "CATHODE[7]" LOC = L18; #CA NET "ANODE_CONTROL[0]" LOC = F17; NET "ANODE_CONTROL[1]" LOC = H17; NET "ANODE_CONTROL[2]" LOC = C18; NET "ANODE_CONTROL[3]" LOC = F15; NET "SIREN" LOC = P4; #LED7 P4 for NEXYS (R4 for NEXYS2-500 series)

Hands On Practice (Work in Team of 2) Down Load / Copy “VHDL-SecurityStateMachine-Starter(NEXYS2-1200)” project folder to your desktop Follow Lab 9 Finite State Machine (FSM) Instructions Verify the Security State Machine operates as prescribed Demonstrate to your lab coordinator

Sample Solution For reference, Sample solution is available at project Folder “VHDL-SecurityStateMachine-SampleSolution(NEXYS2-1200)”