This Answer Record demonstrates the flow to add a Custom AXI IP with interrupt support.
It also covers how to modify the generated HDL code, and how to create a useable device driver API.
Step 1: Create the Hardware platform.
In this example the KC705 is used, and a simple MicroBlaze system was created as shown below:
Use the Run Connection Automation to connect the clocks, and reset:
Step 2: Create the Custom IP.
To create the IP, click Tools > Create and Package IP.., and select Create a new AXI4 peripheral:
Name the IP. This will be the name seen in the IP catalog:
Click View Summary and Finish to create the IP.
This will create all of the HDL code, and an example driver that will be used later in this demo.
Step 3: Add the IP to the HW system
Use the Add IP icon in the block design to add the new IP:
Add the IP (and because this is a MicroBlaze, add an Interrupt controller IP) and a UART lite.
Use the Run Connection Automation to connect the system:
Step 4: Investigate the IP.
To investigate, simulate, or modify the new IP, right click on the IP and select Edit in IP Packager:
In this demo, we will be concentrating on the interrupt section. In the HDL code, the interrupt is simulated by a counter.
This can be seen on the lines below:
The counter is clocked using the ACLK that drives the AXI, so if this is 100Mhz, this interrupt will occur very quickly.
This can be adjusted to a bigger timer value and to generate an interrupt on roll-over:
Note: Before re-packaging the IP, open the S_AXI_INTR and see the AXI address decoding information as in the below example.
This will be used to create a custom driver.
Next Review and Package the IP, by clicking on the Re-Package Button
In the project, Reset Output Products, and Re-Generate Output Products, and Generate the Top level HDL wrapper.
Step 5: Implement the Design and Export to SDK
Step 7: Build the BSP using a custom driver
Next, we add the custom driver. To do this, go to Xilinx Tools > Repositories, and in the Local Repositories, point to the folder containing the drivers folder:
Click Rescan Repositories, and Apply, and Click OK to exit.
Next, build the BSP, File > New > Board Support Package
Verify that the driver is detected. This can be seen in the drivers > microblaze_0 tab:
Note: if the custom driver is not seen, ensure that the path is correct in the repository
Step 8: Create the Application
Now that the API has been created, and the driver is added, we can create our simple application.
To add the application, go to File > New > Application Project:
Use the existing BSP. Select Next, and choose an Empty Application and Finish.
Next, right click on the src folder in the project explorer hierarchy and select New > Source File:
This registers the interrupt, enables the interrupts on the interrupt controller, and uses the API created above to enable interrupts on the custom IP.
These is a simple handler, that will also ACK the interrupt using the API created above: