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 : Complex Multiplier by 0.924
|
41 |
|
|
// FUNCTION: Constant multiplier to cos(PI/8)-cos(3*PI/8) =0.9239
|
42 |
|
|
// FILES: MPUŃ924.v
|
43 |
|
|
// PROPERTIES: 1) Is based on shifts right and add
|
44 |
|
|
// 2) for short input bit width 0.924 is approximated as 0.1110_1100_1 =1_00T0_1100_1
|
45 |
|
|
// 3) for long bit width 0.9239 is appr. as 0.1110_1100_1000_0011 =1_00T0_1100_1000_0011
|
46 |
|
|
// 4) for short input bit width 0.383 is approximated as 0_0110_001
|
47 |
|
|
// 5) for long bit width 0.3827 is approximated as 0_0110_0001_1111_1 = 0_0110_0010_0000_T// 4) hardware is 4, or 5 adders +1
|
48 |
|
|
// 6) MPYJ switches multiply by j , C383=1 selects the coefficient 0.383
|
49 |
|
|
// 7) A complex data is multiplied for 2 cycles, latent delay=4
|
50 |
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
51 |
|
|
`include "FFT128_CONFIG.inc"
|
52 |
|
|
|
53 |
|
|
module MPUC924_383 ( CLK,DS ,ED, MPYJ,C383,DR,DI ,DOR ,DOI, );
|
54 |
|
|
`FFT128paramnb
|
55 |
|
|
|
56 |
|
|
input CLK ;
|
57 |
|
|
wire CLK ;
|
58 |
|
|
input DS ;
|
59 |
|
|
wire DS ;
|
60 |
|
|
input ED; //data strobe
|
61 |
|
|
input MPYJ ; //the result is multiplied by -j
|
62 |
|
|
wire MPYJ ;
|
63 |
|
|
input C383 ; //the coefficient is 0.383
|
64 |
|
|
wire C383 ;
|
65 |
|
|
input [nb-1:0] DR ;
|
66 |
|
|
wire signed [nb-1:0] DR ;
|
67 |
|
|
input [nb-1:0] DI ;
|
68 |
|
|
wire signed [nb-1:0] DI ;
|
69 |
|
|
|
70 |
|
|
output [nb-1:0] DOR ;
|
71 |
|
|
reg [nb-1:0] DOR ;
|
72 |
|
|
output [nb-1:0] DOI ;
|
73 |
|
|
reg [nb-1:0] DOI ;
|
74 |
|
|
|
75 |
|
|
reg signed [nb+1 :0] dx7;
|
76 |
|
|
reg signed [nb :0] dx3;
|
77 |
|
|
reg signed [nb-1 :0] dii;
|
78 |
|
|
reg signed [nb-1 : 0] dt;
|
79 |
|
|
wire signed [nb+1 : 0] dx5p;
|
80 |
|
|
wire signed [nb+1 : 0] dot;
|
81 |
|
|
reg edd,edd2, edd3; //delayed data enable impulse
|
82 |
|
|
reg mpyjd,mpyjd2,mpyjd3,c3d,c3d2,c3d3;
|
83 |
|
|
reg [nb-1:0] doo ;
|
84 |
|
|
reg [nb-1:0] droo ;
|
85 |
|
|
|
86 |
|
|
always @(posedge CLK)
|
87 |
|
|
begin
|
88 |
|
|
if (ED) begin
|
89 |
|
|
edd<=DS;
|
90 |
|
|
edd2<=edd;
|
91 |
|
|
edd3<=edd2;
|
92 |
|
|
mpyjd<=MPYJ;
|
93 |
|
|
mpyjd2<=mpyjd;
|
94 |
|
|
mpyjd3<=mpyjd2;
|
95 |
|
|
c3d<=C383;
|
96 |
|
|
c3d2<=c3d;
|
97 |
|
|
c3d3<=c3d2;
|
98 |
|
|
if (DS) begin // 1_00T0_1100_1000_0011
|
99 |
|
|
dx7<=(DR<<2) - (DR >>>1); //multiply by 7
|
100 |
|
|
dx3<=DR+(DR >>>1); //multiply by 3,
|
101 |
|
|
dt<=DR;
|
102 |
|
|
dii<=DI;
|
103 |
|
|
end
|
104 |
|
|
else begin
|
105 |
|
|
dx7<=(dii<<2) - (dii >>>1); //multiply by 7
|
106 |
|
|
dx3<=dii +(dii >>>1); //multiply by 3
|
107 |
|
|
dt<=dii;
|
108 |
|
|
end
|
109 |
|
|
if (c3d || c3d2) doo<=dot >>>2;
|
110 |
|
|
else doo<=dot >>>2;
|
111 |
|
|
|
112 |
|
|
droo<=doo;
|
113 |
|
|
if (edd3)
|
114 |
|
|
if (mpyjd3) begin
|
115 |
|
|
DOR<=doo;
|
116 |
|
|
DOI<= - droo; end
|
117 |
|
|
else begin
|
118 |
|
|
DOR<=droo;
|
119 |
|
|
DOI<= doo; end
|
120 |
|
|
end
|
121 |
|
|
end
|
122 |
|
|
|
123 |
|
|
assign dx5p= (c3d || c3d2)? ((dt>>>5)+dx3) : ( dx7+(dx3>>>3)); // multiply by 0_0110_001
|
124 |
|
|
//or multiply by 1_00T0_11
|
125 |
|
|
|
126 |
|
|
`ifdef FFT128bitwidth_coef_high
|
127 |
|
|
assign dot= (c3d || c3d2)? dx5p-(dt>>>11) :(dx5p+((dt>>>7) +(dx3>>>13)));// by 0_0110_0010_0000_T
|
128 |
|
|
//or multiply by 1_00T0_1100_1000_0011
|
129 |
|
|
`else
|
130 |
|
|
assign dot= (c3d || c3d2)? dx5p : (dx5p+(dt>>>7));
|
131 |
|
|
//or multiply by 1_00T0_1100_1
|
132 |
|
|
`endif
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
endmodule
|