Creating a C-Callable Library

The SDSoC tools include a command line utility, sdx_pack, that encapsulates internal data files required to incorporate RTL IP into SDSoC application projects.

Usage

sdx_pack -header<header.h/pp >-ip <component.xml> [-param <name>="value"] [configuration options]

Configuration Options

Description Option
-add-ip-repo No arguments, add IP repository to library
-header <header.h/.hpp> (required) Header file with function prototype
-ip<component.xml> (required) IP packed by the Vivado® IP integrator
-parm<name>=value IP parameter values
-func <function_name> (required) Function name
-control<protocol> [=<port> [:offset]] (required) IP control protocol options:
  • AP_CTRL
  • AXI
  • none
-map<sw_name>=<hw_name>:direction[:offset[aximm_name>:direction]] (required) SW function argument to IP port mapping:<SW_Name>=HW_Name>:direction[:offset[<aximm_name>:direction]
-target-cpu<cpu_type> Specify target CPU:
  • cortex-a9
  • cortex-a53
  • cortex-r5
  • microblaze
-target-family <board_family>

Specify target board family; for example, zynq or zynquplus

-target-os<name>

Specify target Operating System

  • linux (default)
  • standalone(bare-metal)
-stub<file.c/.cpp> Stub file with entry points; can be multiple functions mapping to a single IP.
-verbose Print verbose output to STDOUT.
-version Print the sdx_pack version information to STDOUT.
--help Display information about this command.

Example:

sdx_pack -header count.hpp -ip ../ip/component.xml -func count \
-control AXI=S_AXI:0 -target-cpu cortex-a9 -map start_value=S_AXI:in:0x8 -map return=S_AXI:out:4 -target-os standalone
Where:
  • The count.hpp specifies the header file defining the function prototype for the count function.
  • The component.xml of the IP generates the packaged Vivado IP for SDx.
  • The -control specifies the IP control protocol.
  • The –map specifies the mapping of an argument from the software function to a port on the Vivado IP. Notice the option is used twice in the example above to map start_value and return arguments to IP ports.
  • The –target-cpu option specifies the target operating system.
The sdx_pack utility automatically generates:
  • <function_name>.o: Compiled object code for the specified function.
  • <function_name>.fcnmap.xml: mapping IP ports to function arguments
  • <function_name>.params.xml: IP parameters
  • stub.cpp: C++ file with entry points; can include multiple functions mapping to a single IP
Note: You will need to create an archive file (.a) of the sdx_pack compiled object code (.o) using an appropriate GNU tool chain utility, like arm-none-eabi-ar, so that the function can be linked to the appropriate IP during runtime. For multiple functions mapping to a single IP, currently sdx_pack has limited support, use sdslib instead.