ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

Similar documents
ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University. Laboratory Exercise #1 Using the Vivado

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University. Laboratory Exercise #1 Using the Vivado

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

Quick Start Guide ZedboardOLED Display Controller IP v1.0

Xilinx Vivado/SDK Tutorial

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

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

Copyright 2014 Xilinx

CE 435 Embedded Systems. Spring Lab 3. Adding Custom IP to the SoC Hardware Debug. CE435 Embedded Systems

Introduction to Embedded System Design using Zynq

Use Vivado to build an Embedded System

Use Vivado to build an Embedded System

TP : System on Chip (SoC) 1

Lab 1 - Zynq RTL Design Flow

The Zynq Book Tutorials

Building an Embedded Processor System on Xilinx NEXYS3 FPGA and Profiling an Application: A Tutorial

Creating a Processor System Lab

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

Vivado Design Suite User Guide. Designing IP Subsystems Using IP Integrator

Adding Custom IP to the System

Creating the AVS6LX9MBHP211 MicroBlaze Hardware Platform for the Spartan-6 LX9 MicroBoard Version

Writing Basic Software Application

The Zynq Book. for Zybo and ZedBoard

Description: Write VHDL code for full_adder.vhd with inputs from switches and outputs to LEDs.

Lab Exercise 4 System on chip Implementation of a system on chip system on the Zynq

Spartan-6 LX9 MicroBoard Embedded Tutorial. Tutorial 1 Creating an AXI-based Embedded System

Zynq-7000 All Programmable SoC: Embedded Design Tutorial. A Hands-On Guide to Effective Embedded System Design

Spartan-6 LX9 MicroBoard Embedded Tutorial. Tutorial 2 Adding EDK IP to an Embedded System

ChipScope Inserter flow. To see the Chipscope added from XPS flow, please skip to page 21. For ChipScope within Planahead, please skip to page 23.

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

Introduction to Zynq

NIOS CPU Based Embedded Computer System on Programmable Chip

Xilinx Platform Studio tutorial

ELEC 4200 Lab#0 Tutorial

AC701 Built-In Self Test Flash Application April 2015

Arty MicroBlaze Soft Processing System Implementation Tutorial

Creating a base Zynq design with Vivado IPI

Integrating LogiCORE SEM IP in Zynq UltraScale+ Devices

Reconfigurable Architecture (8)

Avnet Zynq Mini Module Plus Embedded Design

Vivado Design Suite Tutorial. Designing IP Subsystems Using IP Integrator

Firstly, lets build the example design that shall be used throughout this tutorial by following the steps below:

NIOS CPU Based Embedded Computer System on Programmable Chip

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

Vivado Design Suite Tutorial. Designing IP Subsystems Using IP Integrator

ZedBoard: Zynq-7000 AP SoC Concepts, Tools, and Techniques

Requirement ZYNQ SOC Development Board: Z-Turn by MYiR ZYNQ-7020 (XC7Z020-1CLG400C) Vivado and Xilinx SDK TF Card Reader (Micro SD) Windows 7

427 Class Notes Lab2: Real-Time Clock Lab

Module 3: Adding Custom IP to an Embedded System

Interrupt Creation and Debug on ML403

Hello World on the ATLYS Board. Building the Hardware

University of Massachusetts Amherst Computer Systems Lab 1 (ECE 354) LAB 1 Reference Manual

Estimating Accelerator Performance and Events

Introduction. In this exercise you will:

1-1 SDK with Zynq EPP

Hardware In The Loop (HIL) Simulation for the Zynq-7000 All Programmable SoC Author: Umang Parekh

Xilinx ChipScope ICON/VIO/ILA Tutorial

Vivado Design Suite Tutorial

HyperBus Memory Controller (HBMC) Tutorial

Adding the ILA Core to an Existing Design Lab

Vivado Design Suite Tutorial. Designing IP Subsystems Using IP Integrator

Spartan-6 LX9 MicroBoard Embedded Tutorial. Lab 6 Creating a MicroBlaze SPI Flash Bootloader

University of Massachusetts Amherst Computer Systems Lab 2 (ECE 354) Spring Lab 1: Using Nios 2 processor for code execution on FPGA

KCU GBASE-KR Ethernet TRD User Guide

MicroZed: Hello World. Overview. Objectives. 23 August 2013 Version 2013_2.01

ZedBoard: Zynq-7000 AP SoC Concepts, Tools, and Techniques

Virtex-4 PowerPC Example Design. UG434 (v1.2) January 17, 2008

Vivado Tutorial. Introduction. Objectives. Procedure

Spartan-3 MicroBlaze Sample Project

Avnet S6LX16 Evaluation Board and Maxim DAC/ADC FMC Module Reference Design

Figure 1 TCL Used to Initialize PS

Reference System: Determining the Optimal DCM Phase Shift for the DDR Feedback Clock for Spartan-3E Author: Ed Hallett

EE 1315 DIGITAL LOGIC LAB EE Dept, UMD

Hardware Design Using EDK

FMC-IMAGEON VITA Pass-Through Tutorial

Introduction to Xilinx Vivado tools

Using Xilinx ChipScope Pro ILA Core with Project Navigator to Debug FPGA Applications. UG750 (v12.3) November 5, 2010

SimXMD Simulation-based HW/SW Co-debugging for field-programmable Systems-on-Chip

GigaX API for Zynq SoC

Microblaze for Linux Howto

VIVADO TUTORIAL- TIMING AND POWER ANALYSIS

Lab 5. Using Fpro SoC with Hardware Accelerators Fast Sorting

Laboratory Exercise 3 Comparative Analysis of Hardware and Emulation Forms of Signed 32-Bit Multiplication

Introduction to the Altera SOPC Builder Using Verilog Designs. 1 Introduction

Profiling Applications and Creating Accelerators

Synaptic Labs' AXI HyperBus Memory Controller (HBMC) IP for Xilinx FPGA Devices Tutorial

SimXMD: Simulation-based HW/SW Co-Debugging for FPGA Embedded Systems

SimXMD Co-Debugging Software and Hardware in FPGA Embedded Systems

Vivado Tutorial. Introduction. Objectives. Procedure. Lab Workbook. Vivado Tutorial

Vivado Design Suite User Guide

ISE Tutorial: Using Xilinx ChipScope Pro ILA Core with Project Navigator to Debug FPGA Applications

Module 2: Adding IP to a Hardware Design

EE 367 Logic Design Lab #1 Introduction to Xilinx ISE and the ML40X Eval Board Date: 1/21/09 Due: 1/28/09

University Program 3 Kit

Spartan-6 LX9 MicroBoard Embedded Tutorial. Tutorial 5 Embedded Chipscope Debugging

LED display manager documentation

Designing with ALTERA SoC Hardware

Introduction to the Altera SOPC Builder Using Verilog Design

Corona (MAXREFDES12#) ZedBoard Quick Start Guide

Transcription:

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University Prof. Sunil P Khatri (Lab exercise created and tested by Ramu Endluri, He Zhou, Andrew Douglass and Sunil P Khatri) Laboratory Exercise #2 Using the Software Development Kit (SDK) Objective The purpose of lab this week is to familiarize you with Vivado by developing a software based solution for controlling the LEDs in a manner similar to that which was done last week in pure FPGA hardware. To accomplish this goal, you will be guided through the process of creating a MicroBlaze processor system using the Vivado Block Design Builder. You will then add General Purpose Input/Output (GPIO) capabilities to the microprocessor via Intellectual Property (IP) hardware blocks from Xilinx. Finally, you will create software using the C programming language, which will run on the MicroBlaze processor inorder to implement the appropriate LED functionality. System Overview The microprocessor system you will build in this lab is depicted in Figure 1. To the left of the diagram is the MicroBlaze soft IP processor. Connected to it are two Local Memory Buses (LMBs), ilmb and dlmb for instruction fetch and data access respectively. Each LMB has its own block RAM (BRAM) controller which provides the interconnect logic between the MicroBlaze and BRAM (local memory). The AXI interconnect connects the MicroBlaze (bus master) to peripherals (bus slaves) external to the microprocessor. Typically included in the list of peripherals are the debugger module. The debugger allows the SDK to interact with the MicroBlaze processor after the FPGA has been programmed. This is useful for initializing regions of 1

2 Laboratory Exercise #2 memory outside of the FPGA and for general software debugging. The GPIO blocks provide the microprocessor with a means of controlling the LEDs and reading user input from the DIP switches and push buttons. Figure 1: MicroBlaze System Diagram Procedure 1. In the following steps we will launch Vivado and create a block design. (a) Before beginning, create a directory in your home folder for today s lab. Try to avoid spaces and special characters in the directory name as they have the potential for causing problems during the system build process. You may use the mkdir command in an open terminal to create a directory. (b) Next, type the following commands in the terminal window: >source /softwares/linux/xilinx/vivado/2015.2/settings64.sh >vivado The first command will setup the environment for Vivado, and the second command runs Vivado. (c) Once Vivado launches, select Create New Project and follow the same procedure as shown in Lab1 to create a new RTL project except do not add a source file in the project. In this lab you will use Xilinx Microblaze Processor. 2 ECEN 449

Laboratory Exercise #2 3 (d) On the left side, in the Flow Navigator under the IP Integrator section, click on Create Block Design. A window opens where you can specify the name of your design(eg. led sw). Leave the Directory and the Specify source set as they are. Click on the OK button. (Figure 2) Figure 2: Create Block Design (e) The Block Design Diagram opened (tab called Diagram) is empty. Right click within the diagram tab and select Add IP. Search MicroBlaze and double click on MicroBlaze to add it to our design. Right click and select Run Block Automation. Select the following configuration for the MicroBlaze processor and click OK. (Figure 3) Figure 3: Run Block Automation Local Memory: 64KB ECEN 449 3

4 Laboratory Exercise #2 Local Memory ECC: None Cache Configuration : None Debug Module: Debug & UART Peripheral AXI Port: Enabled Interrupt Controller: Unchecked. Clock Connection: New Clocking Wizard (100 MHz) (f) Once the Diagram is generated, double-click on the Clocking Wizard block named clk wiz 1. This launches the Re-customize IP window. Select Clocking Options and change the source of the Primary Input Clock from Differential clock capable pin to Single ended clock capable pin. Click OK. (g) Right click and select Run Connection Automation in the diagram. In the Run Connection Automation window check All Automation and click OK. (h) The processor is set up, now we need to add General Purpose IO (GPIO) blocks to interact with LEDS, Switches and Buttons on the ZYBO board. Right click and select ADD IP. Search for GPIO and select AXI GPIO to add it to the design. Double click on the GPIO block named axi gpio 0 and select the IP configuration tab. Set the following configuration for the GPIO and click OK (Figure 4). Figure 4: Customize GPIO All Inputs: (not checked) 4 ECEN 449

Laboratory Exercise #2 5 All Outputs (checked) GPIO Width: 4 Leave the remaining values unchanged. (i) Right click and select Run Connection Automation, check All Automation, and click OK. Now design is connected. To make it look neat, right click and select Regenerate Layout. (j) You are using the GPIO block to configure LEDs, so let s rename the AXI GPIO block. Select the AXI GPIO block and rename the block to led in the Block Properties panel and press Enter. Repeat the same procedure for the port connected to the AXI GPIO block and rename it to led. The layout should look like Figure 5 Figure 5: Layout (k) Double click the reset rtl 0 port in the diagram. You can see that it is ACTIVE LOW. Double Click on the reset rtl port and observe that it is ACTIVE HIGH. (l) These are the reset ports for Microblaze. On ZYBO board we have dedicated reset pins for reset. Refer to manual and see the functionality of BTN6 and BTN7. (m) These two reset ports can be configured to a push button on the board. For the purpose of this lab, connect the ports to constant values and use the dedicated pins on board for reset. (n) Select Constant IP from the IP repository (Right click and ADD IP) and add two instances to the diagram. Double click on one of the constant IP blocks and set Constant Width to 1 and Constant Value to 1. Rename this block to VDD. Now, right click on the reset rtl 0 port and select Delete to delete it. Connect the constant block to ext rst in of the Processor System Reset because it is ACTIVE LOW. Connect the constant block by clicking on the output of the constant block and dragging it to the ext rst in pin. (o) Repeat the same procedure for the other constant block but set constant value to 0 and rename it as GND. Delete the reset rtl port and connect it to the reset port of the Clocking Wizard. ECEN 449 5

6 Laboratory Exercise #2 (p) Right click on the diagram and select Regenerate Layout. The final layout should look like Figure 6. 2. In the following steps we map the IO ports to the LEDs and buttons. (a) In the design tab, expand External Interfaces and Ports and examine the ports listed. When led is expanded it shows the led tri o and clock rtl ports listed. We need to connect these ports to the ZYBO board. (b) In the sources panel, right click on the constraints and select Add sources. Next, in the add sources window, select Add or create constraints and click Next. Click on the green + button and select create file. The Create Constraints File window will open, give a file name (eg. led), and click OK. Select Finish to create a constraint file. (c) In the sources panel, expand Constraints and double click on the created XDC file to open it. (d) Add the following code to attach the above ports to the pins on ZYBO board. # c l o c k r t l s e t p r o p e r t y PACKAGE PIN L16 [ g e t p o r t s c l o c k r t l ] s e t p r o p e r t y IOSTANDARD LVCMOS33 [ g e t p o r t s c l o c k r t l ] c r e a t e c l o c k add name s y s c l k p i n p e r i o d 10.00 waveform {0 5} [ g e t p o r t s c l o c k r t l ] # l e d t r i o s e t p r o p e r t y PACKAGE PIN M14 [ g e t p o r t s { l e d t r i o [ 0 ] } ] s e t p r o p e r t y IOSTANDARD LVCMOS33 [ g e t p o r t s { l e d t r i o [ 0 ] } ] s e t p r o p e r t y PACKAGE PIN M15 [ g e t p o r t s { l e d t r i o [ 1 ] } ] s e t p r o p e r t y IOSTANDARD LVCMOS33 [ g e t p o r t s { l e d t r i o [ 1 ] } ] s e t p r o p e r t y PACKAGE PIN G14 [ g e t p o r t s { l e d t r i o [ 2 ] } ] s e t p r o p e r t y IOSTANDARD LVCMOS33 [ g e t p o r t s { l e d t r i o [ 2 ] } ] s e t p r o p e r t y PACKAGE PIN D18 [ g e t p o r t s { l e d t r i o [ 3 ] } ] s e t p r o p e r t y IOSTANDARD LVCMOS33 [ g e t p o r t s { l e d t r i o [ 3 ] } ] 3. In the following steps we will Generate Bitstream and launch the SDK. (a) Right click in the diagram and select Validate Design to check for any errors in the design. If everything is correct, you have successfully built the hardware platform. (b) Right click on your project in the sources panel and select Create HDL wrapper. Select Let Vivado manage wrapper and auto update and click OK to create the top level module for the 6 ECEN 449

Laboratory Exercise #2 7 Figure 6: Final Layout design. Finally, click Generate Bitstream to create the program file. Once this is done, we will be able to export our hardware design and switch over to the SDK to program the FPGA and run the program to manage LEDs. (c) If any errors are found please rectify them. Once successfully completed, select File Export Export Hardware. Check Include bitstream to export the hardware platform. (d) Now, launch the Software Development Kit(SDK) using File Launch SDK. Select local to project as the location. 4. In the following steps we will use the SDK to create the software application. (a) Once the SDK is open. Select File New Application Project. Give a project name (eg.counter sw). Click Next and select the Empty Application and click Finish. (b) You will now have three files in the Project Explorer panel (counter sw, counter sw bsp and led wrapper hw platform 0). (c) Using your favorite editor, create a file called lab2a.c. Type the C code shown below in your file and save it in your lab2 directory. # i n c l u d e <x p a r a m e t e r s. h> # i n c l u d e <xgpio. h> # i n c l u d e <x s t a t u s. h> # i n c l u d e < x i l p r i n t f. h> / D e f i n i t i o n s / # d e f i n e GPIO DEVICE ID XPAR LED DEVICE ID / GPIO d e v i c e t h a t LEDs are c o n n e c t e d t o / # d e f i n e WAIT VAL 10000000 i n t d e l a y ( void ) ; i n t main ( ) { i n t c o u n t ; i n t count masked ; XGpio l e d s ; ECEN 449 7

8 Laboratory Exercise #2 i n t s t a t u s ; } s t a t u s = X G p i o I n i t i a l i z e (& l e d s, GPIO DEVICE ID ) ; X G p i o S e t D a t a D i r e c t i o n (& l e d s, 1, 0 x00 ) ; i f ( s t a t u s!= XST SUCCESS ) { x i l p r i n t f ( I n i t i a l i z a t i o n f a i l e d ) ; } c o u n t =0; while ( 1 ) { count masked = c o u n t & 0xF ; X G p i o D i s c r e t e W r i t e (& l e d s, 1, count masked ) ; x i l p r i n t f ( Value of LEDs = 0x%x\n\ r, count masked ) ; d e l a y ( ) ; c o u n t ++; } return ( 0 ) ; i n t d e l a y ( void ) { v o l a t i l e i n t d e l a y c o u n t =0; while ( d e l a y c o u n t < WAIT VAL) d e l a y c o u n t ++; return ( 0 ) ; } (d) Look through the code you just wrote and try to understand what exactly is going on. Notice we include the xparameters.h, xstatus.h, and xgpio.h header files. Open up these files from the Outline panel to the right of the window and understand what they provide. At the end of the lab, you will find questions on these files. (e) In the project explorer, expand counter sw, right click on src and select import. In the import window expand General, select File System, and click Next. Click Browse and select the folder where you saved the lab2a.c file and click OK. Select the lab2a.c file from the import window and click Finish. (f) Now we have the software application ready. Connect the FPGA and switch it ON. In the SDK, click Xilinx Tools and select Program FPGA. Next, the Program FPGA window will appear and select Program to program the the bitstream file generated in Vivado on to the FPGA. A warning will appear indicating that there is no PS in the design. PS is short for processing system which represents the ARM Cortex Processor in the ZYBO board. In this lab, the Microblaze processor is used which is implemented completely on the FPGA, and hence it is called a soft processor. Click OK on the message to program the FPGA. (g) The next step is to run the C application on the system. Click Run, and select Run Configuration. In the Run Configuration window, select Xilinx C/C++ Application(GDB). Click 8 ECEN 449

Laboratory Exercise #2 9 on the icon which resembles a document with a + sign on top left corner of the window to create a configuration file. Name the configuration(eg. led sw) and in the application tab, select Browse in the Project Name field and select the counter sw. In the STDIO connection, check Connect STDIO to Console. Select JTAG UART as Port. Click on Apply and select Run to deploy the program to the FPGA. Figure 7: Run Configuration (h) If everything is correct, you should now be able to see the LEDs glowing in the order from 0 to 15 and the output from the printf statements on the console in the SDK. NOTE: For the purpose of debugging stop the program by entering stop on the XMD console and re-run the program. The XMD console can be found under Xilinx Tools. Demonstrate your progress to the TA. Deliverables 1. [4 points.] Demonstrate your work to the TA after downloading the bitstream for the design created using the steps provided in the manual. Add comments to your C code and the modified portion of the XDC file and include them in your lab write-up. 2. [5 points.] Add an 8-bit GPIO IP block to your system and connect the lower 4-bits to the switches and the upper 4-bits to the push buttons on the ZYBO board (all bits should be inputs). Then, develop software to implement the following functionality: Your program should keep track of a COUNT value. When the push button 0 is held down, the COUNT should increment at approximately 1 Hz. When push button 1 is held down COUNT should decrement at 1 HZ. When the push button 2 is held down, the status ECEN 449 9

10 Laboratory Exercise #2 Hints: of the switches should be displayed. When the push button 4 is pressed, COUNT should be displayed on the LEDs. The console should display the current action and LEDs value. Be sure to demo this to your TA. Skim through the user manual for the ZYBO board and Master XDC file to determine the pin assignments for additional signals. The user manual may be found on the course website. Do not forget to add the DIP switches and push buttons to your XDC file before generating the netlist. Your source code must detect a change on the push buttons and DIP switches and react accordingly. When a change is detected, print the current action and LEDs value to the terminal window. Also, print to the terminal everytime the LEDs value changes. You must regenerate the bitstream after completing the design and contraints in order for the switches and buttons to appear in the xparameters.h file. 3. [5 points.] Correct format including an Introduction, Procedure, Results, and Conclusion. 4. [2 points.] The output of the TCL console from the part 2 demo. 5. [4 points.] Answer the following questions: (a) In the first part of the lab, we created a delay function by implementing a counter. The goal was to update the LEDs approximately every second as we did in the previous lab. Compare the count value in this lab to the count value you used as a delay in the previous lab. If they are different, explain why? Can you determine approximately how many clock cycles are required to execute one iteration of the delay for-loop? If so, how many? (b) Why is the count variable in our software delay declared as volatile? (c) What does the while(1) expression in our code do? (d) Compare and contrast this lab with the previous lab. Which implementation do you feel is easier? What are the advantages and disadvantages associated with a purely software implementation such as this when compared to a purely hardware implementation such as the previous lab? 10 ECEN 449