Lab 2
Lab 2
Hardware
Introduction
This lab guides you through the process of adding additional IP to an existing processor system by using
Xilinx Platform Studio (XPS). You will add GPIO peripherals from the IP Catalog tab to interface to the
push buttons and DIP switches on the Atlys Board. At the end of the lab, you will generate the bitstream
and test the peripherals in hardware.
Objectives
After completing this lab, you will be able to:
Add additional IP to a hardware design
Update ucf file to support external ports of the added IP
Setup some of the compiler settings
Procedure
This lab is separated into steps that consist of general overview statements that provide information on
the detailed instructions that follow. Follow these detailed instructions to progress through the lab.
This lab comprises 6 primary steps: You will open the project, add and configure GPIO peripherals in the
system, make ports external, analyze the MHS file, create TestApp application in SDK, and, finally, verify
the design in hardware.
Design Description
The purpose of this lab exercise is to extend the hardware design (Figure 1) created in Lab 1
Step 6:
Verify the
design in
hardware
1-1-1. Create a lab2 folder in the c:\xup\embedded\labs directory and copy the contents from lab1 to
lab2 or copy the content of the labsolution/lab1 folder to lab2
1-1-2. Open XPS by selecting Start > All Programs > Xilinx Design Tools > ISE Design Suite 14.2 >
EDK > Xilinx Platform Studio.
2-1-1. Select the IP Catalog tab in the left window and click on plus sign next to General Purpose IO
entry to view the available cores under it.
Figure 2. IP Catalog
2-1-2. Double-click on the AXI General Purpose IO core twice to add an instance to the System
Assembly View, and click Yes to add.
2-1-3. In the properties form, change the instance name to dip. Expand Channel 1 parameters field,
change width to 8 and also make Input only field to 1 as the device is input only.
Notice that the peripheral can be configured for two channels, but, since we want to use only one
channel without interrupt, leave the GPIO Supports Interrupts and Enable Channel 2
unchecked.
2-1-4. Click OK twice to add the instance and connect to the processor system. Note that the address
is automatically assigned as the peripheral is connected to the processor system.
2-1-5. Similarly, add another instance of the GPIO peripheral, naming it as push, making it 5 bits wide,
and setting it as input only.
At this point, the System Assembly View should look like the following:
Note that the addresses are automatically assigned to the added peripherals.
You can manually assign the base address and size of your peripherals or have XPS generate
the addresses for you.
3-1-1. Select the Ports tab, expand dip and push port connections under by clicking the plus sign of
(IO_IF) gpio_0.
Notice that there are four ports of the GPIO peripheral - _I for input only, _O for output only, _T
for making it tristate, and _IO for input/output. By default _IO port is connected and made
external.
3-1-2. Right-click on the GPIO_IO port of the dip and push instances and select No Connection to
remove the existing connections.
3-1-3. Right-click on the GPIO_I port of the dip and push instances and select Make External to make
the connections.
Figure 7. GPIO_I port connections added to the dip and push instances
3-1-4. Double-click on the system.ucf file under the Project tab and add the following code to assign
pins to push buttons and dip switches (The constraints are provided in lab2.ucf file in c:\xup\
embedded\sources directory. Copy it from there and add them in your ucf file).
Study the external ports sections and answer the following questions
Question 1
Complete the following:
Number of external ports: 22 26
Number of external ports that are output: 13 13
Number of external ports that are input: 6 6
Number of external ports that are bidirectional: 3 7
Question 2
Review the entire MHS file
List the instances to which the clk_100_0000MHzMMCM0 is connected:
Slowest_sync_clk, LMB_CLK, LMB_CLK, CLK, S_AXI_ACLK, CLKOUT0, INTERCONNECT_ACLK,
interconnect_aclk________________________________________________________________
_________ui_clk, s0_axi_aclk, interconnect_aclk , CLKOUT2,clk, LMD_clk
_____________________________________________________
List the instances connected to the AXI_0 interface instance:
interconnect_aclk, INTERCONNECT_ARESETN
________________________________________________________________
________________________________________________________________
Question 3
Review the memory map in the Addresses tab of the System Assembly View
Draw the address map of the system, providing instance names
0x00000000–0x00001fff dlmb, llmb
unused
5-1-1. Start SDK by clicking Project > Export Hardware Design to SDK or click on left Navigator.
5-1-2. Click on Export & Launch SDK button with default settings.
Since we have not generated hardware bitstream and the default option is selected, a hardware
bitstream will be generated and then SDK will be open
5-1-4. In SDK, select File > New > Xilinx Board Support Package.
5-1-5. Click Finish with default settings (with standalone operating system).
This will open the Software Platform Settings form showing the OS and libraries selections.
5-1-6. Click OK to accept the default settings, as we want to create a standalone_bsp_0 software
platform project without requiring any additional libraries support.
5-1-7. The library generator will run in the background and will create xparameters.h file in the C:\xup\
embedded\labs\lab2\SDK\SDK_Export\standalone_bsp_0\microblaze_0\include\
directory.
5-2. Create an empty application project and import the provided lab2.c file.
5-2-1. Select Standalone_bsp_0 in the project view, right-click, and select New > Project.
5-2-3. Select Empty Application in the Select Project Template window, and enter TestApp as the
Project Name and click Next.
5-2-4. Select Target an existing Board Support Package option, then select standalone_bsp_0, and
click Finish.
The TestApp project will be created in the Project Explorer window of SDK.
5-2-5. Select TestApp in the project view, right-click, and select Import.
5-3. Set build setting to no optimization and generate linker script which targets
the application to the ilmb and dlmb memories as well as have 400 bytes of
heap and stack each
5-3-1. Select TestApp project, right-click, and select C/C++ Build Settings
5-3-2. Select Optimization option of the MicroBlaze gcc compiler in the Tool Settings tab and make
sure that the Optimization Level is set to None (-O0) as we have a software loop acting as a
delay loop and we do not want it to be optimized away.
5-3-4. Target everything to ilmb and dlmb memories, and set heap and stack to 400 bytes each.
5-3-5. Click on the Generate button, and click Yes to overwrite the existing linker script file.
6-1-2. Select the tab. If it is not visible then select Window > Show view > Terminal.
6-1-3. Click on and select appropriate COM port (depends on your computer), and configure it with
115200 baud rate.
You should see the output similar to the following in the terminal window.
Conclusion
GPIO peripherals were added from the IP catalog and connected to the MicroBlaze system that was
created in the first lab. The peripherals were configured and external FPGA connections were
established. Pin location constraints were made in the UCF file to connect the peripherals to push
buttons and DIP switches on the Atlys board.
Answers
1. Complete the following:
Number of external ports: 24
Number of external ports that are output: 12
Number of external ports that are input: 5
Number of external ports that are bidirectional: 7
3. Draw the address map of the system, providing instance names. You can sort the peripheral
addresses by base address from the Addresses tab.
unused
# ##############################################################################
# Created by Base System Builder Wizard for Xilinx EDK 14.2 Build EDK_P.28xd
# Wed Jul 25 08:27:29 2012
# Target Board: digilent atlys Rev C
# Family: spartan6
# Device: xc6slx45
# Package: csg324
# Speed Grade: -2
# ##############################################################################
PARAMETER VERSION = 2.1.0
BEGIN proc_sys_reset
PARAMETER INSTANCE = proc_sys_reset_0
PARAMETER HW_VER = 3.00.a
PARAMETER C_EXT_RESET_HIGH = 0
PORT MB_Debug_Sys_Rst = proc_sys_reset_0_MB_Debug_Sys_Rst
PORT Dcm_locked = proc_sys_reset_0_Dcm_locked
PORT MB_Reset = proc_sys_reset_0_MB_Reset
PORT Slowest_sync_clk = clk_100_0000MHzPLL0
PORT Interconnect_aresetn = proc_sys_reset_0_Interconnect_aresetn
PORT Ext_Reset_In = RESET
PORT BUS_STRUCT_RESET = proc_sys_reset_0_BUS_STRUCT_RESET
END
BEGIN lmb_v10
PARAMETER INSTANCE = microblaze_0_ilmb
PARAMETER HW_VER = 2.00.b
www.xilinx.com/university Atlys 2-17
[email protected]
© Copyright 2012 Xilinx
Hardware Lab Workbook
BEGIN lmb_bram_if_cntlr
PARAMETER INSTANCE = microblaze_0_i_bram_ctrl
PARAMETER HW_VER = 3.10.a
PARAMETER C_BASEADDR = 0x00000000
PARAMETER C_HIGHADDR = 0x00001fff
BUS_INTERFACE SLMB = microblaze_0_ilmb
BUS_INTERFACE BRAM_PORT = microblaze_0_i_bram_ctrl_2_microblaze_0_bram_block
END
BEGIN lmb_v10
PARAMETER INSTANCE = microblaze_0_dlmb
PARAMETER HW_VER = 2.00.b
PORT SYS_RST = proc_sys_reset_0_BUS_STRUCT_RESET
PORT LMB_CLK = clk_100_0000MHzPLL0
END
BEGIN lmb_bram_if_cntlr
PARAMETER INSTANCE = microblaze_0_d_bram_ctrl
PARAMETER HW_VER = 3.10.a
PARAMETER C_BASEADDR = 0x00000000
PARAMETER C_HIGHADDR = 0x00001fff
BUS_INTERFACE SLMB = microblaze_0_dlmb
BUS_INTERFACE BRAM_PORT = microblaze_0_d_bram_ctrl_2_microblaze_0_bram_block
END
BEGIN bram_block
PARAMETER INSTANCE = microblaze_0_bram_block
PARAMETER HW_VER = 1.00.a
BUS_INTERFACE PORTA = microblaze_0_i_bram_ctrl_2_microblaze_0_bram_block
BUS_INTERFACE PORTB = microblaze_0_d_bram_ctrl_2_microblaze_0_bram_block
END
BEGIN microblaze
PARAMETER INSTANCE = microblaze_0
PARAMETER HW_VER = 8.40.a
PARAMETER C_INTERCONNECT = 2
PARAMETER C_USE_BARREL = 1
PARAMETER C_USE_FPU = 0
PARAMETER C_DEBUG_ENABLED = 1
PARAMETER C_ICACHE_BASEADDR = 0xa8000000
PARAMETER C_ICACHE_HIGHADDR = 0xafffffff
PARAMETER C_USE_ICACHE = 1
PARAMETER C_CACHE_BYTE_SIZE = 8192
PARAMETER C_ICACHE_ALWAYS_USED = 1
PARAMETER C_DCACHE_BASEADDR = 0xa8000000
PARAMETER C_DCACHE_HIGHADDR = 0xafffffff
PARAMETER C_USE_DCACHE = 1
PARAMETER C_DCACHE_BYTE_SIZE = 8192
PARAMETER C_DCACHE_ALWAYS_USED = 1
BUS_INTERFACE ILMB = microblaze_0_ilmb
BUS_INTERFACE DLMB = microblaze_0_dlmb
BUS_INTERFACE M_AXI_DP = AXIlite_0
BUS_INTERFACE M_AXI_DC = AXI_0
BUS_INTERFACE M_AXI_IC = AXI_0
Atlys 2-18 www.xilinx.com/university
[email protected]
© Copyright 2012 Xilinx
Lab Workbook Hardware
BEGIN mdm
PARAMETER INSTANCE = debug_module
PARAMETER HW_VER = 2.10.a
PARAMETER C_INTERCONNECT = 2
PARAMETER C_USE_UART = 1
PARAMETER C_BASEADDR = 0x41400000
PARAMETER C_HIGHADDR = 0x4140ffff
BUS_INTERFACE S_AXI = AXIlite_0
BUS_INTERFACE MBDEBUG_0 = microblaze_0_debug
PORT Debug_SYS_Rst = proc_sys_reset_0_MB_Debug_Sys_Rst
PORT S_AXI_ACLK = clk_100_0000MHzPLL0
END
BEGIN clock_generator
PARAMETER INSTANCE = clock_generator_0
PARAMETER HW_VER = 4.03.a
PARAMETER C_EXT_RESET_HIGH = 0
PARAMETER C_CLKIN_FREQ = 100000000
PARAMETER C_CLKOUT0_FREQ = 600000000
PARAMETER C_CLKOUT0_GROUP = PLL0
PARAMETER C_CLKOUT0_BUF = FALSE
PARAMETER C_CLKOUT1_FREQ = 600000000
PARAMETER C_CLKOUT1_PHASE = 180
PARAMETER C_CLKOUT1_GROUP = PLL0
PARAMETER C_CLKOUT1_BUF = FALSE
PARAMETER C_CLKOUT2_FREQ = 100000000
PARAMETER C_CLKOUT2_GROUP = PLL0
PORT LOCKED = proc_sys_reset_0_Dcm_locked
PORT CLKOUT2 = clk_100_0000MHzPLL0
PORT RST = RESET
PORT CLKOUT0 = clk_600_0000MHzPLL0_nobuf
PORT CLKOUT1 = clk_600_0000MHz180PLL0_nobuf
PORT CLKIN = GCLK
END
BEGIN axi_interconnect
PARAMETER INSTANCE = AXIlite_0
PARAMETER HW_VER = 1.06.a
PARAMETER C_INTERCONNECT_CONNECTIVITY_MODE = 0
PORT INTERCONNECT_ARESETN = proc_sys_reset_0_Interconnect_aresetn
PORT INTERCONNECT_ACLK = clk_100_0000MHzPLL0
END
BEGIN axi_interconnect
PARAMETER INSTANCE = AXI_0
PARAMETER HW_VER = 1.06.a
PORT interconnect_aclk = clk_100_0000MHzPLL0
PORT INTERCONNECT_ARESETN = proc_sys_reset_0_Interconnect_aresetn
END
BEGIN axi_uartlite
PARAMETER INSTANCE = RS232_Uart_1
PARAMETER HW_VER = 1.02.a
www.xilinx.com/university Atlys 2-19
[email protected]
© Copyright 2012 Xilinx
Hardware Lab Workbook
BEGIN axi_s6_ddrx
PARAMETER INSTANCE = MCB_DDR2
PARAMETER HW_VER = 1.06.a
PARAMETER C_MCB_RZQ_LOC = L6
PARAMETER C_MCB_ZIO_LOC = C2
PARAMETER C_MEM_TYPE = DDR2
PARAMETER C_MEM_PARTNO = EDE1116AXXX-8E
PARAMETER C_MEM_BANKADDR_WIDTH = 3
PARAMETER C_MEM_NUM_COL_BITS = 10
PARAMETER C_SKIP_IN_TERM_CAL = 0
PARAMETER C_S0_AXI_ENABLE = 1
PARAMETER C_INTERCONNECT_S0_AXI_MASTERS = microblaze_0.M_AXI_DC &
microblaze_0.M_AXI_IC
PARAMETER C_MEM_DDR2_RTT = 50OHMS
PARAMETER C_S0_AXI_STRICT_COHERENCY = 0
PARAMETER C_INTERCONNECT_S0_AXI_AW_REGISTER = 8
PARAMETER C_INTERCONNECT_S0_AXI_AR_REGISTER = 8
PARAMETER C_INTERCONNECT_S0_AXI_W_REGISTER = 8
PARAMETER C_INTERCONNECT_S0_AXI_R_REGISTER = 8
PARAMETER C_INTERCONNECT_S0_AXI_B_REGISTER = 8
PARAMETER C_S0_AXI_BASEADDR = 0xa8000000
PARAMETER C_S0_AXI_HIGHADDR = 0xafffffff
BUS_INTERFACE S0_AXI = AXI_0
PORT zio = zio
PORT rzq = rzq
PORT s0_axi_aclk = clk_100_0000MHzPLL0
PORT ui_clk = clk_100_0000MHzPLL0
PORT mcbx_dram_we_n = mcbx_dram_we_n
PORT mcbx_dram_udqs_n = mcbx_dram_udqs_n
PORT mcbx_dram_udqs = mcbx_dram_udqs
PORT mcbx_dram_udm = mcbx_dram_udm
PORT mcbx_dram_ras_n = mcbx_dram_ras_n
PORT mcbx_dram_odt = mcbx_dram_odt
PORT mcbx_dram_ldm = mcbx_dram_ldm
PORT mcbx_dram_dqs_n = mcbx_dram_dqs_n
PORT mcbx_dram_dqs = mcbx_dram_dqs
PORT mcbx_dram_dq = mcbx_dram_dq
PORT mcbx_dram_clk_n = mcbx_dram_clk_n
PORT mcbx_dram_clk = mcbx_dram_clk
PORT mcbx_dram_cke = mcbx_dram_cke
PORT mcbx_dram_cas_n = mcbx_dram_cas_n
PORT mcbx_dram_ba = mcbx_dram_ba
PORT mcbx_dram_addr = mcbx_dram_addr
PORT sysclk_2x = clk_600_0000MHzPLL0_nobuf
PORT sysclk_2x_180 = clk_600_0000MHz180PLL0_nobuf
PORT SYS_RST = proc_sys_reset_0_BUS_STRUCT_RESET
Atlys 2-20 www.xilinx.com/university
[email protected]
© Copyright 2012 Xilinx
Lab Workbook Hardware
BEGIN axi_gpio
PARAMETER INSTANCE = dip
PARAMETER HW_VER = 1.01.b
PARAMETER C_GPIO_WIDTH = 8
PARAMETER C_ALL_INPUTS = 1
PARAMETER C_BASEADDR = 0x40000000
PARAMETER C_HIGHADDR = 0x4000ffff
BUS_INTERFACE S_AXI = AXIlite_0
PORT S_AXI_ACLK = clk_100_0000MHzPLL0
PORT GPIO_IO_I = dip_GPIO_IO_I
END
BEGIN axi_gpio
PARAMETER INSTANCE = push
PARAMETER HW_VER = 1.01.b
PARAMETER C_GPIO_WIDTH = 5
PARAMETER C_ALL_INPUTS = 1
PARAMETER C_BASEADDR = 0x40040000
PARAMETER C_HIGHADDR = 0x4004ffff
BUS_INTERFACE S_AXI = AXIlite_0
PORT S_AXI_ACLK = clk_100_0000MHzPLL0
PORT GPIO_IO_I = push_GPIO_IO_I
END