We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 58632

2013.3 Vivado HLS - How dow I use generated driver C code to set/get non-integer variable types?


How do I use generated driver C code to set/get non-integer variable types?

See the following code section in cpp:

int caculate(float a, float *r1)
#pragma HLS INTERFACE ap_vld register port=r1
#pragma HLS RESOURCE variable=r1 core=AXI4LiteS metadata="-bus_bundle HLS_PERIPH_BUS"
#pragma HLS RESOURCE variable=a core=AXI4LiteS metadata="-bus_bundle HLS_PERIPH_BUS"
#pragma HLS RESOURCE variable=return core=AXI4LiteS metadata="-bus_bundle HLS_PERIPH_BUS"
 *r1 = 0.5f*a;
 return (a>0);

The generated driver contains the following functions to set "a" and get "r1":

void XCaculate_SetA(XCaculate *InstancePtr, u32 Data) {
    Xil_AssertVoid(InstancePtr != NULL);
    Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
    XCaculate_WriteReg(InstancePtr->Hls_periph_bus_BaseAddress, XCACULATE_HLS_PERIPH_BUS_ADDR_A_DATA, Data);
u32 XCaculate_GetR1(XCaculate *InstancePtr) {
    u32 Data;
    Xil_AssertNonvoid(InstancePtr != NULL);
    Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
    Data = XCaculate_ReadReg(InstancePtr->Hls_periph_bus_BaseAddress, XCACULATE_HLS_PERIPH_BUS_ADDR_R1_DATA);
    return Data;

There is a type mismatch between u32 and float.

If I use these functions directly with u32 or float type variables, the write and read values are not consistent with the expected float values.


The following conversion can be used when using these functions in SDK:

float a=3.0f,r1;
u32 ua,ur1;

AR# 58632
Date 03/25/2015
Status Active
Type General Article
  • Vivado Design Suite - 2013.3