OpenCores
URL https://opencores.org/ocsvn/fft2_size/fft2_size/trunk

Subversion Repositories fft2_size

[/] [fft2_size/] [fft_int/] [fft_int.sv] - Blame information for rev 13

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 Papayaved
`ifndef _fft_int_
2
`define _fft_int_
3
`include "cascade_0.sv"
4
`include "cascade_n.sv"
5
 
6
// Integer streaming FFT
7
module fft_int #(parameter
8
        POW = 9, // FFT length N = 2**POW
9
        DATA_WIDTH = 32,
10
        RES_WIDTH = DATA_WIDTH + POW // not divided by 1/sqrt(N)
11
)(
12
        input clk, aclr,
13
        input sink_sop, sink_eop, sink_valid,
14
        input signed [DATA_WIDTH-1:0] sink_Re, sink_Im,
15
        output reg source_sop, source_eop, source_valid,
16
        output signed [RES_WIDTH-1:0] source_Re, source_Im,
17
        output error
18
);
19
 
20
        wire [POW:0][POW-1:0] rdaddr;
21
        wire [POW:0] ready, rdack;
22
 
23
        genvar k;
24
        generate for (k = 0; k <= POW; k++)
25
                begin :res
26
                        wire signed [DATA_WIDTH + k - 1:0] re, im;
27
                end
28
        endgenerate
29
 
30
        // input controller
31
        cascade_0 #(.ADDR_WIDTH(POW), .DATA_WIDTH(DATA_WIDTH)) c0(
32
                .clk, .aclr, .sink_sop, .sink_eop, .sink_valid,
33
                .sink_Re, .sink_Im,
34
 
35
                .source_rdaddr(rdaddr[0]),
36
                .source_Re(res[0].re), .source_Im(res[0].im),
37
                .source_ready(ready[0]),
38
                .source_rdack(rdack[0]),
39
                .error
40
        );
41
 
42
        genvar i;
43
        generate for (i = 1; i <= POW; i++)
44
                begin :gen
45
                        cascade_n #(.ADDR_WIDTH(POW), .DATA_WIDTH(DATA_WIDTH + i - 1), .POW(i)) cn(
46
                                .clk, .aclr, .sink_ready(ready[i-1]),
47
                                .sink_rdaddr(rdaddr[i-1]),
48
                                .sink_Re(res[i-1].re), .sink_Im(res[i-1].im),
49
                                .sink_rdack(rdack[i-1]),
50
                                .source_rdaddr(rdaddr[i]),
51
                                .source_Re(res[i].re), .source_Im(res[i].im),
52
                                .source_ready(ready[i]),
53
                                .source_rdack(rdack[i])
54
                        );
55
                end
56
        endgenerate
57
 
58
        // todo: to module
59
        reg [POW-1:0] cnt = '0;
60
        always_ff @(posedge clk, posedge aclr)
61
                if (aclr)
62
                        cnt <= '0;
63
                else if (!ready[POW])
64
                        cnt <= '0;
65
                else
66
                        cnt <= cnt + 1'b1;
67
 
68
        assign rdaddr[POW] = cnt;
69
        assign rdack[POW] = cnt == '1;
70
 
71
        always_ff @(posedge clk) begin
72
                source_sop <= ready[POW] && cnt == '0;
73
                source_valid <= ready[POW] || rdack[POW];
74
                source_eop <= cnt == '1;
75
        end
76
 
77
        assign source_Re = res[POW].re;
78
        assign source_Im = res[POW].im;
79
 
80
endmodule :fft_int
81
 
82
`endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.