UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 

The Zynq PS/PL, Part Three: Adam Taylor’s MicroZed Chronicles Part 23

Xilinx Employee
Xilinx Employee
0 10 323K

By Adam Taylor

 

In the previous blog we used Vivado to create an AXI4 peripheral and to generate a bit file. Having created the hardware components of the design, we now need to export it to our SDK design so that we can write software to drive it.

 

The first step is to open the current implementation within Vivado and then export the hardware to SDK. (You will get a warning if SDK is already in use when you attempt to export the hardware.) If you don’t export the hardware to SDK, the next time you open SDK, the hardware definition and the board support package will need to be updated or you won’t be able to use them.

 

It is also necessary to update the repositories defined within the design to include the IP repository that contains the peripheral. To do this we select the Xilinx tools option and then repositories and add the new repositories as either local or global. For this example I have chosen local.

 

 

 Figure 1.jpg

 

 

 

Add in the peripheral directory created by Vivado and rescan the repositories. We can now re-build the project to recreate the files needed in the BSP to support software development.

 

Once the re-build is completed, open the xparameters.h file (within the BSP include files) to see the address space dedicated to the new AXI4 peripheral:

 

 

 Code Listing 1.jpg

 

 

The next step is to open the System.MSS file and customise the BSP to use the drivers generated in the peripheral creation process instead of the generic drivers.

 

 

 Figure 2.jpg

 

 

Re-building the project ensures that the driver files are loaded into the BSP. This is a very helpful step because these files also include a simple self-test program that you can use to test the that the software interface to the peripheral is correct before you start using it for more advanced things. Using this test program also demonstrates that we have correctly instantiated the Hardware in Vivado.

 

 

 Figure 3.jpg

 

 

Under the BSP included within the libsrc you will see a number of files for the new AXI4 peripheral. These files allow you to read and write to the peripheral just as you do with the native peripheral devices such as the XADC and GPIO, which we have been using previously in other blog instalments.

 

For this simple example, the file adams_perihperal.h  contains three functions we can use to drive the new peripheral. (Bonus points if you can spot my spelling mistake)

 

 

ADAMS_PERIHPERAL_mReadReg(BaseAddress, RegOffset)

 

ADAMS_PERIHPERAL_mWriteReg(BaseAddress, RegOffset, Data)

 

XStatus ADAMS_PERIHPERAL_Reg_SelfTest(void * baseaddr_p);

 

 

With the exception of the self-test function, the read and write functions are mapped to generic functions Xil_In32 and Xil_Out32, which are defined within Xil_io.h. However using the created functions enables more readable code as the peripheral being addressed is very clear.

 

For this example, we only have four registers within the peripheral so we will just use the self-test which will write and read to all of the registers and report a pass or fail. This test gives us confidence we have got the hardware and software environments correct and we can go on to more advanced functions once we define them in the peripheral module.

 

 Code Listing 2.jpg

 

 

In the next blog we will be looking at how we can add in some functionality to the peripheral using VHDL code to offload functions from the Processing System and improve system performance.

 

 

 

Please see the previous entries in this MicroZed series by Adam Taylor:

 

The Zynq PS/PL, Part Two: Adam Taylor’s MicroZed Chronicles Part 22

 

The Zynq PS/PL, Part One: Adam Taylor’s MicroZed Chronicles Part 21

 

Introduction to the Zynq Triple Timer Counter Part Four: Adam Taylor’s MicroZed Chronicles Part 20

 

Introduction to the Zynq Triple Timer Counter Part Three: Adam Taylor’s MicroZed Chronicles Part 19

 

Introduction to the Zynq Triple Timer Counter Part Two: Adam Taylor’s MicroZed Chronicles Part 18

 

Introduction to the Zynq Triple Timer Counter Part One: Adam Taylor’s MicroZed Chronicles Part 17

 

The Zynq SoC’s Private Watchdog: Adam Taylor’s MicroZed Chronicles Part 16

 

Implementing the Zynq SoC’s Private Timer: Adam Taylor’s MicroZed Chronicles Part 15

 

MicroZed Timers, Clocks and Watchdogs: Adam Taylor’s MicroZed Chronicles Part 14

 

More About MicroZed Interrupts: Adam Taylor’s MicroZed Chronicles Part 13

 

MicroZed Interrupts: Adam Taylor’s MicroZed Chronicles Part 12

 

Using the MicroZed Button for Input: Adam Taylor’s MicroZed Chronicles Part 11

 

Driving the Zynq SoC's GPIO: Adam Taylor’s MicroZed Chronicles Part 10

 

Meet the Zynq MIO: Adam Taylor’s MicroZed Chronicles Part 9

 

MicroZed XADC Software: Adam Taylor’s MicroZed Chronicles Part 8

 

Getting the XADC Running on the MicroZed: Adam Taylor’s MicroZed Chronicles Part 7

 

A Boot Loader for MicroZed. Adam Taylor’s MicroZed Chronicles, Part 6 

 

Figuring out the MicroZed Boot Loader – Adam Taylor’s MicroZed Chronicles, Part 5

 

Running your programs on the MicroZed – Adam Taylor’s MicroZed Chronicles, Part 4

 

Zynq and MicroZed say “Hello World”-- Adam Taylor’s MicroZed Chronicles, Part 3

 

Adam Taylor’s MicroZed Chronicles: Setting the SW Scene

 

Bringing up the Avnet MicroZed with Vivado

 

 

 

 

Tags (2)
10 Comments