想系统的学习hls加速开发fpga,接下来会更新实战项目工程
如下时钟100MHz,频率控制字429,496,729.6。生成16位的10MHz正弦波信号。
void basicwave(ap_int<16> *sin, ap_int<16> *cos){#pragma HLS PIPELINE II=1 ap_int<16> cos_table[256] = {32768,32758,32728,32679,32610,32521,32413,32285,32138,31971,31785,31581,31357, 31114,30852,30572,30273,29956,29621,29269,28898,28511,28106,27684,27245,26790, 26319,25832,25330,24812,24279,23732,23170,22594,22005,21403,20787,20159,19519,
18868,18204,17530,16846,16151,15446,14732,14010,13278,12539,11793,11039,10278,
9512,8739,7961,7179,6392,5602,4808,4011,3211,2410,1607,804,0,-804,-1607,-2410,
-3211,-4011,-4808,-5602,-6392,-7179,-7961,-8739,-9512,-10278,-11039,-11793,-12539,
-13278,-14010,-14732,-15446,-16151,-16846,-17530,-18204,-18868,-19519,-20159,
-20787,-21403,-22005,-22594,-23170,-23732,-24279,-24812,-25330,-25832,-26319,
-26790,-27245,-27684,-28106,-28511,-28898,-29269,-29621,-29956,-30273,-30572,
-30852,-31114,-31357,-31581,-31785,-31971,-32138,-32285,-32413,-32521,-32610,
-32679,-32728,-32758,-32768,-32758,-32728,-32679,-32610,-32521,-32413,-32285,
-32138,-31971,-31785,-31581,-31357,-31114,-30852,-30572,-30273,-29956,-29621,
-29269,-28898,-28511,-28106,-27684,-27245,-26790,-26319,-25832,-25330,-24812,
-24279,-23732,-23170,-22594,-22005,-21403,-20787,-20159,-19519,-18868,-18204,
-17530,-16846,-16151,-15446,-14732,-14010,-13278,-12539,-11793,-11039,-10278,
-9512,-8739,-7961,-7179,-6392,-5602,-4808,-4011,-3211,-2410,-1607,-804,0,804,
1607,2410,3211,4011,4808,5602,6392,7179,7961,8739,9512,10278,11039,11793,12539,
13278,14010,14732,15446,16151,16846,17530,18204,18868,19519,20159,20787,21403,
22005,22594,23170,23732,24279,24812,25330,25832,26319,26790,27245,27684,28106,
28511,28898,29269,29621,29956,30273,30572,30852,31114,31357,31581,31785,31971,
32138,32285,32413,32521,32610,32679,32728,32758};
#pragma HLS RESOURCE variable=cos_table core=ROM_1P_BRAM
static ap_uint<32> phasesum = 0;
ap_uint<8> addr = phasesum.range(31 , 24);
phasesum = phasesum +FRQ_W;
*sin = cos_table[addr];
}
完整代码和仿真工程链接
https://download.csdn.net/download/weixin_37594197/88117149?spm=1001.2014.3001.5503