Hello,
I’ve recently begun working with the Pynq Z2 board, utilizing a simple example that involves adding two scalars. Below is the C code for this scalar addition, which I synthesized in Vitis HLS.
void add_ip(int a, int b, int* c) {
#pragma HLS INTERFACE s_axilite port=a
#pragma HLS INTERFACE s_axilite port=b
#pragma HLS INTERFACE s_axilite port=c
#pragma HLS INTERFACE s_axilite port=return
*c = a + b;
}
After synthesizing the code, I instantiated the IP block in Vivado IP Integrator. You can view the block design in the attached picture.
Next, I instantiated the Overlay, initialized the scalars, and attempted to read the result using the following code:
from pynq import Overlay
ol = Overlay("add_ip.bit")
add_ip = ol.add_ip_0
add_ip.write(0x10, 4) #set the value of a
add_ip.write(0x18, 8) #set the value of b
add_ip.read(0x20) #read the value of c
I’m encountering incorrect results(add_ip.read(0x20) gives me 0). Can somebody assist me in understanding why I’m not getting the correct result?
Hi @marioruiz
Thanks for your reply.
I’ve just observed that when I use " ap_ctrl_none " interface for port return I get the correct value but when I use “s_axilite” interface for return port I always get the value of 0.
This is the output of add_ip.register_map
:
RegisterMap {
CTRL = Register(AP_START=0, AP_DONE=0, AP_IDLE=1, AP_READY=0, RESERVED_1=0, AUTO_RESTART=0, RESERVED_2=0, INTERRUPT=0, RESERVED_3=0),
GIER = Register(Enable=0, RESERVED=0),
IP_IER = Register(CHAN0_INT_EN=0, CHAN1_INT_EN=0, RESERVED_0=0),
IP_ISR = Register(CHAN0_INT_ST=0, CHAN1_INT_ST=0, RESERVED_0=0),
a = Register(a=write-only),
b = Register(b=write-only),
c = Register(c=0),
c_ctrl = Register(c_ap_vld=0, RESERVED=0)
}
Isn’t it because AP_IDLE=1
and AP_START=0
?
I’ve just observed that when I use " ap_ctrl_none " interface for port return I get the correct value but when I use “s_axilite” interface for return port I always get the value of 0.
If you do not use “ap_ctrl_none”, you need to start the IP using the CTRL register.
Mario
Thank you @marioruiz.
My problem’s solved.
1 Like