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 HW platform.
Here 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:
Then add the Interrupt support:
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:
This will open a Vivado project and all of the IP source files will be added. Since we added interrupt support, we can see the S_AXI_INTR
In this demo, we will concentrating on the interrupt section. In the HDL code, the interrupt is simulated by a counter.
This can be seen on the lines below:
Here, the interrupt will occur if the 16 bit counter counts to 10, then stops.
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:
Save any changes. To verify, we can synthesize the design.
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 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:
Name your source file <file name>.c and OK. Below is a simple application example that can be used to test the interrupt on the custom IP.
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 ACK the interrupt using the API created above also.