• XILINX FFT IP仿真 (二)


    较上次的仿真,这次我们增加了FFT计算的长度到64点,使用MATLAB产生波形的64采样点的值存储在单口ROM中,观察仿真结果。

    一Matlab 生成*.coe文件的方法(借用他人的方法)

    x=0:1:63;%64个点,此处点数改变,波形数据点数改变

    Y=round(299*sin(2*pi*x/32))+300;%圆整每个点对应的值,且最大幅值是600.注:此处可以换成其他波形公式即可,如方波、三角波、锯齿波

    A=[x;Y]; %求正弦值矩阵

    fid=fopen ('E:\graduation project\FFT\fftcore\data.coe','w');%coe存放在路径

    fprintf(fid,' MEMORY_INITIALIZATION_RADIX=10;\r\n MEMORY_INITIALIZATION_VECTOR=\r\n');

    fprintf (fid,'%d,\r\n',Y); %输出Y的值

    fclose (fid ); %关闭

    stem ( x,Y)%绘出正弦波

    二 ISE 里面的顶层文件:

    module fftcore

       (

    input wire clk,

    input wire [15:0]  xn_im,

    input wire fwd_inv_we, fwd_inv, start,

    output wire  rfd,   dv, done, busy, edone,

    output wire [5:0] xk_index, xn_index,

    output wire [15:0] xn_re,

    output wire [22:0] xk_re, xk_im

        );

       // delay the xn_index for three clock periods to match the timing :2 or 3 ?

    reg [5:0]  tmp1, tmp2;

    always @(posedge clk)

      begin

    tmp1 <= xn_index;

    tmp2 <= tmp1;

    end

      fft64 unit0

      (

       .fwd_inv_we(fwd_inv_we),

    .rfd(rfd),

    .start(start),

    .fwd_inv(fwd_inv),

    .dv(dv),

    .done(done),

    .clk(clk),

    .busy(busy),

    .edone(edone),

    .xn_re(xn_re),

    .xk_im(xk_im),

    .xn_index(xn_index),

    .xk_re(xk_re),

    .xn_im(xn_im),

    .xk_index(xk_index)

      );

       rom unit1(

    .clka(clk),

    .addra(tmp2),

    .douta(xn_re));

    endmodule

    三。仿真文件仍不变。

    产生的仿真结果截图:

    四将结果与MATLAB的计算结果对比:

    x=0:1:63;%64个点,此处点数改变,波形数据点数改变 Y=round(299*sin(2*pi*x/32))+300; s=fft(Y,64); stem(x,s) >> s

    s =

      1.0e+004 *

      Columns 1 through 6

       1.9200                  0                  0 - 0.9562i        0                  0                  0        

      Columns 7 through 12

            0 + 0.0005i        0                  0                  0                  0 + 0.0007i        0        

      Columns 13 through 18

            0                  0                  0 + 0.0000i        0                  0                  0        

      Columns 19 through 24

            0 - 0.0001i        0                  0                  0                  0 + 0.0007i        0        

      Columns 25 through 30

            0                  0                  0 - 0.0005i        0                  0                  0        

      Columns 31 through 36

            0 - 0.0005i        0                  0                  0                  0 + 0.0005i        0        

      Columns 37 through 42

            0                  0                  0 + 0.0005i        0                  0                  0        

      Columns 43 through 48

            0 - 0.0007i        0                  0                  0                  0 + 0.0001i        0        

      Columns 49 through 54

            0                  0                  0 - 0.0000i        0                  0                  0        

      Columns 55 through 60

            0 - 0.0007i        0                  0                  0                  0 - 0.0005i        0        

      Columns 61 through 64

            0                  0                  0 + 0.9562i        0        

    OPTIMISM, PASSION & HARDWORK
  • 相关阅读:
    待解决问题集
    官方
    jsp 页面接收另一个页面传递过来的数据
    页面无法通过“${ctx}” 拿到值
    自定义 UsernamePasswordToken 报错 java.lang.ClassCastException: org.apache.shiro.authc.UsernamePasswordToken cannot be cast to
    springboot+mybatis map集合映射字段,当sql字段返回值为空时 不映射的问题
    java实现读写服务器文件
    前端模板免费下载网站
    The connection string contains invalid user information. If the username or password contains a colon (:) or an at-sign (@) then it must be urlencoded 解决方法
    springBoot -mongodb 小坑
  • 原文地址:https://www.cnblogs.com/hiramlee0534/p/5731177.html
Copyright © 2020-2023  润新知