FPGA使用sv生成虚拟单音数据

FPGA使用sv生成虚拟单音数据

之前一直使用matlab生成虚拟的数据,导出到txt或是coe文件中,再导入到fpga中进行仿真测试。

复杂的数据这样操作自然是必要的,但是平日使用正弦数据进行测试的话,这样的操作不免复杂,今日尝试使用systemverilog虚拟单音数据,并存入到txt文件。

systemverilog 复制代码
module top_tb(

  );

  localparam FRACTIONAL_BITS = 7;  // 7位小数,1位符号
  localparam SCALE = 1<<FRACTIONAL_BITS;
  logic signed [7:0] fixed_sin[0:9];
  real float_sin;

  int file;

  initial
  begin
    
    // 生成正弦数据
    for (int i = 0;i<10;i++)
    begin
      float_sin = $sin(2*3.1415926 *i/10);
      fixed_sin[i] = $rtoi(float_sin*SCALE);
      $display("i=%d, float_sin=%f, fixed_sin=%d",i,float_sin,fixed_sin[i]);
    end

    // 写入文件
    file = $fopen("../../../../fixed_sin.txt","w");
    $fdisplay(file,"虚拟生成的正弦数据:");

    for (int i = 0;i<10;i++)
    begin
      $fdisplay(file,"%d",fixed_sin[i]);
    end

    $fclose(file);

  end
endmodule
相关推荐
风_峰3 天前
Ubuntu Linux SD卡分区操作
嵌入式硬件·ubuntu·fpga开发
FPGA_Linuxer3 天前
FPGA 40 DAC线缆和光模块带光纤实现40G UDP差异
网络协议·fpga开发·udp
风_峰4 天前
Petalinux相关配置——ZYNQ通过eMMC启动
嵌入式硬件·ubuntu·fpga开发
风_峰4 天前
【ZYNQ开发篇】Petalinux和电脑端的静态ip地址配置
网络·嵌入式硬件·tcp/ip·ubuntu·fpga开发
碎碎思4 天前
一块板子,玩转 HDMI、USB、FPGA ——聊聊开源项目 HDMI2USB-Numato-Opsis
fpga开发
ooo-p4 天前
FPGA学习篇——Verilog学习Led灯的实现
学习·fpga开发
嵌入式-老费4 天前
Zynq开发实践(FPGA之选择开发板)
fpga开发
风_峰4 天前
PuTTY软件访问ZYNQ板卡的Linux系统
linux·服务器·嵌入式硬件·fpga开发
电子凉冰5 天前
FPGA入门-状态机
fpga开发
Aczone285 天前
硬件(十)IMX6ULL 中断与时钟配置
arm开发·单片机·嵌入式硬件·fpga开发