DESIGN DESCRIPTION:
Discrete Fourier transform is used convert the samples in time domain to equivalent frequency
domain. The DFT transformation for N samples is as given below:
=
Where
is equal to
As Verilog HDL doesnt support data types that are complex in nature we have split
up the real and imaginary parts and computed them separately.
In the code all the input data is scaled by 10 to consider the fractional part and the
output data which will be generated by the code will be scaled by 100.
The twiddle factors are declared as parameters since they are constant.
The output is computed is stage wise where the output of the first stage is given as
input to the next stage.
The output of the second stage N=4 butterfly and also the twiddle factors required to
compute N=8 butterfly are scaled by 10.
2. BLOCK DIAGRAM:
Real Inputs
Real Outputs
Imaginary Inputs
Imaginary Outputs
10
reset_bar = 0;
// input pattern for [1 1 1 1 1 1 1 1]
// multiply all the real and imaginary input data by 10 before assigning the values
#(2*clkDelay)
enable_bar = 0;
reset_bar = 1;
x0r = 10;
x1r = 10;
x2r = 10;
x3r = 10;
x4r = 10;
x5r = 10;
x6r = 10;
x7r = 10;
x0i = 0;
x1i = 0;
x2i = 0;
x3i = 0;
x4i = 0;
x5i = 0;
x6i = 0;
x7i = 0;
// input pattern for [-1 -1 -1 -1 -1 -1 -1 -1]
// multiply all the real and imaginary input data by 10 before assigning the values
#(2*clkDelay)
enable_bar = 0;
reset_bar = 1;
x0r = -10;
x1r = -10;
x2r = -10;
x3r = -10;
x4r = -10;
x5r = -10;
x6r = -10;
x7r = -10;
x0i = 0;
x1i = 0;
x2i = 0;
11
x3i = 0;
x4i = 0;
x5i = 0;
x6i = 0;
x7i = 0;
// input pattern for [0+j, 0+j, 0+j, 0+j, 0+j, 0+j, 0+j, 0+j]
// multiply all the real and imaginary input data by 10 before assigning the values
#(2*clkDelay)
enable_bar = 0;
reset_bar = 1;
x0r = 0;
x1r = 0;
x2r = 0;
x3r = 0;
x4r = 0;
x5r = 0;
x6r = 0;
x7r = 0;
x0i = 10;
x1i = 10;
x2i = 10;
x3i = 10;
x4i = 10;
x5i = 10;
x6i = 10;
x7i = 10;
// input pattern for [0-j, 0-j, 0-j, 0-j, 0-j, 0-j, 0-j, 0-j]
// multiply all the real and imaginary input data by 10 before assigning the values
#(2*clkDelay)
enable_bar = 0;
reset_bar = 1;
x0r = 0;
x1r = 0;
x2r = 0;
x3r = 0;
x4r = 0;
x5r = 0;
x6r = 0;
x7r = 0;
12
x0i = -10;
x1i = -10;
x2i = -10;
x3i = -10;
x4i = -10;
x5i = -10;
x6i = -10;
x7i = -10;
// input pattern for [1+j, 2+2j, 3+j, 1+3j, 2+j, 1+2j, 1+j, 3+4j]
// multiply all the real and imaginary input data by 10 before assigning the values
#(2*clkDelay)
enable_bar = 0;
reset_bar = 1;
x0r = 10;
x1r = 20;
x2r = 30;
x3r = 10;
x4r = 20;
x5r = 10;
x6r = 10;
x7r = 30;
x0i = 10;
x1i = 20;
x2i = 10;
x3i = 30;
x4i = 10;
x5i = 20;
x6i = 10;
x7i = 40;
// input pattern for [-1+j, 2+2j, -3-j, 1+3j, 2-j, -1+2j, 1-j, 3-4j]
// multiply all the real and imaginary input data by 10 before assigning the values
#(2*clkDelay)
enable_bar = 0;
reset_bar = 1;
x0r = -10;
x1r = 20;
x2r = -30;
x3r = 10;
13
x4r = 20;
x5r = -10;
x6r = 10;
x7r = 30;
x0i = 10;
x1i = 20;
x2i = -10;
x3i = 30;
x4i = -10;
x5i = 20;
x6i = -10;
x7i = -40;
// input pattern for [-0.1+0.1j, 0.2+0.2j, -0.3-0.1j, 0.1+0.3j, 0.2-0.1j, -0.1+0.2j, 0.1-0.1j, 0.3-0.4j]
// multiply all the real and imaginary input data by 10 before assigning the value
#(2*clkDelay)
enable_bar = 0;
reset_bar = 1;
x0r = -1;
x1r = 2;
x2r = -3;
x3r = 1;
x4r = 2;
x5r = -1;
x6r = 1;
x7r = 3;
x0i = 1;
x1i = 2;
x2i = -1;
x3i = 3;
x4i = -1;
x5i = 2;
x6i = -1;
x7i = -4;
end
endmodule
14
6. SIMULATION RESULTS:
Output interpretation:
We get output in the form of {X0r X1r X2r X3r X4r X5r X6r X7r} and {X0i X1i X2i
X3i X4i X5i X6i X7i} real and imaginary respectively scaled up by 100, so the final output
would be {(X0r+jX0i) (X1r+jX1i) (X2r+jX2i) (X3r+jX3i) (X4r+jX4i) (X5r+jX5i) (X6r+jX6i)
(X7r+jX7i)} scaled down by 100.
When reset_bar is set to 0 all the outputs of FFT Module will be cleared, yellow pointer is
pointed to the period during which reset_bar = 0.
15
Above simulation waveform points to the period when x(n) = {1 1 1 1 1 1 1 1} is applied to the
input variables after scaling by 10, enable_bar = 0 and reset_bar = 1.
Output is X (k) = {800, 0, 0, 0, 0, 0, 0, 0} which is scaled by 100.
Corresponding MATLAB output is
>> fft([1 1 1 1 1 1 1 1])
Answer = 8 0 0 0
16
Above simulation waveform points to the period when x (n) = {-1 -1 -1 -1 -1 -1 -1 -1} is applied
to the input variables after scaling by 10, enable_bar = 0 and reset_bar = 1.
Output is X(k) = {-800, 0, 0, 0, 0, 0, 0, 0} which is scaled by 100.
Corresponding MATLAB output is
>> fft([-1 -1 -1 -1 -1 -1 -1 -1])
Answer = -8 0 0 0 0
17
Figure 6.4: Simulation waveform when x(n) = {0+j 0+j 0+j 0+j 0+j 0+j 0+j 0+j}
Above simulation waveform points to the period when x(n) = {0+j 0+j 0+j 0+j 0+j 0+j 0+j 0+j }
is applied to the input variables after scaling by 10, enable_bar = 0 and reset_bar = 1.
Output is X(k) = {0+j800 0 0 0 0 0 0 0} which is scaled by 100.
Corresponding MATLAB output is
>> fft([0+j 0+j 0+j 0+j 0+j 0+j 0+j 0+j])
Answer = 0 + 8.0000i 0 0 0 0 0 0 0
18
Figure 6.5: Simulation waveform when x(n) = {0-j 0-j 0-j 0-j 0-j 0-j 0-j 0-j}
Above simulation waveform points to the period when x(n) = {0-j 0-j 0-j 0-j 0-j 0-j 0-j 0-j } is
applied to the input variables after scaling by 10, enable_bar = 0 and reset_bar = 1.
Output is X(k) = {0-j800 0 0 0 0 0 0 0} which is scaled by 100. Corresponding MATLAB
output is
>> fft([0-j 0-j 0-j 0-j 0-j 0-j 0-j 0-j])
Answer = 0 - 8.0000i 0 0 0 0 0 0 0
19
Figure 6.6: Simulation waveform when x(n) = { 1+j 2+2j 3+j 1+3j 2+j 1+2j 1+j 3+4j}
Above simulation waveform points to the period when x(n) = { 1+j 2+2j 3+j 1+3j 2+j 1+2j 1+j
3+4j} is applied to the input variables after scaling by 10, enable_bar = 0 and reset_bar = 1.
Output is X(k) = {(1400+j1500) (40-j60) (-400+j100) (-380+200) (0-j700) (-240-j340) (200j100) (180+j200)} which is scaled by 100. Corresponding MATLAB output is
>> fft([1+j 2+2j 3+j 1+3j 2+j 1+2j 1+j 3+4j])
Answer = {(14.0000 +15.0000i) (0.4142-0.5858i) (-4.0000+1.0000i) (-3.8284+2.0000i) (0 7.0000i)
(-2.4142-3.4142i) (2.0000-1.0000i) (1.8284+2.0000i)}
20
Figure 6.7: Simulation waveform when x(n) = {-1+j 2+2j -3-j 1+3j 2-j -1+2j 1-j 3-4j}
Above simulation waveform points to the period when x(n) = {-1+j 2+2j -3-j 1+3j 2-j -1+2j 1-j
3-4j} is applied to the input variables after scaling by 10, enable_bar = 0 and reset_bar = 1.
Output is X(k) = {(400+j100), (540+j40), (800+j500), (-160+j220), (-600-j500), (-1140+j1160),
(-200-j100), (-440-j620)} which is scaled by 100.
Corresponding MATLAB output is
>> fft([-1+j 2+2j -3-j 1+3j 2-j -1+2j 1-j 3-4j])
Answer = {(4.0000+1.0000i) (5.4853+0.3431i) (8.0000+5.0000i) (-1.5858+2.2426i) (-6.00005.0000i) (-11.4853+11.6569i) (-2.0000-1.0000i) (-4.4142-6.2426i)}
21
Above simulation waveform points to the period when x(n) = { -0.1+0.1j, 0.2+0.2j, -0.3-0.1j,
0.1+0.3j, 0.2-0.1j, -0.1+0.2j, 0.1-0.1j, 0.3-0.4j} is applied to the input variables after scaling by
10, enable_bar = 0 and reset_bar = 1.
Output is X(k) = {(40+j10), (54+j4), (80+j50) , (-16+j22), (-60-j50) , (-114+j116), (-20-j10), (44-j62)} which is scaled by 100. Corresponding MATLAB output is
>> fft([-0.1+0.1j 0.2+0.2j -0.3-0.1j 0.1+0.3j 0.2-0.1j -0.1+0.2j 0.1-0.1j 0.3-0.4j])
Answer = {(0.4000+0.1000i) (0.5485+0.0343i) (0.8000+0.5000i) (-0.1586+0.2243i) (-0.60000.5000i) (-1.1485+1.1657i) (-0.2000-0.1000i) (-0.4414-0.6243i)}
22