问题
I have a custom IP with some design parameters. They are exposed from the IP so I can customize them when using the IP in a block design.
I want to be able to use those parameters inside my firmware code.
For example when using a simple GPIO there are several parameters exposed in the xparameters.h
header:
#define XPAR_GPIO_0_BASEADDR 0x41200000
#define XPAR_GPIO_0_HIGHADDR 0x4120FFFF
#define XPAR_GPIO_0_DEVICE_ID XPAR_GPIO_DEVICE_ID
#define XPAR_GPIO_0_INTERRUPT_PRESENT 0
#define XPAR_GPIO_0_IS_DUAL 0
Besides the base address of most interest is the IS_DUAL
parameter, that is set when instantiating the IP in a block design.
For my, custom IP, only the BASEADDR
and HIGHADDR
are exposed in the header.
So, the question is, is there a way to expose my custom parameters as well?
回答1:
The content of xparameters.h is generated by the TCL scripts in the software drivers for the IP. If you haven't created a driver, by default you'll get the generic driver which just adds those addresses to xparameters.h.
You can look at the gpio driver to get an idea of how to do what you want. It's located in the SDK install dir under data/embeddedsw/XilinxProcessorIPLib/drivers/gpio_v4_4
, and the TCL script is in there at data/gpio.tcl
. In that script, there's a generate function that runs when the BSP is generated, and you can add code there to do whatever you need, including outputting text to xparameters.h. The define_include_file
line is the one outputting all those parameters for GPIO cores.
You can use gpio or one of others as a reference for creating your own driver. Once you do that, add it to the repositories list in SDK and then modify your BSP configuration to use that driver for your IP instances. (Or it may select it automatically if you create a new BSP.)
来源:https://stackoverflow.com/questions/59990095/is-there-a-way-to-pass-a-design-parameter-from-a-custom-ip-to-software