keypad decoder on picoblaze 1. synopsis: 2. procedure

7
EE354L - Introduction to Digital Circuits Keypad_decoder_on_Picoblaze.fm [Revised: 3/9/20] 1/7 Keypad Decoder on Picoblaze 1. Synopsis: The purpose of this lab is to get to know how to add input ports and output ports to the picoblaze soft-core processor so that the processor can interact with the top-level design. Incidentally we get to know the keypad scanning mechanism to detect the key pressed on a hex keypad. This lab cov- ers partial address decoding in the top design, significance of the read_strobe and the write_strobe, and need for the output registers in the output ports. 2. Procedure: In this lab, we will explore interfacing the Digilent Hex Keypad to the Artix-7 FPGA on Nexys-4. It is assumed that all of you have gone through the following demo and know the steps involved in a picoblaze-based design. http://www-classes.usc.edu/engr/ee-s/254/ee254l_lab_manual/PicoBlaze/Picoblaze_Design_Steps_Demo_README_r1.pdf Please keep Picoblaze_Design_Steps_Demo_README_r1.pdf open while doing this lab. Prelab: Please go through this and the other pdf files posted in the following directory before coming to the lab. http://www-classes.usc.edu/engr/ee-s/254/ee254l_lab_manual/PicoBlaze/USC_Keypad/ Also go through the Verilog files in the two RTL completed designs (non-picoblaze-based designs) provided in the following subdirectory. Go through the Keypad_RTL_without_switches design first followed by the Keypad_RTL_with_switches design. http://www-classes.usc.edu/engr/ee-s/254/ee254l_lab_manual/PicoBlaze/USC_Keypad/Keypad_RTL_Designs/ Part 1 Keypad_2RO_3WO_ports: In part 1 you will implement the RTL design interfacing the keypad and switches (Keypad_RTL_with_switches) in picoblaze. Part 2 Keypad_5RO_6WO_ports: In part 2, you modify part 1 design by increasing the input and output ports and get to know more about input and output ports. 3. Keypad, PMOD, and the Digilent demo design:

Upload: khangminh22

Post on 24-Nov-2023

0 views

Category:

Documents


0 download

TRANSCRIPT

EE354L - Introduction to Digital Circuits

Keypad_decoder_on_Picoblaze.fm [Revised: 3/9/20] 1/7

Keypad Decoder on Picoblaze

1. Synopsis:

The purpose of this lab is to get to know how to add input ports and output ports to the picoblazesoft-core processor so that the processor can interact with the top-level design. Incidentally we getto know the keypad scanning mechanism to detect the key pressed on a hex keypad. This lab cov-ers partial address decoding in the top design, significance of the read_strobe and thewrite_strobe, and need for the output registers in the output ports.

2. Procedure:

In this lab, we will explore interfacing the Digilent Hex Keypad to the Artix-7 FPGA on Nexys-4.

It is assumed that all of you have gone through the following demo and know the steps involvedin a picoblaze-based design.http://www-classes.usc.edu/engr/ee-s/254/ee254l_lab_manual/PicoBlaze/Picoblaze_Design_Steps_Demo_README_r1.pdf Please keep Picoblaze_Design_Steps_Demo_README_r1.pdf open while doing this lab.

Prelab: Please go through this and the other pdf files posted in the following directory beforecoming to the lab.http://www-classes.usc.edu/engr/ee-s/254/ee254l_lab_manual/PicoBlaze/USC_Keypad/ Also go through the Verilog files in the two RTL completed designs (non-picoblaze-baseddesigns) provided in the following subdirectory. Go through the Keypad_RTL_without_switchesdesign first followed by the Keypad_RTL_with_switches design.http://www-classes.usc.edu/engr/ee-s/254/ee254l_lab_manual/PicoBlaze/USC_Keypad/Keypad_RTL_Designs/

Part 1 Keypad_2RO_3WO_ports: In part 1 you will implement the RTL design interfacing thekeypad and switches (Keypad_RTL_with_switches) in picoblaze.

Part 2 Keypad_5RO_6WO_ports: In part 2, you modify part 1 design by increasing the input andoutput ports and get to know more about input and output ports.

3. Keypad, PMOD, and the Digilent demo design:

EE354L - Introduction to Digital Circuits

Keypad_decoder_on_Picoblaze.fm [Revised: 3/9/20] 2/7

4. Procedure:

Part 0: Preview the completed RTL designs Download Key-pad_RTL_Designs.zip. There are two designs. In the Keypad_RTL_with-out_switches, we do not read switches. We just activate anode 0 and display thekey pressed on SSD0.assign anode = 4'b1110;In the Keypad_RTL_with_switches, we read the right four switches, and display the key pressed on the rightfour SSDs based on which of the four switches are on. We added this reading of switches and writing to anodes toincrease the number of input and output ports we need to deal with in the picoblaze-based design. assign anode = ~ switch; // Note: anode pins on the FPGA are active low

In this Part 0, please compare the two files, Decoder.v and Decoder_simplified_by_Trojans.v in Keypad_RTL_Designs\Keypad_RTL_without_switches\Design_files\sources. Connect a hex keypad to the JA PMOD connector and download the .bit file TAs_pmodkypd_with_switches.bit file in the Keypad_RTL_with_switchesto the board. Press keys on the keypad and operate switches SW[3:0] and verify their operation.

Part 1 Keypad_2RO_3WO_ports : Please see the block diagram at the end of this file. Inthis part, we will port the RTL design interfacing the keypad and switches (Key-pad_RTL_with_switches) to picoblaze. We implement the functionality ofDecoder_with_switches.v and the DisplayController_with_switches.v in assembly lan-guage by completing the “TODO” sections in the two files,

prom_kypd_2RO_3WO.psm and keypad_top_2RO_3WO.v.

Part 1 Steps:

4.1 Keep Picoblaze_Design_Steps_Demo_README_r1.pdf open

4.2 Download the USC_Keypad.zip file and extract it in your C:\Xilinx_projects\ direc-tory to form C:\Xilinx_projects\USC_Keypad directory.

ROW3

ROW2ROW1ROW0

COL3COL2COL1COL0

1

4

7

0

2

5

8

F

3

6

9

E

A

B

C

D

R0R1R2R3

C0C1C2C3

EE354L - Introduction to Digital Circuits

Keypad_decoder_on_Picoblaze.fm [Revised: 3/9/20] 3/7

4.3 Copy the following two files from Picoblaze_Design_Steps_Demo\assembly to your directory USC_Keypad\Keypad_2RO_3WO_ports\assembly .kcpsm6.exe and ROM_form.v

4.4 Complete the “TODO” sections in the file prom_kypd_2RO_3WO.psm in the sources subdirectory, copy it to assembly subdirectory.Assemble the .psm file to produce prom_kypd_2RO_3WO.v Move (or copy) the file prom_kypd_2RO_3WO.v from assembly subdirectory to sources subdirectory.

4.5 Copy the picoblaze processor file kcpsm6.v from Picoblaze_Design_Steps_Demo\sources to your USC_Keypad\Keypad_2RO_3WO_ports\sources directory. You already have the .xdc file ee354_Nexys4_top.xdc here in the sources directory. It has all the pin definitions and the clock constraint.

4.6 Complete the “TODO” sections in the top design file keypad_top_2RO_3WO.v Invoke Vivado. Setup project directory as your USC_Keypad\Keypad_2RO_3WO_ports\synthesis . Add two Verilog files and one .xdc file to the project, and produce the pmodkypd_2ro_3wo.bit file.

4.7 Connect a hex keypad to the JA PMOD connector and download the .bit file to the board. Press keys on the keypad and operate switches SW[3:0] and verify its operation. Demonstrate to your TA.

Part 2 Keypad_5RO_6WO_ports: Please see the 2-page block diagram at the end of this file. In this part, we split the 4-bit output port driving the 4 column lines into 4 single-bit output ports. We also split the 4-bit input port reading the 4 row lines, into four separateinput ports (one per each row line concatenated with 7 zeros). You need to use minimum number of port_id bits to perform address decoding in the top design. And once you decide on address decoding, you use those addresses in your assembly language program (.psm).

Part 2 Steps:

4.8 Go to the directory USC_Keypad, and copy the source files (not machine generated files) from the sources subdirectory of Keypad_2RO_3WO_ports into corresponding sourcessubdirectory in Keypad_5RO_6WO_ports. By this time you know that you need in theassembly subdirectory the kcpsm6.exe and ROM_form.v from the other assembly directory.

4.9 Go into Keypad_5RO_6WO_ports/sources and change the names of the two files: We wanted you to copy and modify the following files.Change prom_kypd_2RO_3WO.psm to prom_kypd_5RO_6WO.psm and edit.Change keypad_top_2RO_3WO.v to keypad_top_5RO_6WO.v and edit.But senior TAs advised me that students need more time to learn these techniques. So we have actually provided exercise versions of these two files with TODO parts :)

EE354L - Introduction to Digital Circuits

Keypad_decoder_on_Picoblaze.fm [Revised: 3/9/20] 4/7

4.10 Assemble the .psm file (prom_kypd_5RO_6WO.psm) to produce the .v file (prom_kypd_5RO_6WO.v) and move it (or copy it) from assembly subdirectory to sources subdirectory.

4.11 Setup Vivado project in the synthesis subdirectory and add the two .v files and one .xdc file to the project. Produce the pmodkypd_5ro_6wo.bit file.

4.12 Download, test, and demonstrate to your TA.

Celebrate your successful completion of this lab!

EE354L - Introduction to Digital Circuits

Keypad_decoder_on_Picoblaze.fm [Revised: 3/9/20] 5/7If the picoblaze is reading the output of a FIFO, we need to considerthe read_strobe, as otherwise the FIFO would increment its internalread pointer undesirably.

EE354L - Introduction to Digital Circuits

Keypad_decoder_on_Picoblaze.fm [Revised: 3/9/20] 6/7

EE354L - Introduction to Digital Circuits

Keypad_decoder_on_Picoblaze.fm [Revised: 3/9/20] 7/7