交出你的灵魂

64点FFT TESTBENCH.v

上一篇 / 下一篇  2019-02-28 20:23:48


// TESTBENCH
// test serial 64 bit FFT

module TESTBENCH();
begin
  
reg signed  [7:0] InputData [63:0][1:0];
reg signed [19:0] CalData   [63:0][1:0];
reg signed [19:0] TempDataR;
reg signed [19:0] TempDataI;

reg signed  [7:0] ParamData [62:0][1:0];

/*
assign W02_00R = ParamData[ 0][0];  assign W02_00I = ParamData[ 0][1];

assign W04_00R = ParamData[ 1][0];  assign W04_00I = ParamData[ 1][1];
assign W04_01R = ParamData[ 2][0];  assign W04_01I = ParamData[ 2][1];

assign W08_00R = ParamData[ 3][0];  assign W08_00I = ParamData[ 3][1];
assign W08_00R = ParamData[ 4][0];  assign W08_01I = ParamData[ 4][1];
assign W08_00R = ParamData[ 5][0];  assign W08_02I = ParamData[ 5][1];
assign W08_00R = ParamData[ 6][0];  assign W08_03I = ParamData[ 6][1];

assign W16_00R = ParamData[ 7][0];  assign W16_00I = ParamData[ 7][1];
assign W16_01R = ParamData[ 8][0];  assign W16_01I = ParamData[ 8][1];
assign W16_02R = ParamData[ 9][0];  assign W16_02I = ParamData[ 9][1];
assign W16_03R = ParamData[10][0];  assign W16_03I = ParamData[10][1];
assign W16_04R = ParamData[11][0];  assign W16_04I = ParamData[11][1];
assign W16_05R = ParamData[12][0];  assign W16_05I = ParamData[12][1];
assign W16_06R = ParamData[13][0];  assign W16_06I = ParamData[13][1];
assign W16_07R = ParamData[14][0];  assign W16_07I = ParamData[14][1];

assign W32_00R = ParamData[15][0];  assign W32_00I = ParamData[15][1];
assign W32_01R = ParamData[16][0];  assign W32_01I = ParamData[16][1];
assign W32_02R = ParamData[17][0];  assign W32_02I = ParamData[17][1];
assign W32_03R = ParamData[18][0];  assign W32_03I = ParamData[18][1];
assign W32_04R = ParamData[19][0];  assign W32_04I = ParamData[19][1];
assign W32_05R = ParamData[20][0];  assign W32_05I = ParamData[20][1];
assign W32_06R = ParamData[21][0];  assign W32_06I = ParamData[21][1];
assign W32_07R = ParamData[22][0];  assign W32_07I = ParamData[22][1];
assign W32_08R = ParamData[23][0];  assign W32_08I = ParamData[23][1];
assign W32_09R = ParamData[24][0];  assign W32_09I = ParamData[24][1];
assign W32_10R = ParamData[25][0];  assign W32_10I = ParamData[25][1];
assign W32_11R = ParamData[26][0];  assign W32_11I = ParamData[26][1];
assign W32_12R = ParamData[27][0];  assign W32_12I = ParamData[27][1];
assign W32_13R = ParamData[28][0];  assign W32_13I = ParamData[28][1];
assign W32_14R = ParamData[29][0];  assign W32_14I = ParamData[29][1];
assign W32_15R = ParamData[30][0];  assign W32_15I = ParamData[30][1];

assign W64_00R = ParamData[31][0];  assign W64_00I = ParamData[31][1];
assign W64_01R = ParamData[32][0];  assign W64_01I = ParamData[32][1];
assign W64_02R = ParamData[33][0];  assign W64_02I = ParamData[33][1];
assign W64_03R = ParamData[34][0];  assign W64_03I = ParamData[34][1];
assign W64_04R = ParamData[35][0];  assign W64_04I = ParamData[35][1];
assign W64_05R = ParamData[36][0];  assign W64_05I = ParamData[36][1];
assign W64_06R = ParamData[37][0];  assign W64_06I = ParamData[37][1];
assign W64_07R = ParamData[38][0];  assign W64_07I = ParamData[38][1];
assign W64_08R = ParamData[39][0];  assign W64_08I = ParamData[39][1];
assign W64_09R = ParamData[40][0];  assign W64_09I = ParamData[40][1];
assign W64_10R = ParamData[41][0];  assign W64_10I = ParamData[41][1];
assign W64_11R = ParamData[42][0];  assign W64_11I = ParamData[42][1];
assign W64_12R = ParamData[43][0];  assign W64_12I = ParamData[43][1];
assign W64_13R = ParamData[44][0];  assign W64_13I = ParamData[44][1];
assign W64_14R = ParamData[45][0];  assign W64_14I = ParamData[45][1];
assign W64_15R = ParamData[46][0];  assign W64_15I = ParamData[46][1];
assign W64_16R = ParamData[47][0];  assign W64_16I = ParamData[47][1];
assign W64_17R = ParamData[48][0];  assign W64_17I = ParamData[48][1];
assign W64_18R = ParamData[49][0];  assign W64_18I = ParamData[49][1];
assign W64_19R = ParamData[50][0];  assign W64_19I = ParamData[50][1];
assign W64_20R = ParamData[51][0];  assign W64_20I = ParamData[51][1];
assign W64_21R = ParamData[52][0];  assign W64_21I = ParamData[52][1];
assign W64_22R = ParamData[53][0];  assign W64_22I = ParamData[53][1];
assign W64_23R = ParamData[54][0];  assign W64_23I = ParamData[54][1];
assign W64_24R = ParamData[55][0];  assign W64_24I = ParamData[55][1];
assign W64_25R = ParamData[56][0];  assign W64_25I = ParamData[56][1];
assign W64_26R = ParamData[57][0];  assign W64_26I = ParamData[57][1];
assign W64_27R = ParamData[58][0];  assign W64_27I = ParamData[58][1];
assign W64_28R = ParamData[59][0];  assign W64_28I = ParamData[59][1];
assign W64_29R = ParamData[60][0];  assign W64_29I = ParamData[60][1];
assign W64_30R = ParamData[61][0];  assign W64_30I = ParamData[61][1];
assign W64_31R = ParamData[62][0];  assign W64_31I = ParamData[62][1];
*/

reg [7:0] i;
reg [5:0] j;
reg [5:0] z;
reg [7:0] base;
reg [7:0] bias;
reg [7:0] num;
reg [7:0] point;
reg [7:0] UpNum;
reg [7:0] DnNum;
reg [7:0] DnBias;

initial begin
  
$display("\n\n0.Load Data");  
  $readmemh("Data_Input.txt", InputData);
  for(i = 0; i < 64; i = i + 1)
  begin
    $display("%d:( %d,%d j)", i, InputData[i][0], InputData[i][1]);
  end
$display("\n\n1.Load Parameter");  
  $readmemh("Data_Parameter.txt", ParamData);
  for(i = 0; i < 63; i = i + 1)
  begin
    $display("%d:( %d,%dj)", i, ParamData[i][0], ParamData[i][1]);
  end



$display("\n\n2.ReConfig Input Data");
  for(i = 0; i < 64; i = i + 1)
  begin
    j[5:0] = {i[0], i[1], i[2], i[3], i[4], i[5]}; 
    CalData[i][0] = InputData[j][0];
    CalData[i][1] = InputData[j][1];
    $display("%d:( %d,%d j)", i, CalData[i][0], CalData[i][1]);
  end
  

$display("\n\n3.Start FFT");
bias = 0; num = 0; point = 0;
for(z = 1; z < 7; z = z + 1)  // Stage
begin
  bias = bias + point/2;      // Init
  point = 2 ** z; 
  num = 64 / point;
  DnBias = point / 2;
  $display("\n\n3.%d  stage: %d *  %d points. (Wn_Bias: %d)", z, num, point, bias);
  
  for(i = 0; i < num; i = i + 1)//Stage
  begin
    base = point * i;
    for(j = 0; j < DnBias; j = j + 1)// Some 'Butterfly Scheme'
    begin
      UpNum = base + j;
      DnNum = base + j + DnBias;

      TempDataR = CalData[DnNum][0] * ParamData[ bias + j][0] - CalData[DnNum][1] * ParamData[ bias + j][1];
      TempDataI = CalData[DnNum][1] * ParamData[ bias + j][0] + CalData[DnNum][0] * ParamData[ bias + j][1];

      CalData[DnNum][0] = CalData[UpNum][0] * 128 - TempDataR;
      CalData[DnNum][1] = CalData[UpNum][1] * 128 - TempDataI;
      CalData[UpNum][0] = CalData[UpNum][0] * 128 + TempDataR;
      CalData[UpNum][1] = CalData[UpNum][1] * 128 + TempDataI;


      CalData[UpNum][0] = CalData[UpNum][0] / 128;
      CalData[UpNum][1] = CalData[UpNum][1] / 128;
      CalData[DnNum][0] = CalData[DnNum][0] / 128;
      CalData[DnNum][1] = CalData[DnNum][1] / 128;      
  
      $display("%d,%d,%d: CalData:(%d %dj)(%d %dj) Parameter:(%d %dj)", z, i, j
         , CalData[UpNum][0], CalData[UpNum][1]
         , CalData[DnNum][0], CalData[DnNum][1]
         , ParamData[ bias + j][0], ParamData[ bias + j][1]);
    end
  end

end// z
  
  
  
$display("4.Finish record FFT result");
  for(i = 0; i < 64; i = i + 1)
  begin
    $display("%d:( %d %d j)", i, CalData[i][0], CalData[i][1]);
  end
  
  
  
end
  
end
  
endmodule

TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2019-03-12  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 3209
  • 日志数: 25
  • 建立时间: 2018-10-29
  • 更新时间: 2019-02-28

RSS订阅

Open Toolbar
重庆时时彩 重庆时时彩 重庆时时彩 重庆时时彩 重庆时时彩 重庆时时彩 重庆时时彩 重庆时时彩 重庆时时彩