Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* synthesize *)
- module mkFftFolded(Fft);
- Fifo#(2,Vector#(FftPoints, ComplexData)) inFifo <- mkCFFifo;
- Fifo#(2,Vector#(FftPoints, ComplexData)) outFifo <- mkCFFifo;
- Vector#(16, Bfly4) bfly <- replicateM(mkBfly4);
- Reg#(Vector#(FftPoints, ComplexData)) stageReg <- mkRegU();
- Reg#(StageIdx) counter <- mkReg(0);
- function Vector#(FftPoints, ComplexData) stage_f(StageIdx stage, Vector#(FftPoints, ComplexData) stage_in);
- Vector#(FftPoints, ComplexData) stage_temp, stage_out;
- for (FftIdx i = 0; i < 16; i = i + 1)
- begin
- FftIdx idx = i * 4;
- Vector#(4, ComplexData) x;
- Vector#(4, ComplexData) twid;
- for (FftIdx j = 0; j < 4; j = j + 1 )
- begin
- x[j] = stage_in[idx+j];
- twid[j] = getTwiddle(stage, idx+j);
- end
- let y = (bfly[i]).bfly4(twid, x);
- for(FftIdx j = 0; j < 4; j = j + 1 )
- stage_temp[idx+j] = y[j];
- end
- stage_out = permute(stage_temp);
- return stage_out;
- endfunction
- rule doFft;
- if (counter == 0) begin
- inFifo.deq;
- stageReg <= stage_f(0, inFifo.first);
- counter <= counter + 1;
- end
- else begin
- if (counter < 3) begin
- stageReg <= stage_f(counter, stageReg);
- counter <= counter + 1;
- end
- else begin
- outFifo.enq(stageReg);
- counter <= 0;
- end
- end
- endrule
- method Action enq(Vector#(FftPoints, ComplexData) in);
- inFifo.enq(in);
- endmethod
- method ActionValue#(Vector#(FftPoints, ComplexData)) deq;
- outFifo.deq;
- return outFifo.first;
- endmethod
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement