Finite State Machine Design A Vending Machine



Similar documents
No serious hazards are involved in this laboratory experiment, but be careful to connect the components with the proper polarity to avoid damage.

VENDING MACHINE. ECE261 Project Proposal Presentaion. Members: ZHANG,Yulin CHEN, Zhe ZHANG,Yanni ZHANG,Yayuan

Multiplexers Two Types + Verilog

Lab 1: Full Adder 0.0

EXPERIMENT 8. Flip-Flops and Sequential Circuits

Modeling Registers and Counters

ECE232: Hardware Organization and Design. Part 3: Verilog Tutorial. Basic Verilog

Design and Implementation of Vending Machine using Verilog HDL

CHAPTER 11: Flip Flops

Modeling Latches and Flip-flops

Sequential Logic: Clocks, Registers, etc.

The 104 Duke_ACC Machine

Lecture 8: Synchronous Digital Systems

A Verilog HDL Test Bench Primer Application Note

Counters and Decoders

Lab 17: Building a 4-Digit 7-Segment LED Decoder

Decimal Number (base 10) Binary Number (base 2)

A New Paradigm for Synchronous State Machine Design in Verilog

LAB4: Audio Synthesizer

Aims and Objectives. E 3.05 Digital System Design. Course Syllabus. Course Syllabus (1) Programmable Logic

Lab 1: Introduction to Xilinx ISE Tutorial

IE1204 Digital Design F12: Asynchronous Sequential Circuits (Part 1)

Final Project: Enhanced Music Synthesizer and Display Introduction

A First Course in Digital Design Using VHDL and Programmable Logic

ECE410 Design Project Spring 2008 Design and Characterization of a CMOS 8-bit Microprocessor Data Path

Upon completion of unit 1.1, students will be able to

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995

Module 3: Floyd, Digital Fundamental

Gray Code Generator and Decoder by Carsten Kristiansen Napier University. November 2004

ASYNCHRONOUS COUNTERS

Digital Electronics Detailed Outline

A low-cost, connection aware, load-balancing solution for distributing Gigabit Ethernet traffic between two intrusion detection systems

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

Design Example: Counters. Design Example: Counters. 3-Bit Binary Counter. 3-Bit Binary Counter. Other useful counters:

PLL frequency synthesizer

INTRODUCTION TO DIGITAL SYSTEMS. IMPLEMENTATION: MODULES (ICs) AND NETWORKS IMPLEMENTATION OF ALGORITHMS IN HARDWARE

EXPERIMENT 4. Parallel Adders, Subtractors, and Complementors

Xilinx ISE. <Release Version: 10.1i> Tutorial. Department of Electrical and Computer Engineering State University of New York New Paltz

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

ELEC EXPERIMENT 1 Basic Digital Logic Circuits

HOST Embedded System. SLAVE EasyMDB interface. Reference Manual EasyMDB RS232-TTL. 1 Introduction

2 : BISTABLES. In this Chapter, you will find out about bistables which are the fundamental building blocks of electronic counting circuits.

Physics 226 FPGA Lab #1 SP Wakely. Terasic DE0 Board. Getting Started

Jianjian Song LogicWorks 4 Tutorials (5/15/03) Page 1 of 14

Cadence Verilog Tutorial Windows Vista with Cygwin X Emulation

1.1 The 7493 consists of 4 flip-flops with J-K inputs unconnected. In a TTL chip, unconnected inputs

Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts)

RUTGERS UNIVERSITY Department of Electrical and Computer Engineering 14:332:233 DIGITAL LOGIC DESIGN LABORATORY

Having read this workbook you should be able to: recognise the arrangement of NAND gates used to form an S-R flip-flop.

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

WEEK 8.1 Registers and Counters. ECE124 Digital Circuits and Systems Page 1

Counters are sequential circuits which "count" through a specific state sequence.

University of St. Thomas ENGR Digital Design 4 Credit Course Monday, Wednesday, Friday from 1:35 p.m. to 2:40 p.m. Lecture: Room OWS LL54

Sequential Logic Design Principles.Latches and Flip-Flops

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

Building an Embedded Processor System on a Xilinx Zync FPGA (Profiling): A Tutorial

Two's Complement Adder/Subtractor Lab L03

Technical Aspects of Creating and Assessing a Learning Environment in Digital Electronics for High School Students

VHDL Test Bench Tutorial

Step Response of RC Circuits

Measuring Electric Phenomena: the Ammeter and Voltmeter

After opening the Programs> Xilinx ISE 8.1i > Project Navigator, you will come to this screen as start-up.

10/100 Mbps Ethernet MAC

Take-Home Exercise. z y x. Erik Jonsson School of Engineering and Computer Science. The University of Texas at Dallas

Active Learning in the Introduction to Digital Logic Design Laboratory Course

(Refer Slide Time: 00:01:16 min)

EE 42/100 Lecture 24: Latches and Flip Flops. Rev B 4/21/2010 (2:04 PM) Prof. Ali M. Niknejad

PCB Project (*.PrjPcb)

Testing high-power hydraulic pumps with NI LabVIEW (RT) and the StateChart module. Jeffrey Habets & Roger Custers

Digital Fundamentals. Lab 8 Asynchronous Counter Applications

Figure 1 FPGA Growth and Usage Trends

To design digital counter circuits using JK-Flip-Flop. To implement counter using 74LS193 IC.

Asynchronous counters, except for the first block, work independently from a system clock.

A Digital Timer Implementation using 7 Segment Displays

Digitale Signalverarbeitung mit FPGA (DSF) Soft Core Prozessor NIOS II Stand Mai Jens Onno Krah

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

Quartus II Introduction for VHDL Users

CSE 141L Computer Architecture Lab Fall Lecture 2

COMBINATIONAL and SEQUENTIAL LOGIC CIRCUITS Hardware implementation and software design

LAB #4 Sequential Logic, Latches, Flip-Flops, Shift Registers, and Counters

Quartus II Introduction Using VHDL Design

Modeling Sequential Elements with Verilog. Prof. Chien-Nan Liu TEL: ext: Sequential Circuit

2011, The McGraw-Hill Companies, Inc. Chapter 5

Flip-Flops and Sequential Circuit Design. ECE 152A Winter 2012

Flip-Flops and Sequential Circuit Design

Figure 8-1 Four Possible Results of Adding Two Bits

State Machines in VHDL

CHAPTER 3 Boolean Algebra and Digital Logic

Life Cycle of a Memory Request. Ring Example: 2 requests for lock 17

DIGITAL COUNTERS. Q B Q A = 00 initially. Q B Q A = 01 after the first clock pulse.

LEVERAGING FPGA AND CPLD DIGITAL LOGIC TO IMPLEMENT ANALOG TO DIGITAL CONVERTERS

CS311 Lecture: Sequential Circuits

An Introduction to MPLAB Integrated Development Environment

Fall 2006 CS/ECE 333 Lab 1 Programming in SRC Assembly

isppac-powr1220at8 I 2 C Hardware Verification Utility User s Guide

Lab 3: Introduction to Data Acquisition Cards

Implementation of Web-Server Using Altera DE2-70 FPGA Development Kit

3-Digit Counter and Display

Microprocessor & Assembly Language

Transcription:

LAB 6 Finite State Machine Design A Vending Machine You will learn how turn an informal sequential circuit description into a formal finite-state machine model, how to express it using ABEL, how to simulate it, and how to implement it and test it on the logic board. 1.0 Introduction Design of sequential circuits is quite a bit more involved than that of combinational circuits. There are many opportunities for things to go wrong, and debugging a malfunctioning circuit can be tedious at best and downright frustrating at worst. Fortunately, by adopting a structured approach to the design and debug of sequential circuits, and by carefully documenting the design, many of these problems become manageable. The analogy to software development here is quite apt; if you write spaghetti code you are more likely to be frustrated when things don t work, and won t get much sympathy when you seek help. The reward for discipline, on the other hand, is that you ll spend less time chasing after hard-to-find bugs and more enjoying the fruits of your creativity. Design can be fun! 2.0 Preparation Read Chapter 7 of Wakerly, especially Sec. 7.6 on state machine synthesis using transition lists and Sec. 7.11 on the sequential features of the ABEL HDL; additional help on ABEL is available through the on-line documentation of the Foundation software. 3.0 Design Specifications VEDMACH is a vending machine that accepts nickels, dimes, and quarters, and dispenses gum, apple, or yogurt. A gum pack costs 15, an apple is 20, and yogurt is 25. Prof. Jenkins and Prof. Mazumder EECS 270: Introduction to Logic Design 6-1

Design Specifications FIGURE 8. Top-level schematic of VEDMACH VEDMACH D0 D1 CLOCK IIT CREDIT 7 LEFT & RIGHT LEDs PC Parallel Port D2 D3 D4 D5 ICKEL DIME DISPESED ITEM QUARTER COIRETUR 7 (GUM) (APPLE) (YOGURT) XS40 LED DIPSW1 GUM DIPSW2 APPLE CHAGE 3 BAR LED DIPSW3 YOGURT The top-level schematic of VEDMACH is shown in Figure 8. The machine has the following 1-bit inputs: ICKEL: a signal that becomes 1 when a nickel is deposited in the coin slot. DIME: a signal that becomes 1 when a dime is deposited in the coin slot. QUARTER: a signal that becomes 1 when a quarter is deposited in the coin slot. COIRETUR: a signal that becomes 1 when the coin return button is pressed. GUM: a signal that becomes 1 when the gum selection button is pressed. APPLE: a signal that becomes 1 when the apple selection button is pressed. YOGURT: a signal that becomes 1 when the yogurt selection button is pressed. In addition to these user inputs, the machine has two control inputs: CLOCK: a timing signal that sequences the state transitions of the machine. IIT: an initialization signal that resets the machine to a suitable starting state. The machine has three outputs: CREDIT: the amount of money deposited so far and available to make a purchase; CREDIT, in cents, should be displayed on the LEFT and RIGHT LED digits. DISPESED ITEM: the item that was just purchased should be displayed on the XS40 LED: g for gum, A for apple, and y for yogurt, as indicated in Figure 8. 6-2 EECS 270: Introduction to Logic Design Prof. Jenkins and Prof. Mazumder

Design otes and Hints CHAGE: the amount of money returned in change, or as a result of pressing the coin return button. The machine returns change using only nickels; the number of nickels returned should be displayed as a binary number using the three left-most BAR LED segments (bright segment for 1, dark segment for 0.) The machine should behave in accordance with the following specifications: 1. A customer needs to deposit a sufficient amount of money before or at the same time that he or she is selecting an item for purchase. If the item costs less than the deposited amount, the item is dispensed and the correct change is returned. If the item costs more than the deposited amount, the machine waits for more coins to be inserted or for a cheaper item to be selected. 2. The coin slot in the machine will only accept a single coin. Attempts to jam two or more coins cannot affect the state of the machine and are ignored. Similarly, attempts to make multiple selections (e.g. selecting apple and yogurt at the same time) are ignored. 3. At any time, pressing the coin return button causes the credit amount to be returned as change in nickels. Furthermore, when credit is equal to 25, any additional coins that are inserted are immediately returned as change. Finally, the return button closes the coin insertion slot; thus attempting to deposit a coin while at the same time pressing the return button prevents the coin from being inserted. 4.0 Design otes and Hints This circuit has too many inputs and state variables to be designed using an explicit state diagram model. Instead, it is best approached by constructing a transition list that gives symbolic transition expressions for each pair of present and next states. Construct this transition list and code it using ABEL s state diagram construct. Make sure that your transition expressions for every possible present state are mutually exclusive and all-inclusive. Use a one-hot state encoding. The FPGA has plenty of flip-flops, and a sparse onehot encoding of the machine states is more appropriate than an encoding that uses the fewest number of flip-flops. Sequential circuits are a lot harder to design and debug than combinational circuits. Make sure you provide a means to initialize the flip-flops in your design. Whenever you notice signals whose value is X or Z, check to make sure that the flip-flops driving them are properly initialized. While we have not paid much attention to electrical issues in this lab, sometimes reality hits and we must face it. Signals that have high fan-out (i.e. a lot of connections) such as clocks must be buffered sufficiently and treated specially by the wire routing tools (to use high-speed interconnect layers, e.g.) to avoid timing problems. There are a number of global clock buffers that you can instantiate to help deal with these problems. For the clock input, it is suggested that you insert a BUFGLS after the IBUF you normally use on input signals. Prof. Jenkins and Prof. Mazumder EECS 270: Introduction to Logic Design 6-3

Deliverables 5.0 Deliverables This is a two-week lab with the following timeline: Lab6 Week 0 Week 1 Week 2 Week 3 Design & simulate Circuit Pre-lab due at start of lab period Post-lab report due In-lab demo can be done in either lab period The pre-lab is due at the beginning of your lab period in week 1. The in-lab demonstration can be done during either of the two lab periods; if you successfully demonstrate a working design in the first lab period, you don t have to come to the second lab period. 5.1 Pre-Lab (25 Points) 1. Hardcopy of VEDMACH s schematic, ABEL, and UCF files. 2. Hardcopy of simulation results for the sequence of inputs shown below: Cycle 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 G Q A Q Q D Q A R Q Q D Y Inputs G R Y D Q G G Y A In the above table,, D, Q, R, G, A, Y stand for asserting (i.e. setting to 1) the nickel, dime, quarter, coin return, gum, apple, and yogurt inputs. You should make sure the circuit is initialized properly before applying the above input sequence. Display the simulation traces using the format shown in the Figure 9; annotate your waveforms (either using the comment feature of the waveform viewer, or by marking your hardcopy) to facilitate their interpretation. Provide a table showing the correspondence between the hexadecimal values displayed for the bus signals and their interpretation as displayed on the LEDs. For example, the hexadecimal values 6D and 14 on LS6..LS0 and RS6..RS0 display as the decimal digits 15, meaning a 15-cent credit. 5.2 In-Lab (30 Points) Generate the.bit file for VEDMACH, download it to the XESS board, and verify that your implementation is working properly. ote that applying input to the FPGA requires that you issue three stimulus commands: a) set the inputs to their required values (while the clock is low); b) assert the clock (make it go high); and c) de-assert both the input and the clock. When you are satisfied that you have a correctly-function- 6-4 EECS 270: Introduction to Logic Design Prof. Jenkins and Prof. Mazumder

Deliverables FIGURE 9. Format for displaying simulation results 5 10 15 0 (nickels) g LS6..LS0 RS6..RS0 S6..S0 DB1..DB3 ing circuit, demonstrate its operation to your lab GSI and have him sign your experiment s cover sheet. 5.3 Post-Lab (45 Points) Prepare your lab report as described in the EECS270 Laboratory Overview handout. Make sure you complete and include all parts of the report including the Cover Sheet, the Design arrative section, and the Design Documentation section. Include as part of your design documentation all corrected pre-lab requirements. DO OT ICLUDE THE MAP AD PLACE & ROUTE IMPLEMETATIO REPORT FILES. Instead, consult the report files (and any other files in the project directory) to find the following information about the design: Utilization of the FPGA resources: number of CLBs used, number of flip-flops used, and number of 3- and 4-input look-up tables (LUTs) used. Worst case net delay. Minimum clock period and maximum clock frequency for reliable operation. Minimum and maximum fan-in (number of first-level AD gates) over the set of implemented output functions. umber of product terms used in the implementation. Prof. Jenkins and Prof. Mazumder EECS 270: Introduction to Logic Design 6-5

Deliverables In your design narrative, provide enough detail about the choices you made to realize your particular implementation of this circuit. Specifically, document any flexibility in the design specification that you exploited to make particular design decisions. 6-6 EECS 270: Introduction to Logic Design Prof. Jenkins and Prof. Mazumder