How I can use HSI to create a driver for a custom IP?
This Answer Record describes how to use the HSI tool to create a custom driver to populate the xparameters.h file in SDK.
Step 1: Create the IP in IP Packager
In the following example a simple AXI slave IP is created and connected to the MPSoC device:
Step 2: Explore the Hardware design using HSI
Exported hardware designs (HDF files) can be inspected using HSI, so the tool can be used within the driver generation Tcl to customize it according to the design.
Launch the shell from SDK and call HSI to get the command prompt.
$ hsi
hsi% open_hw_design system.hdf
hsi% get_cells *
hsi% list_property [get_cells myip_0]
get_pins -of_objects [get_cells myip_0]
get_pins -of_objects [get_cells myip_0] -filter TYPE==clk
list_property [get_pins s00_axi_aclk]
get_property CLK_FREQ [get_pins s00_axi_aclk]
hsi% set int_pin [get_pins -of_objects [get_cells myip_0] -filter TYPE==INTERRUPT]
irq
hsi% set intc_type [:hsi::utils::get_connected_intr_cntrl myip_0 $int_pin]
For more information on the HSI command, see (UG1138)
Step 3: Update the driver Tcl file
Modify the Tcl script for the custom IP within the hardware platform driver as development flow.
The changes made in the driver will only be applicable for those BSP generated based on the hardware project, but once stable, the changes can be exported to the IP repository created in Vivado.
proc generate {drv_handle} {
xdefine_include_file $drv_handle "xparameters.h" "myip" "NUM_INSTANCES" "DEVICE_ID" "C_S00_AXI_BASEADDR" "C_S00_AXI_HIGHADDR"
#Custom Diver handler
set periph_name [get_property IP_NAME [get_cells $drv_handle]]
set found [string first $periph_name $drv_handle]
if {$found != -1} {
set ip_name [string toupper [string range $drv_handle $found [string length $drv_handle]]]
} else {
set ip_name [string toupper $drv_handle]
}
set file_handle [::hsi::utils::open_include_file xparameters.h]
puts $file_handle "/* This is from the custom addition $ip_name */"
set clk_pins [get_pins -of_objects [get_cells $drv_handle] -filter TYPE==clk]
for {set i 0} {$i < [llength $clk_pins]} {incr i} {
set clk_freq [get_property CLK_FREQ [lindex $clk_pins $i]]
set clk_name [string toupper [get_property NAME [lindex $clk_pins $i]]]
puts $file_handle "\#define XPAR_${ip_name}_${clk_name} $clk_freq"
}
set int_pin [get_pins -of_objects [get_cells $drv_handle] -filter TYPE==INTERRUPT]
set intc_periph_type [::hsi::utils::get_connected_intr_cntrl myip_0 $int_pin]
if {$intc_periph_type != ""} {
puts $file_handle "\#define XPAR_${ip_name}_INTERRUPT_CONNECTED 1"
} else {
puts $file_handle "\#define XPAR_${ip_name}_INTERRUPT_CONNECTED 0"
}
close $file_handle
}
The custom code in the Tcl script does the following:
Step 4: Test the BSP
Once the Tcl script is ready, a BSP project can be created to check if the driver for the custom IP is been generated property.
The xparameters.h file of the BSP includes the customized values:
Step 5: Integrate in the Vivado repository
In order to integrate the custom driver into the Vivado repository, just copy the Tcl script into the ip_repo folder where the IP is stored.
This will trigger an IP change within Vivado, so update the design to integrate the new driver.
This way the new script will be used each time a hardware is exported with the custom IP.
Answer Number | Answer Title | Version Found | Version Resolved |
---|---|---|---|
66297 | SDK - Design Assistant | N/A | N/A |
AR# 64980 | |
---|---|
Date | 08/20/2018 |
Status | Active |
Type | Solution Center |
Tools |