You are on page 1of 4

ECE 315 Computer Interfacing

Lab #1: Interfacing to Input and Output Devices on the


Digilent Zybo Z7 Board and Implementing a Simple Calculator
Winter 2022

Lab Dates, Demo Due Dates, and Report Dates


This lab exercise will be held on February 1 (LAB H21), February 2 (LAB H31), February 3 (LAB H41),
and February 4 (LAB H51). You must demo your design for Exercise 1 of this lab before 5 pm i.e.,
before the end of your respective lab session. Your solutions to Exercises 2 and 3 of this lab will
be due at the beginning of the first session of Lab #2 (Feb. 15, 16, 17 and 18 for sections H21, H31,
H41 and H51, respectively). Your team’s lab report must be uploaded by 11:00 pm on the same
day that the demonstration is due.

Objectives
• To gain experience designing with tasks, delays, and queues in a FreeRTOS application.
• To gain experience interfacing to inputs received from a keypad and push-buttons.
• To gain experience interfacing to outputs sent to a 7-segment LED display on the Zybo Z7
and to the console window in Xilinx Vivado SDK on the host PC.
• To implement a simple calculator as an embedded system.

Hardware Platform and Software Environment


• The hardware platform is a Digilent Zybo Z7 development board, which is based on a Xilinx
Zynq-7010 System-on-Chip (SoC) silicon chip. The Zynq-7010 contains two 667-MHz ARM
Cortex A9 32-bit CPUs, called CPU0 and CPU1, which can simultaneously execute two
independent software systems. As in Lab #0, CPU0 will run the FreeRTOS operating system;
the second processor, CPU1, will be left disabled.
• The Zybo Z7 board has five Pmod expansion ports, which can be used to enhance the Zybo
Z7 by connecting Pmod devices. Two of the Pmod ports connect to a 2-digit 7-segment LED
display (SSD), and a third Pmod port is connected to a 16-button keypad. There are also four
general-purpose pushbuttons, which are present on the Zybo Z7 board. Two adjacent Pmod

1
headers, labeled JC and JD on the Zybo board, must be connected to the twin plugs of a
Pmod 2-digit 7-segment LED display (SSD). The third header on the same edge of the Zybo
board, labeled JE, must be connected to the plug of a Pmod 16-button hex keypad module.
These three headers (JC, JD, and JE) are assumed by the software to connect to certain
general-purpose input/output signals coming from the Zynq-7010 SoC. If the wrong
headers are used to connect the Pmod modules, the software drivers will not work.
• The SoC hardware configuration and the initial source file must be downloaded from the Lab
#1 section of the lab eClass site. This source file contains the initial application code in C that
you will be trying out and then modifying.
Documentation
• Three HOWTO Vivado installation guides in the Lab References Section of the lab eClass
page (titled "ECE 315 Winter 2022" on eClass).
• Digilent Zybo Z7 Reference Manual: https://reference.digilentinc.com/reference/
programmable-logic/zybo-z7/reference-manual
• FreeRTOS Reference Manual: https://www.freertos.org/fr-content-
src/uploads/2018/07/FreeRTOS_Reference_Manual_V10.0.0.pdf
• Chapter 5 of the ECE 315 lecture slides.

Prelab Work
The 2019.1 version of the Vivado design package, including the Software Development Kit (SDK),
must be installed on your host computer. If you did not have access to a board for Lab #0, then
it is important that you complete the tutorial lab on your own to verify that your Vivado and SDK
development environments are working properly with your Zybo Z7 board. If you have any
difficulties with your installation, then contact a lab TA for assistance. It is recommended, but not
required, that you complete Exercise 1 below before coming to your lab session. This will verify
that you have succeeded in installing and slightly modifying the provided software project for Lab
#1. Exercise 1 will be due before 5 pm on your respective lab session day.

Laboratory Instructions
Exercise 1: Lighting up two LED digits from the key press
Download the hardware configuration and software project from the Lab #1 section of the eClass
site for the ECE 315 labs. Start up Vivado and load the hardware configuration onto the Zybo Z7
board. Export the hardware configuration from Vivado to SDK and then open and run the
provided software project. Verify that the provided FreeRTOS application executes properly as
follows: When a button is pressed on the 16-button keypad, the corresponding hex digit should
be displayed in the SDK terminal window. Initially the SSD is OFF. You must add your code to set

2
the SSD direction to “output” to enable it. Examine the given template carefully before making
changes to your code.

Only one digit can be displayed at a time on the two-digit LED (light-emitting diode) display, but
two digits can be effectively displayed to a human user if each digit (alternating between left-side
and right-side) is lit rapidly enough in succession. Now, you are to modify the given application so
that when a keypad button is pressed, the current digit will show on the right-side SSD. Next,
when a new keypad button is pressed, the previous digit shifts to the left-side SSD and the new
digit should be displayed on the right-side SSD. As the enters each new digit, the previous digit
will be shifted to the left side. Start off using a relatively slow frequency, say switching between
LED digits at 4 Hz (each digit is lit twice per second). Then increase the switching frequency in
steps until you get to the point where the two digits no longer appear to flicker. Can you find this
approximate value of frequency/time period when the digits no longer appear to flicker? Save
your working project. Your the source code will be handed along with your lab report.

Exercise 2: Entering multiple digits using the keypad to perform logical and modulo
operations
You are to modify the initially provided software project so that you can enter two digits from the
keypad into the application for processing.

The required system specification is as follows: The LED display is to start out unlit. When a
keypad key corresponding to a decimal digit is pressed, the corresponding digit will be displayed
on the SDK terminal. The keys A, B, C, D and F are to be ignored at this point. If instead of a
decimal display key, the E key is pressed, the last digit will be considered entered into the
application. This last digit will also be displayed on the right-side SSD. The keys A, B, C, D, and F
are to be ignored, with no effect on the internal state of the program and no effect on the output
display.

After pressing E, another decimal digit can be entered. However, pressing E again will cause the
last digit key pressed to be entered into the application. This digit will also be displayed on the
right-side LED. As before, the keys A, B, C, D, and F are to be ignored.

Using the two entered digits as operands from the above procedure, pressing one of the four
general-purpose pushbuttons on the Zybo Z7 board will perform either an XOR (right-most
button), OR, AND or modulo operation (left-most button), on the two decimal digits. Use the
push-button driver function that was included in the downloaded source file to read the
pushbuttons. If multiple pushbuttons get pressed, the first button to be pressed (after all
pushbuttons started out unpressed) is to be input, and any other pressed buttons are to be
ignored. If two more buttons appear to be pressed simultaneously, they are all to be ignored. The
answer of the operation is to be displayed on the two digits of the LED display in decimal.

3
For example, 8 ^ 7 = 15. Digit 5 will be displayed on the right Seven Segment display and Digit 1
will be displayed on the left Seven Segment display.

One or more new digits can also be entered into the system to allow further operations to be
performed. Save the source file as it must be submitted as part of your lab report.

Exercise 3: A Simple Calculator


The final exercise in this lab produces a four-function calculator. A similar procedure as in
Exercise 2 is to be used to enter a sequence of digits (representing a decimal number), with the E
key pressed to reset the operand, and the F key to register the operand from the user. When at
least two sequences (that is, two decimal numbers) have been entered, then pressing the A, B or
C keys will cause the two decimal numbers to be added, subtracted, or multiplied, respectively.
The fourth operation is checking if the two operands form a palindrome by pressing the key D. If
both the entered numbers are indeed a palindrome, a white light will glow on the RGB LED (LD6)
for 1.5 seconds. The answer for all the operations will be displayed in the console terminal. For
example, consider entering “123” and pressing F key. Then enter “100” and press the F key.
Pressing C will display “123 x 100 = 12300” on the console. Your code must of course take care
of any necessary conversions between the binary and decimal representations of numbers. You
must check any overflow when performing these operations and display an error message for the
operation.

Report Requirements
Your report will include the source files that you used to implement Exercises 1, 2 and 3. The
report must take the form of one file in pdf format that is then uploaded to eClass by the report
deadline to eClass.

Marking Scheme
Students will be graded based on the form and general quality of the report (clarity, organization,
tidiness, spelling, grammar) for the lab. The lab demonstration is worth 55% and the report is
worth 45%. The demonstration for exercises 1, 2 and 3 are each worth 10%, 22.5 and 22.5%,
respectively. It is acceptable to build your lab report around the three source files that you
developed for the three exercises, but those source files need to be provided with sufficient
comments to clearly explain what the code is doing. Your lab report should present the design
and results in a well-organized and professional manner. A clear and tidy layout as well as correct
grammar and punctuation are expected. References to technical sources should be indicated in
the text and listed in a final reference section.

You might also like