Laboratory Exercise 7

Similar documents
California State University, Bakersfield Computer & Electrical Engineering & Computer Science ECE 3220: Digital Design with VHDL Laboratory 7

Laboratory Exercise 7

CSCB58 - Lab 4. Prelab /3 Part I (in-lab) /1 Part II (in-lab) /1 Part III (in-lab) /2 TOTAL /8

HDL & High Level Synthesize (EEET 2035) Laboratory II Sequential Circuits with VHDL: DFF, Counter, TFF and Timer

Ryerson University Department of Electrical and Computer Engineering EES508 Digital Systems

Laboratory Exercise 3

Chapter 5 Synchronous Sequential Logic

Ryerson University Department of Electrical and Computer Engineering COE/BME 328 Digital Systems

Debugging of VHDL Hardware Designs on Altera s DE2 Boards

Laboratory Exercise 6

Experiment # 12. Traffic Light Controller

ASYNCHRONOUS COUNTER CIRCUITS

EECS150 - Digital Design Lecture 19 - Finite State Machines Revisited

Laboratory 4. Figure 1: Serdes Transceiver

Lecture 11: Synchronous Sequential Logic

Debugging of Verilog Hardware Designs on Altera s DE-Series Boards. 1 Introduction. For Quartus Prime 15.1

Flip-flop and Registers

Eng. Mohammed Samara. Fall The Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department

Electrical and Telecommunications Engineering Technology_TCET3122/TC520. NEW YORK CITY COLLEGE OF TECHNOLOGY The City University of New York

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

Lab #10 Hexadecimal-to-Seven-Segment Decoder, 4-bit Adder-Subtractor and Shift Register. Fall 2017

Elwin Cabrera May 11, 2016 DIGITAL CLOCK. ECE271/CSC222 Final Project Report

Microprocessor Design

Lab 13: FPGA Circuit Realization Ian Callahan

Asynchronous (Ripple) Counters

Feedback Sequential Circuits

Altera s Max+plus II Tutorial

Digital Systems Laboratory 3 Counters & Registers Time 4 hours

Lecture 8: Sequential Logic

Chapter 4: One-Shots, Counters, and Clocks

Digital Electronics II 2016 Imperial College London Page 1 of 8

ECT 224: Digital Computer Fundamentals Digital Circuit Simulation & Timing Analysis

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

FPGA TechNote: Asynchronous signals and Metastability

problem maximum score 1 28pts 2 10pts 3 10pts 4 15pts 5 14pts 6 12pts 7 11pts total 100pts

Digital Fundamentals: A Systems Approach

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Introductory Digital Systems Laboratory

Timing Pulses. Important element of laboratory electronics. Pulses can control logical sequences with precise timing.

STATIC RANDOM-ACCESS MEMORY

Laboratory 1 - Introduction to Digital Electronics and Lab Equipment (Logic Analyzers, Digital Oscilloscope, and FPGA-based Labkit)

Figure 1 Block diagram of a 4-bit binary counter

Faculty of Electrical & Electronics Engineering BEE3233 Electronics System Design. Laboratory 3: Finite State Machine (FSM)

2 Sequential Circuits

CSC258: Computer Organization. Combinational Logic

CHAPTER 6 DESIGN OF HIGH SPEED COUNTER USING PIPELINING

Flip-Flops and Sequential Circuit Design

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Introductory Digital Systems Laboratory

Step 1 - shaft decoder to generate clockwise/anticlockwise signals

Task 4_B. Decoder for DCF-77 Radio Clock Receiver

EET 1131 Lab #10 Latches and Flip-Flops

Laboratory Exercise 4

Section 6.8 Synthesis of Sequential Logic Page 1 of 8

2.6 Reset Design Strategy

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

Side Street. Traffic Sensor. Main Street. Walk Button. Traffic Lights

Counter dan Register

Digital Systems Laboratory 1 IE5 / WS 2001

VeriLab. An introductory lab for using Verilog in digital design (first draft) VeriLab

EECS150 - Digital Design Lecture 15 Finite State Machines. Announcements

Computer Systems Architecture

Synchronous Sequential Logic

ELCT201: DIGITAL LOGIC DESIGN

Sequential Circuits. Output depends only and immediately on the inputs Have no memory (dependence on past values of the inputs)

ECE 270 Lab Verification / Evaluation Form. Experiment 9

Modeling Latches and Flip-flops

Chapter 5: Synchronous Sequential Logic

DIGITAL SYSTEM FUNDAMENTALS (ECE421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE422) LATCHES and FLIP-FLOPS

Final Exam review: chapter 4 and 5. Supplement 3 and 4

CSE115: Digital Design Lecture 23: Latches & Flip-Flops

ECSE-323 Digital System Design. Datapath/Controller Lecture #1

CHAPTER 4: Logic Circuits

Solar Power for Small Hall

You will be first asked to demonstrate regular operation with default values. You will be asked to reprogram your time values and continue operation

CprE 281: Digital Logic

Vending Machine. Keywords FSM, Vending Machine, FPGA, VHDL

Design and Simulation of a Digital CMOS Synchronous 4-bit Up-Counter with Set and Reset

COMPUTER ENGINEERING PROGRAM

Administrative issues. Sequential logic

Design of a Binary Number Lock (using schematic entry method) 1. Synopsis: 2. Description of the Circuit:

YEDITEPE UNIVERSITY DEPARTMENT OF COMPUTER ENGINEERING. EXPERIMENT VIII: FLIP-FLOPS, COUNTERS 2014 Fall

Logic Design Viva Question Bank Compiled By Channveer Patil

IE1204 Digital Design F11: Programmable Logic, VHDL for Sequential Circuits

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science. EECS 150 Spring 2000

ECE 301 Digital Electronics

Chapter. Synchronous Sequential Circuits

LATCHES & FLIP-FLOP. Chapter 7

University of Pennsylvania Department of Electrical and Systems Engineering. Digital Design Laboratory. Lab8 Calculator

10.1 Sequential logic circuits are a type of logic circuit where the output of the circuit depends not only on

DALHOUSIE UNIVERSITY Department of Electrical & Computer Engineering Digital Circuits - ECED 220. Experiment 4 - Latches and Flip-Flops

CSE 352 Laboratory Assignment 3

The basic logic gates are the inverter (or NOT gate), the AND gate, the OR gate and the exclusive-or gate (XOR). If you put an inverter in front of

Digital Circuit And Logic Design I. Lecture 8

Digital Circuit And Logic Design I

Outputs Combinational circuit. Next state. Fig. 4-1 Block Diagram of a Sequential Circuit

Sequential Digital Design. Laboratory Manual. Experiment #7. Counters

CHAPTER 4: Logic Circuits

Chapter 7 Counters and Registers

Main Design Project. The Counter. Introduction. Macros. Procedure

Digital Design, Kyung Hee Univ. Chapter 5. Synchronous Sequential Logic

Universal Asynchronous Receiver- Transmitter (UART)

Transcription:

Laboratory Exercise 7 Finite State Machines This is an exercise in using finite state machines. Part I We wish to implement a finite state machine (FSM) that recognizes two specific sequences of applied input symbols, namely four consecutive s or four consecutive s. There is an input w and an output z. Whenever w = or w = for four consecutive clock pulses the value of z has to be ; otherwise, z =. Overlapping sequences are allowed, so that if w = for five consecutive clock pulses the output z will be equal to after the fourth and fifth pulses. Figure illustrates the required relationship between w and z. Clock w z Figure : Required timing for the output z. A state diagram for this FSM is shown in Figure 2. For this part you are to manually derive an FSM circuit that implements this state diagram, including the logic expressions that feed each of the state flip-flops. To implement the FSM use nine state flip-flops called y 8,..., y and the one-hot state assignment given in Table.

Reset B/ w = A/ w = F/ w = C/ G/ w = D/ H/ w = E/ I/ Figure 2: A state diagram for the FSM. State Code Name y 8 y 7 y 6 y 5 y 4 y 3 y 2 y y A B C D E F G H I Table : One-hot codes for the FSM. Design and implement your circuit on your DE-series board as follows:. Create a new Quartus II project for the FSM circuit. 2. Write a VHDL file that instantiates the nine flip-flops in the circuit and which specifies the logic expressions that drive the flip-flop input ports. Use only simple assignment statements in your VHDL code to specify the logic feeding the flip-flops. Note that the one-hot code enables you to derive these expressions by inspection. Use the toggle switch SW as an active-low synchronous reset input for the FSM, use SW as the w input, and the pushbutton KEY as the clock input which is applied manually. Use the red light LEDR 9 as the output z, and assign the state flip-flop outputs to the red lights LEDR 8 to LEDR. 3. Include the VHDL file in your project, and assign the pins on the FPGA to connect to the switches and the LEDs. 2

4. Simulate the behavior of your circuit. 5. Once you are confident that the circuit works properly as a result of your simulation, download the circuit into the FPGA chip. Test the functionality of your design by applying the input sequences and observing the output LEDs. Make sure that the FSM properly transitions between states as displayed on the red LEDs, and that it produces the correct output values on LEDR 9. 6. Finally, consider a modification of the one-hot code given in Table. It is often desirable to set all flip-flop outputs to the value in the reset state. Table 2 shows a modified one-hot state assignment in which the reset state, A, uses all s. This is accomplished by inverting the state variable y. Create a modified version of your VHDL code that implements this state assignment. (Hint: you should need to make very few changes to the logic expressions in your circuit to implement the modified state assignment.) 7. Compile your new circuit and test it. State Code Name y 8 y 7 y 6 y 5 y 4 y 3 y 2 y y A B C D E F G H I Table 2: Modified one-hot codes for the FSM. Part II For this part you are to write another style of Verilog code for the FSM in Figure 2. In this version of the code you should not manually derive the logic expressions needed for each state flip-flop. Instead, describe the state table for the FSM by using a VHDL CASE statement in a PROCESS block, and use another PROCESS block to instantiate the state flip-flops. You can use a third PROCESS block or simple assignment statements to specify the output z. To implement the FSM, use four state flip-flops y 3,..., y and binary codes, as shown in Table 3. State Code Name y 3 y 2 y y A B C D E F G H I Table 3: Binary codes for the FSM. 3

A suggested skeleton of the VHDL code is given in Figure 3. LIBRARY ieee; USE ieee.std_logic_64.all; ENTITY part2 IS PORT (... define input and output ports...); END part2; ARCHITECTURE Behavior OF part2 IS... declare signals TYPE State_type IS (A, B, C, D, E, F, G, H, I); Attribute to declare a specific encoding for the states attribute syn_encoding : string; attribute syn_encoding of State_type : type is " "; SIGNAL y_q, Y_D : State_type; - - y_q is present state, y_d is next state BEGIN... PROCESS (w, y_q) - - state table BEGIN case y_q IS WHEN A IF (w = ) THEN Y_D <= B; ELSE Y_D <= F; END IF;... other states END CASE; END PROCESS; - - state table PROCESS (Clock) - - state flip-flops BEGIN... END PROCESS;... assignments for output z and the LEDs END Behavior; Figure 3: Skeleton VHDL code for the FSM. Implement your circuit as follows.. Create a new project for the FSM. 2. Include in the project your VHDL file that uses the style of code in Figure 3. Use the same switches, pushbuttons, and lights that were used in Part I. 3. Before compiling your code it is necessary to explicitly tell the Synthesis tool in Quartus II that you wish to have the finite state machine implemented using the state assignment specified in your VHDL code. If you do not explicitly give this setting to Quartus II, the Synthesis tool will automatically use a state assignment of its own choosing, and it will ignore the state codes specified in your VHDL code. To make this setting, choose Assignments > Settings in Quartus II, and click on the Analysis and Synthesis item on the left 4

side of the window, then click on the More Setting button. As indicated in Figure 4, change the parameter State Machine Processing to the setting User-Encoded. 4. Compile your project. To examine the circuit produced by Quartus II open the RTL Viewer tool. Doubleclick on the box shown in the circuit that represents the finite state machine, and determine whether the state diagram that it shows properly corresponds to the one in Figure 2. To see the state codes used for your FSM, open the Compilation Report, select the Analysis and Synthesis section of the report, and click on State Machines. 5. Download the circuit into the FPGA chip and test its functionality. 6. In step 3 you instructed the Quartus II Synthesis tool to use the state assignment given in your VHDL code. To see the result of removing this setting, open again the Quartus II settings window by choosing Assignments > Settings, and click on the Analysis and Synthesis item, then click on the More Setting button. Change the setting for State Machine Processing from User-Encoded to One-Hot. Recompile the circuit and then open the report file, select the Analysis and Synthesis section of the report, and click on State Machines. Compare the state codes shown to those given in Table 2, and discuss any differences that you observe. Figure 4: Specifying the state assignment method in Quartus II. Part III The sequence detector can be implemented in a straightforward manner using shift registers, instead of using the more formal approach described above. Create VHDL code that instantiates two 4-bit shift registers; one is for recognizing a sequence of four s, and the other for four s. Include the appropriate logic expressions in your design to produce the output z. Make a Quartus II project for your design and implement the circuit on your DEseries board. Use the switches and LEDs on the board in a similar way as you did for Parts I and II and observe the behavior of your shift registers and the output z. Answer the following question: could you use just one 4-bit shift register, rather than two? Explain your answer. 5

Part IV In this part of the exercise you are to implement a Morse-code encoder using an FSM. The Morse code uses patterns of short and long pulses to represent a message. Each letter is represented as a sequence of dots (a short pulse), and dashes (a long pulse). For example, the first eight letters of the alphabet have the following representation: A B C D E F G H Design and implement a Morse-code encoder circuit using an FSM. Your circuit should take as input one of the first eight letters of the alphabet and display the Morse code for it on a red LED. Use switches SW 2 and pushbuttons KEY as inputs. When a user presses KEY, the circuit should display the Morse code for a letter specified by SW 2 ( for A, for B, etc.), using.5-second pulses to represent dots, and.5-second pulses to represent dashes. Pushbutton KEY should function as an asynchronous reset. A high-level schematic diagram of a possible circuit for the Morse-code encoder is shown in Figure 5. Pushbuttons and switches Morse code length counter Data Enable Load Letter selection logic Morse code shift register FSM LEDR Data Enable Load Half-second counter Figure 5: High-level schematic diagram of the circuit for Part IV. Copyright c 25 Altera Corporation. 6