Hi Frineds !
i'm trying to solve the 4 poiint FFT using verilog ...can u please help me out with the errors..
The below is the code which i tried !
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
module fft_tb();
parameter width = 1;
reg clock;
reg npoint;
reg [width-1:0] re_in0;
reg [width-1:0] im_in0;
reg [width-1:0] re_in1;
reg [width-1:0] im_in1;
wire [width-1:0] re_out0;
wire [width-1:0] im_out0;
wire [width-1:0] re_out1;
wire [width-1:0] im_out1;
fft_main m1(re_out0, im_out0, re_out1, im_out1, re_in0, im_in0, re_in1,
im_in1, npoint, clock);
initial
clock =1'b0;
always
#5 clock=~clock;
initial
begin
re_in0=1;
im_in0=0;
re_in1=1;
im_in1=0;
npoint=2;
end
initial
$monitor("The FFT Input, The FFT Output :%d, %d, %d, %d, %d, %d, %d,
%d", re_in0, im_in0, re_in1, im_in1, re_out0, im_out0, re_out1,
im_out1);
// $monitor(" :", );
//$monitor(" :%d, %d, %d, %d",);
endmodule
module fft_main(re_out0, im_out0, re_out1, im_out1, re_in0, im_in0,
re_in1, im_in1, npoint, clock);
parameter width = 1;
input [width-1:0] re_in0;
input [width-1:0] im_in0;
input [width-1:0] re_in1;
input [width-1:0] im_in1;
input clock;
input npoint;
output [width-1:0] re_out0;
output [width-1:0] im_out0;
output [width-1:0] re_out1;
output [width-1:0] im_out1;
reg [width-1:0] re_out0;
reg [width-1:0] im_out0;
reg [width-1:0] re_out1;
reg [width-1:0] im_out1;
wire re_tw;
wire im_tw;
//wire re_out0;
//wire re_out1;
//wire im_out0;
//wire im_out1;
twiddle_sin sin(im_tw, npoint, clock);
twiddle_cos cos(re_tw, npoint, clock);
real_butterfly re_part (re_out0, re_out1, re_in0, re_in1, re_tw,
clock);
imag_butterfly im_part (im_out0, im_out1, im_in0, im_in1, im_tw,
clock);
endmodule
module twiddle_sin(im_tw, npoint, clock);
input clock;
input npoint;
//output im_tw0;
//output im_tw1;
output [1:0] im_tw;
reg [1:0]im_tw;
//reg im_tw1;
integer k;
integer n;
integer p;
real x;
real x1,y,y2,y3,y5,y7,sum,sign,sin;
parameter pi=3.14159;
always @(posedge clock)
//initial
// begin
// i=k;
// j=n;
for(k=2;k3.14159/2.0)
begin
x1=x1-3.14159;
sign=1.0*sign;
end
y = x1*2/3.14159265;
y2 = y*y;
y3 = y*y2;
y5 = y3*y2;
y7 = y5*y2;
sum = 1.570794*y - 0.645962*y3 + 0.079692*y5 - 0.004681712*y7;
sin = sign*sum;
im_tw= sin;
end
//end
// end
endmodule
module twiddle_cos(re_tw, npoint, clock);
input clock;
input npoint;
output [1:0]re_tw;
//output re_tw1;
reg [1:0]re_tw;
//reg re_tw1;
integer k;
integer n;
integer p;
real x;
real x1,y,y2,y3,y5,y7,sum,sign,cos;
parameter pi=3.14159;
always @(posedge clock)
//initial
// begin
// i=k;
// j=n;
for(k=2;k3.14159/2.0)
begin
x1=x1-3.14159;
sign=1.0*sign;
end
y = x1*2/3.14159265;
y2 = y*y;
y3 = y*y2;
y5 = y3*y2;
y7 = y5*y2;
sum = 1.570794*y - 0.645962*y3 + 0.079692*y5 - 0.004681712*y7;
cos = sign*sum;
re_tw= cos;
end
//end
// end
endmodule
module real_butterfly(re_out0, re_out1, re_in0, re_in1, re_tw, clock);
parameter width = 1;
input [width-1:0] re_in0;
input [width-1:0] re_in1;
input [width-1:0] re_tw;
input clock;
output [width-1:0] re_out0;
output [width-1:0] re_out1;
reg [width-1:0] re_out0;
reg [width-1:0] re_out1;
always @(posedge clock)
while(1)
begin
re_out0 =
(re_in0*re_tw[0])+(re_in1*re_tw[0])-(re_in0*re_tw[0])-(re_in1*re_tw[0]);
re_out1 =
(re_in1*re_tw[1])+(re_in0*re_tw[1])-(re_in0*re_tw[1])-(re_in1*re_tw[1]);
end
endmodule
module imag_butterfly(im_out0, im_out1, im_in0, im_in1, im_tw, clock);
parameter width = 1;
input [width-1:0] im_in0;
input [width-1:0] im_in1;
input clock;
input [width-1:0] im_tw;
output [width-1:0] im_out0;
output [width-1:0] im_out1;
reg [width-1:0] im_out0;
reg [width-1:0] im_out1;
always @(posedge clock)
while(1)
begin
im_out0=(im_in0*im_tw[0])+(im_in1*im_tw[0])-(im_in0*im_tw[0])-(im_in1*im_tw[0]);
im_out1=(im_in1*im_tw[1])+(im_in0*im_tw[1])-(im_in0*im_tw[1])-(im_in1*im_tw[1]);
end
endmodule
-------------------------------------------
------------------------------------------
-----------------------------------------
Please do reply !!
Vijay