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



Similar documents
Registers & Counters

Modeling Registers and Counters

CHAPTER 11 LATCHES AND FLIP-FLOPS

ECE 451 Verilog Exercises. Sept 14, James Barnes

E158 Intro to CMOS VLSI Design. Alarm Clock

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

CHAPTER 11: Flip Flops

A Verilog HDL Test Bench Primer Application Note

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

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

RAPID PROTOTYPING OF DIGITAL SYSTEMS Second Edition

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

EC313 - VHDL State Machine Example

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

International Journal of Advancements in Research & Technology, Volume 2, Issue3, March ISSN

Figure 8-1 Four Possible Results of Adding Two Bits

A New Paradigm for Synchronous State Machine Design in Verilog

Wiki Lab Book. This week is practice for wiki usage during the project.

Counters and Decoders

Digital Electronics Detailed Outline

MAX II ISP Update with I/O Control & Register Data Retention

More Verilog. 8-bit Register with Synchronous Reset. Shift Register Example. N-bit Register with Asynchronous Reset.

Scan a Keypad with the BS2 For Pushbutton User Input

Chapter 9 Latches, Flip-Flops, and Timers

Chapter 7: Advanced Modeling Techniques

CHAPTER IX REGISTER BLOCKS COUNTERS, SHIFT, AND ROTATE REGISTERS

Digital Circuit Design Using Xilinx ISE Tools

Digital Design Verification

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

Lab 11 Digital Dice. Figure Digital Dice Circuit on NI ELVIS II Workstation

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

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

ECE380 Digital Logic

Introduction to Digital Design Using Digilent FPGA Boards Block Diagram / Verilog Examples

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

Digital Fundamentals. Lab 8 Asynchronous Counter Applications

8 by 8 dot matrix LED displays with Cascadable Serial driver B32CDM8 B48CDM8 B64CDM8 General Description

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

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

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

Upon completion of unit 1.1, students will be able to

Lesson 12 Sequential Circuits: Flip-Flops

An Integer Square Root Algorithm

Timing Methodologies (cont d) Registers. Typical timing specifications. Synchronous System Model. Short Paths. System Clock Frequency

Asynchronous & Synchronous Reset Design Techniques - Part Deux

Memory unit. 2 k words. n bits per word

DDS. 16-bit Direct Digital Synthesizer / Periodic waveform generator Rev Key Design Features. Block Diagram. Generic Parameters.

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

D-MAX WEB GUIDE CONTROLLER WITH OPERATOR INTERFACE PANEL QUICK START SETUP MANUAL

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

PROGETTO DI SISTEMI ELETTRONICI DIGITALI. Digital Systems Design. Digital Circuits Advanced Topics

Chapter 5 :: Memory and Logic Arrays

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

ETEC 2301 Programmable Logic Devices. Chapter 10 Counters. Shawnee State University Department of Industrial and Engineering Technologies

Digital Systems. Syllabus 8/18/2010 1

1. Learn about the 555 timer integrated circuit and applications 2. Apply the 555 timer to build an infrared (IR) transmitter and receiver

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

Seven-Segment LED Displays

University of Toronto Faculty of Applied Science and Engineering

Technical Note. Micron NAND Flash Controller via Xilinx Spartan -3 FPGA. Overview. TN-29-06: NAND Flash Controller on Spartan-3 Overview

Reading User Data from Configuration PROMs

EXPERIMENT 8. Flip-Flops and Sequential Circuits

The components. E3: Digital electronics. Goals:

DM Segment Decoder/Driver/Latch with Constant Current Source Outputs

The 104 Duke_ACC Machine

Digital Logic Design Sequential circuits

Engr354: Digital Logic Circuits

Model 5511 Filler Controller User s Manual Version 1.1 October 2011

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

Copyright Peter R. Rony All rights reserved.

路 論 Chapter 15 System-Level Physical Design

Modeling Latches and Flip-flops

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

Module 3: Floyd, Digital Fundamental

DEPARTMENT OF INFORMATION TECHNLOGY

Digital Systems Design! Lecture 1 - Introduction!!

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

3-Digit Counter and Display

PROGETTO DI SISTEMI ELETTRONICI DIGITALI. Digital Systems Design. Digital Circuits Advanced Topics

Lecture 11: Sequential Circuit Design

Flip-Flops, Registers, Counters, and a Simple Processor

Lecture 10: Sequential Circuits

Manchester Encoder-Decoder for Xilinx CPLDs

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

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

Flip-Flops and Sequential Circuit Design

Rotary Encoder Interface for Spartan-3E Starter Kit

COMBINATIONAL and SEQUENTIAL LOGIC CIRCUITS Hardware implementation and software design

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

STEPPER MOTOR SPEED AND POSITION CONTROL

EE360: Digital Design I Course Syllabus

Lecture 10: Multiple Clock Domains

ASYNCHRONOUS COUNTERS


Fundamentals of Digital Electronics

A Lesson on Digital Clocks, One Shots and Counters

Status of the design of the TDC for the GTK TDCpix ASIC

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

Memory Elements. Combinational logic cannot remember

Transcription:

Dr. Greg Tumbush, gtumbush@uccs.edu Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts) Objective The objective of lab assignments 5 through 9 are to systematically design and implement an FPGA-based keypad scanner. The keypad scanner will utilize a FIFO for data storage and retrieval, a display mux, and the seven-segment displays, slide switches, and LEDs of the Digilent Spartan3 prototyping board. The top level block diagram of the system is shown in Figure 1 and the I/O in Table 1. When a button of the hex keypad is pressed the system must decode the button and store the data in an internal FIFO. The read button will be used to read data from the FIFO and display the data on the seven-segment displays. The mode_toggle input will be used to toggle between display states so that more than eight signals can be presented for view on the LED s. The LEDs will display the status of the FIFO and other information. The hardware prototype will be verified to operate with the Grayhill 072 hex Keypad. A system partition is shown in Figure 2. As input mode_toggle is depressed output DGrp will toggle between DGrp1, DGrp2, and DGrp3 as denoted in Table 2. Figure 1: Keypad scanner top level Name Direction Width Purpose clk input 50MHz clock reset input Asynchronous active high reset read input Read from the fifo. Page 1 of 8 Lab 5 Version 1.5

mode_toggle input Toggle between LED display states Row input [3:0] Keypad row Col output [3:0] Keypad column seven_seg output [6:0] 7-segment character - active low seven_seg_0_en output 7-segment character 0 enable active low seven_seg_1_en output 7-segment character 1 enable active low seven_seg_2_en output 7-segment character 2 enable active low seven_seg_3_en output 7-segment character 3 enable active low DGrp output [7:0] 8 LED s Table 1: Keypad scanner I/O Figure 2: Partition of keypad scanner Data Group System Debug Info DGrp1 {1 b0, read_ptr[2:0], 1 b0, write_ptr[2:0] DGrp2 {<your choice>, empty, full} DGrp3 {Row, Col} Table 2: LED System Debug info Page 2 of 8 Lab 5 Version 1.5

The objective of this lab is to design and test the keypad scanner/encoder. This lab will be completed individually. Keypad Scanner Keypad scanners are used to enter data manually in digital telephones, computer keyboards and other digital systems. Telephones have a decimal keypad, and computer keyboards usually have a hexadecimal keypad. A keypad scanner responds to a pressed key and forms a code that uniquely identifies the key that is pressed. It must take into account the asynchronous nature of the inputs and deal with switch debounce. Also, in some applications, it must not interpret a key to be pressed repeatedly if it is pressed once and held down. We will use a synchronizer to synchronize the asynchronous inputs and a debounce circuit to debounce the synchronized input. Let's consider a scheme for designing a scanner/decoder for the hexadecimal keypad circuit shown in Figure 3. A pressed button establishes a connection between a row and a column at the location of the button. Each row is connected to a pull-down resistor, and is connected to a column when a keypad button is pressed. If a column line is connected to the supply voltage, a row that is connected to that column by a pressed button will be pulled to the supply voltage too; otherwise the row line is pulled down to 0 V. The keypad code generator unit has control over the column lines, and will exercise that control to detect the location of a pressed button. Figure 3: Scanner/encoder for the Grayhill 072 hexadecimal keypad circuit A keypad code generator must implement a decoding scheme that (1) detects whether a button is pressed, (2) identifies the button that is pressed, and (3) generates an output consisting of the unique code of the button. The decoding scheme will be implemented as a synchronous sequential machine with the Page 3 of 8 Lab 5 Version 1.5

button codes shown in Table 3. The outputs of the machine are the column lines, the code lines, and a signal, Valid, that indicates a valid code. Note that for each key press Valid will only be asserted for 1 clock cycle to indicate a valid signal on Code. This is true even if a key is pressed and held down. Table 3: Keypad codes for a hexadecimal scanner/encoder The pin-out of the ribbon cable for the keypad is Figure 4. The column (Col) is scanned by driving a 1 across each column and observing the value of Row. From this information it can be determined what button was pressed. For example if Col[2] is driven to 1 and a 1 is observed on row[1] key 6 has been pressed. Figure 4: Pinout for keypad Synchronization Circuit The input from the keypad, Row, is asynchronous. Any flip-flop that uses input Row will have to meet that flip-flip s setup or hold time requirement as depicted in Figure 5. When a flip-flip s setup/hold time requirement is not met the flip-flop s output may be unknown for a period of time. Page 4 of 8 Lab 5 Version 1.5

Figure 5: Setup/hold time for a flip-flop To combat this problem a synchronization circuit will be used as depicted in Figure 6 with the behavior as depicted in Figure 7. The clk signal is connected to the high speed system clock. Figure 6: Synchronization Circuit Figure 7: Synchronization Circuit timing Debounce Circuit The Row input can bounce for many milliseconds. There are many possibilities for de-bounce circuits. One possibility is to create a very slow divided down clock (~100Hz) and if Row is the same value on two clock edges then Row is considered to have stabilized. Another possibility that does not require dividing down the clock is a counter that will count the number of times a potential transition has occurred. For example, if the current de-bounced value is a zero, the counter will count the number of sequential ones detected. If a zero is detected the counter is reset. When the counter reaches a set value the de-bounced value will be set to a 1. Then the counter begins to look for a zero. Sample code is below: module debounce ( input wire clk, input wire reset, // Active high input wire data_in, // Input to debounce output reg data_debounced // Data debounced ); Page 5 of 8 Lab 5 Version 1.5

reg [15:0] change_reg; always @(posedge clk or posedge reset) begin if (reset) change_reg <= 'b0; // If we are at a 1 and get a 1 reset the change reg else if (data_debounced && data_in) change_reg <= 'b0; // If we are at a 0 and get a 0 reset the change reg else if (!data_debounced &&!data_in) change_reg <= 'b0; // If we are at a 1 and get a 0 increment the change reg else if (data_debounced &&!data_in) change_reg <= change_reg + 1'b1; // If we are at a 0 and get a 1 increment the change reg else if (!data_debounced && data_in) change_reg <= change_reg + 1'b1; end // If change_reg is MAX, toggle data_debounced always @(posedge clk or posedge reset) begin if (reset) data_debounced <= 'b0; else if (change_reg == 16'hFFFF) data_debounced <=!data_debounced; end endmodule Testbench Using the testbench depicted in Figure 8, verify the functionality of Hex_Keypad_Grayhill_072. The scanner is to be tested within a Verilog environment, not on a physical prototyping board with a physical keypad. Therefore, the testbench shown in Figure 8 must include (1) a signal generator that will simulate the assertion of a key, and (2) a module, Row_Signal, that will assert a row line corresponding to the asserted key, and (3) Hex_Keypad_Grayhill_072, the DUT. After the model of the keypad scanner has been verified, it can serve as a user interface in simulating other systems, and can also be used in a physical environment with confidence that it should function correctly, which greatly reduces the scope of a search for the source of an error in the operation of a prototype. The code for module Row_Signal is in Figure 9 Page 6 of 8 Lab 5 Version 1.5

Figure 8: Sample Testbench Figure 9: Code for Row_Signal Deliverables 1. I/O table for the Scanner/Encoder 2. State transition/output diagram for the Scanner/Encoder 3. Source code of Scanner/Encoder 4. Test plan 5. Source code of final self checking testbench 6. Demonstration of the operation of the test-bench to the lab instructor. Grading 1. Demonstrations: Page 7 of 8 Lab 5 Version 1.5

a. Correct operation of self checking test-bench 30pts b. Correct operation of the Scanner/Encoder - 30 pts each 2. Report: a. Completeness of test plan. 30pts b. Final report including test plan. 30pts Page 8 of 8 Lab 5 Version 1.5