Advertisement
Guest User

복붙

a guest
Mar 28th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. (* synthesize *)
  2. module mkFftFolded(Fft);
  3. Fifo#(2,Vector#(FftPoints, ComplexData)) inFifo <- mkCFFifo;
  4. Fifo#(2,Vector#(FftPoints, ComplexData)) outFifo <- mkCFFifo;
  5. Vector#(16, Bfly4) bfly <- replicateM(mkBfly4);
  6. Reg#(Vector#(FftPoints, ComplexData)) stageReg <- mkRegU();
  7. Reg#(StageIdx) counter <- mkReg(0);
  8.  
  9. function Vector#(FftPoints, ComplexData) stage_f(StageIdx stage, Vector#(FftPoints, ComplexData) stage_in);
  10. Vector#(FftPoints, ComplexData) stage_temp, stage_out;
  11. for (FftIdx i = 0; i < 16; i = i + 1)
  12. begin
  13. FftIdx idx = i * 4;
  14. Vector#(4, ComplexData) x;
  15. Vector#(4, ComplexData) twid;
  16. for (FftIdx j = 0; j < 4; j = j + 1 )
  17. begin
  18. x[j] = stage_in[idx+j];
  19. twid[j] = getTwiddle(stage, idx+j);
  20. end
  21. let y = (bfly[i]).bfly4(twid, x);
  22.  
  23. for(FftIdx j = 0; j < 4; j = j + 1 )
  24. stage_temp[idx+j] = y[j];
  25. end
  26.  
  27. stage_out = permute(stage_temp);
  28.  
  29. return stage_out;
  30. endfunction
  31.  
  32. rule doFft;
  33. if (counter == 0) begin
  34. inFifo.deq;
  35. stageReg <= stage_f(0, inFifo.first);
  36. counter <= counter + 1;
  37. end
  38. else begin
  39. if (counter < 3) begin
  40. stageReg <= stage_f(counter, stageReg);
  41. counter <= counter + 1;
  42. end
  43. else begin
  44. outFifo.enq(stageReg);
  45. counter <= 0;
  46. end
  47. end
  48. endrule
  49.  
  50. method Action enq(Vector#(FftPoints, ComplexData) in);
  51. inFifo.enq(in);
  52. endmethod
  53.  
  54. method ActionValue#(Vector#(FftPoints, ComplexData)) deq;
  55. outFifo.deq;
  56. return outFifo.first;
  57. endmethod
  58. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement