ECE 4200
Department of Electrical and Computer Engineering
Advanced Digital Design Lab
University of Colorado at Colorado Springs "Illuminate, Investigate, Innovate"
Spring Semester Dr. Greg Tumbush, greg@tumbush.com
Lab #7: Design Example: Keypad Scanner and Encoder - Part 3 (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 clk reset
Direction input input
read
input
Width Purpose 1MHz clock Asynchronous active high reset Read from the fifo.
Page 1 of 4
Lab 7 Version 1.2
ECE 4200
Department of Electrical and Computer Engineering
Advanced Digital Design Lab
University of Colorado at Colorado Springs "Illuminate, Investigate, Innovate"
Spring Semester
mode_toggle
input
Row Col seven_seg
input output output
[3:0] [3:0] [6:0]
seven_seg_0_en output seven_seg_1_en output seven_seg_2_en output seven_seg_3_en output DGrp
output
[7:0]
Toggle between LED display states Keypad row Keypad column 7-segment character active low 7-segment character 0 enable – active low 7-segment character 1 enable – active low 7-segment character 2 enable – active low 7-segment character 3 enable – active low 8 LED’s
Table 1: Keypad scanner I/O
Figure 2: Partition of keypad scanner
The objective of this lab is to design and test the Controller and LED Controller.
Controller The Controller block will accept the valid signal from the Hex Keypad Code Generator and the read button input and produce write and read signals for the fifo.
Page 2 of 4
Lab 7 Version 1.2
ECE 4200
Department of Electrical and Computer Engineering
Advanced Digital Design Lab
University of Colorado at Colorado Springs "Illuminate, Investigate, Innovate"
Spring Semester
The valid signal indicates that the Code output of the Hex Keypad Code Generator should be written to the fifo. The reset button is distributed to all blocks requiring reset. The FIFO model that we are using will read its contents on the active edge of the clock while the read button input signal is asserted. The prototyping boards have clocks that are running at 25MHz or 50Mhz, depending on the model. Without extra circuitry a single push of the read button would cause the entire contents of the FIFO to be dumped before the read button could be released by a human operator. Therefore, a simple state machine must be designed to accept the read button signal and assert a read signal at the FIFO for only one clock cycle. The button must be de-asserted before another read can occur. This circuitry is known as a one-shot. A diagram of this circuit can be seen in Figure 3 and a timing diagram can be seen in Figure 4. This button should also be de-bounced before the one-shot circuitry.
Figure 3: one-shot for a synchronized input
Figure 4: Timing diagram of synchronous one-shot
LED Controller The LED Controller block will display the full, empty, read_ptr, and write_ptr signals from the fifo
and the current synchronized Row input and Col output of the Hex Keypad Code Generator and a 4-bits of your choice. Lastly, the LED Controller block will accept the mode_toggle push button input. From these inputs and the mode_toggle push button input the 8 LED’s will be driven. NOTE: You might have to create new outputs on certain previously designed blocks so that the signals can be observed. Be sure to update your test-benches of these blocks accordingly. The mode_toggle push button input should be de-bounced and a one-shot used just like the read push button input. The mode_toggle push button input will cause the 8 LED’s to toggle between the system debug information in Table 2. DGrp1 will be displayed at reset.
Page 3 of 4
Lab 7 Version 1.2
ECE 4200
Department of Electrical and Computer Engineering
Advanced Digital Design Lab
University of Colorado at Colorado Springs "Illuminate, Investigate, Innovate"
Spring Semester
Data Group DGrp1 DGrp2 DGrp3
System Debug Info {1’b0, read_ptr[2:0], 1’b0, write_ptr[2:0] {<your choice>, empty, full} {Row, Col} Table 2: LED System Debug info
Testbench Since the Controller and LED Controller share no common I/O except clk and reset they should be tested independently. Deliverables 1. I/O table for the Controller and LED Controller 2. Source code of the Controller and LED Controller 3. Test plan 4. Source code of final self-checking test-bench for Controller 5. Source code of final self-checking test-bench for LED Controller 6. Demonstration of the operation of the test-bench to the lab instructor . Grading 1. Demonstration – 75pts a. Correct operation of test-bench b. Correct operation of Controller and LED Controller 2. Final report including test plan – 45pts
Page 4 of 4
Lab 7 Version 1.2