取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
xusong666
Visitor
Visitor
156 次查看
注册日期: ‎02-01-2021

关于PYNQ复数累乘数据紊乱的wenti

这是我在hls试下呢复数乘法代码,复数采用自定义结构体实现,共计64位,在juoyter里·通过xlnk输入complex64的数据,但是输出结果不对

hls代码

#include "ap_int.h"
#include "hls_stream.h"
#include "ap_fixed.h"


typedef struct {
float rea;
float ima;
}my_data;

 

 

void StreamMul( my_data in1, my_data in2, my_data &out, int length)
{
#pragma HLS DATA_PACK variable=in2 field_level
#pragma HLS DATA_PACK variable=in1 field_level
#pragma HLS DATA_PACK variable=out field_level
#pragma HLS INTERFACE axis register both depth=50 port=out
#pragma HLS INTERFACE axis register both depth=50 port=in2
#pragma HLS INTERFACE axis register both depth=50 port=in1
float tmp1,tmp2,tmp3,tmp4;
for(unsigned int i=0; i<length; i++){
#pragma HLS LOOP_TRIPCOUNT min=1 max=65536
#pragma HLS PIPELINE
my_data cur1 = in1;
my_data cur2 = in2;

tmp1=cur1.rea*cur2.rea;
tmp2=cur1.ima*cur2.ima;
tmp3=cur1.rea*cur2.ima;
tmp4=cur1.ima*cur2.rea;
cur1.rea = tmp1-tmp2;
cur1.ima = tmp3+tmp4;
out=cur1;
}

}

 

 

 

jupyter代码

 

in1=np.array([1+2j,1+3j],dtype=np.complex64)
in2=np.array([1+2j,1+3j],dtype=np.complex64)

 

length=2
in_buffer1=xlnk.cma_array(shape=in1.shape,dtype=np.complex64)
in_buffer2=xlnk.cma_array(shape=in1.shape,dtype=np.complex64)
out_buffer=xlnk.cma_array(shape=in1.shape,dtype=np.complex64)

mul_ip.write(0x10,2)

np.copyto(in_buffer1,in1)
np.copyto(in_buffer2,in2)
print(out_buffer)

dma1.sendchannel.transfer(in_buffer1)
dma2.sendchannel.transfer(in_buffer2)
dma1.recvchannel.transfer(out_buffer)
in_buffer1.close()
in_buffer2.close()
out_buffer.close()

 

输入

[ 1.+2.j  1.+3.j]// 时各自变量自乘

输出结果

[  9.14767638e-41 +0.00000000e+00j   9.14767638e-41 +4.58280650e-41j]
0 项奖励
1 回复
wenchen
Moderator
Moderator
52 次查看
注册日期: ‎05-27-2018

Hi @xusong666 

PYNQ 板卡有自己的官方社区http://www.pynq.io/community.html,xlnk lib 里面我搜索了一下好像不支持这个数据类型dtype=np.complex64

你有没有看到使用了dtype=np.complex64的相关实例?

Wen

-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.


**~ Got a minute? Answer our Vitis HLS survey here! ~**


-------------------------------------------------------------------------
如果提供的信息能解决您的问题,请标记为“接受为解决方案”。
如果您认为帖子有帮助,请点击“奖励”。谢谢!
-------------------------------------------------------------------------------------------------
0 项奖励