1 |
2 |
unicore |
/////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// FFT/IFFT 128 points transform ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// Authors: Anatoliy Sergienko, Volodya Lepeha ////
|
6 |
|
|
//// Company: Unicore Systems http://unicore.co.ua ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Downloaded from: http://www.opencores.org ////
|
9 |
|
|
//// ////
|
10 |
|
|
/////////////////////////////////////////////////////////////////////
|
11 |
|
|
//// ////
|
12 |
|
|
//// Copyright (C) 2006-2010 Unicore Systems LTD ////
|
13 |
|
|
//// www.unicore.co.ua ////
|
14 |
|
|
//// o.uzenkov@unicore.co.ua ////
|
15 |
|
|
//// ////
|
16 |
|
|
//// This source file may be used and distributed without ////
|
17 |
|
|
//// restriction provided that this copyright statement is not ////
|
18 |
|
|
//// removed from the file and that any derivative work contains ////
|
19 |
|
|
//// the original copyright notice and the associated disclaimer.////
|
20 |
|
|
//// ////
|
21 |
|
|
//// THIS SOFTWARE IS PROVIDED "AS IS" ////
|
22 |
|
|
//// AND ANY EXPRESSED OR IMPLIED WARRANTIES, ////
|
23 |
|
|
//// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ////
|
24 |
|
|
//// WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT ////
|
25 |
|
|
//// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ////
|
26 |
|
|
//// IN NO EVENT SHALL THE UNICORE SYSTEMS OR ITS ////
|
27 |
|
|
//// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
|
28 |
|
|
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ////
|
29 |
|
|
//// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ////
|
30 |
|
|
//// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ////
|
31 |
|
|
//// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ////
|
32 |
|
|
//// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ////
|
33 |
|
|
//// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
|
34 |
|
|
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ////
|
35 |
|
|
//// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ////
|
36 |
|
|
//// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ////
|
37 |
|
|
//// ////
|
38 |
|
|
/////////////////////////////////////////////////////////////////////
|
39 |
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
40 |
|
|
// DESCRIPTION : 2-port RAM
|
41 |
|
|
// FUNCTION: 2-port RAM with 1 port to write and 1 port to read
|
42 |
|
|
// FILES: RAM2x256C.v - dual ported synchronous RAM, contains:
|
43 |
|
|
// RAM256.v -single ported synchronous RAM
|
44 |
|
|
// PROPERTIES: 1) Has the volume of 2x256 complex data
|
45 |
|
|
// 2) Contains 4 single port RAMs for real and imaginary parts of data in the 2-fold volume
|
46 |
|
|
// Two halves of RAM are switched on and off in the write mode by the signal ODD
|
47 |
|
|
// 3) RAM is synchronous one, the read datum is outputted in 2 cycles after the address setting
|
48 |
|
|
// 4) Can be substituted to any 2-port synchronous RAM for example,
|
49 |
|
|
// to one RAMB16_S36_S36 in Xilinx FPGAs
|
50 |
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
51 |
|
|
`timescale 1 ns / 1 ps
|
52 |
|
|
`include "FFT128_CONFIG.inc"
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
module RAM2x128C ( CLK ,ED ,WE ,ODD ,ADDRW ,ADDRR ,DR ,DI ,DOR ,DOI );
|
57 |
|
|
`FFT128paramnb
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
output [nb-1:0] DOR ;
|
61 |
|
|
wire [nb-1:0] DOR ;
|
62 |
|
|
output [nb-1:0] DOI ;
|
63 |
|
|
wire [nb-1:0] DOI ;
|
64 |
|
|
input CLK ;
|
65 |
|
|
wire CLK ;
|
66 |
|
|
input ED ;
|
67 |
|
|
wire ED ;
|
68 |
|
|
input WE ; //write enable
|
69 |
|
|
wire WE ;
|
70 |
|
|
input ODD ; // RAM part switshing
|
71 |
|
|
wire ODD ;
|
72 |
|
|
input [6:0] ADDRW ;
|
73 |
|
|
wire [6:0] ADDRW ;
|
74 |
|
|
input [6:0] ADDRR ;
|
75 |
|
|
wire [6:0] ADDRR ;
|
76 |
|
|
input [nb-1:0] DR ;
|
77 |
|
|
wire [nb-1:0] DR ;
|
78 |
|
|
input [nb-1:0] DI ;
|
79 |
|
|
wire [nb-1:0] DI ;
|
80 |
|
|
|
81 |
|
|
reg oddd,odd2;
|
82 |
|
|
always @( posedge CLK) begin //switch which reswiches the RAM parts
|
83 |
|
|
if (ED) begin
|
84 |
|
|
oddd<=ODD;
|
85 |
|
|
odd2<=oddd;
|
86 |
|
|
end
|
87 |
|
|
end
|
88 |
|
|
`ifdef FFT128bufferports1
|
89 |
|
|
//One-port RAMs are used
|
90 |
|
|
wire we0,we1;
|
91 |
|
|
wire [nb-1:0] dor0,dor1,doi0,doi1;
|
92 |
|
|
wire [6:0] addr0,addr1;
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
assign addr0 =ODD? ADDRW: ADDRR; //MUXA0
|
97 |
|
|
assign addr1 = ~ODD? ADDRW:ADDRR; // MUXA1
|
98 |
|
|
assign we0 =ODD? WE: 0; // MUXW0:
|
99 |
|
|
assign we1 =~ODD? WE: 0; // MUXW1:
|
100 |
|
|
|
101 |
|
|
//1-st half - write when odd=1 read when odd=0
|
102 |
|
|
RAM128 #(nb) URAM0(.CLK(CLK),.ED(ED),.WE(we0), .ADDR(addr0),.DI(DR),.DO(dor0)); //
|
103 |
|
|
RAM128 #(nb) URAM1(.CLK(CLK),.ED(ED),.WE(we0), .ADDR(addr0),.DI(DI),.DO(doi0));
|
104 |
|
|
|
105 |
|
|
//2-d half
|
106 |
|
|
RAM128 #(nb) URAM2(.CLK(CLK),.ED(ED),.WE(we1), .ADDR(addr1),.DI(DR),.DO(dor1));//
|
107 |
|
|
RAM128 #(nb) URAM3(.CLK(CLK),.ED(ED),.WE(we1), .ADDR(addr1),.DI(DI),.DO(doi1));
|
108 |
|
|
|
109 |
|
|
assign DOR=~odd2? dor0 : dor1; // MUXDR:
|
110 |
|
|
assign DOI=~odd2? doi0 : doi1; // MUXDI:
|
111 |
|
|
|
112 |
|
|
`else
|
113 |
|
|
//Two-port RAM is used
|
114 |
|
|
wire [7:0] addrr2 = {ODD,ADDRR};
|
115 |
|
|
wire [7:0] addrw2 = {~ODD,ADDRW};
|
116 |
|
|
wire [2*nb-1:0] di= {DR,DI} ;
|
117 |
|
|
|
118 |
|
|
//wire [2*nb-1:0] doi;
|
119 |
|
|
reg [2*nb-1:0] doi;
|
120 |
|
|
|
121 |
|
|
reg [2*nb-1:0] ram [255:0];
|
122 |
|
|
reg [7:0] read_addra;
|
123 |
|
|
always @(posedge CLK) begin
|
124 |
|
|
if (ED)
|
125 |
|
|
begin
|
126 |
|
|
if (WE)
|
127 |
|
|
ram[addrw2] <= di;
|
128 |
|
|
read_addra <= addrr2;
|
129 |
|
|
doi = ram[read_addra];
|
130 |
|
|
end
|
131 |
|
|
end
|
132 |
|
|
//assign
|
133 |
|
|
|
134 |
|
|
assign DOR=doi[2*nb-1:nb]; // Real read data
|
135 |
|
|
assign DOI=doi[nb-1:0]; // Imaginary read data
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
`endif
|
139 |
|
|
endmodule
|