Wednesday, 26 December 2012

8 point DIT FFT


module fft(clk,sel,yr,yi); //main module
  input clk;
  input [2:0]sel;
  output reg [7:0]yr,yi;
 
  wire [7:0]y0r,y1r,y2r,y3r,y4r,y5r,y6r,y7r,y0i,y1i,y2i,y3i,y4i,y5i,y6i,y7i;
  wire [7:0]x20r,x20i,x21r,x21i,x22r,x22i,x23r,x23i,x24r,x24i,x25r,x25i,x26r,x26i,x27r,x27i;
  wire [7:0]x10r,x10i,x11r,x11i,x12r,x12i,x13r,x13i,x14r,x14i,x15r,x15i,x16r,x16i,x17r,x17i;
  wire [7:0]x0,x1,x2,x3,x4,x5,x6,x7;

parameter w0r=8'b1;
parameter w0i=8'b0;
parameter w1r=8'b10110101;
parameter w1i=8'b01001011;
parameter w2r=8'b0;
parameter w2i=8'b11111111;
parameter w3r=8'b01001011;
parameter w3i=8'b01001011;

assign x0=8'b1;
assign x1=8'b10;
assign x2=8'b100;
assign x3=8'b1000;
assign x4=8'b10000;
assign x5=8'b100000;
assign x6=8'b1000000;
assign x7=8'b10000000;
//stage1
bfly1 s11(x0,x4,w0r,w0i,x10r,x10i,x11r,x11i);
bfly1 s12(x2,x6,w0r,w0i,x12r,x12i,x13r,x13i);
bfly1 s13(x1,x5,w0r,w0i,x14r,x14i,x15r,x15i);  
bfly1 s14(x3,x7,w0r,w0i,x16r,x16i,x17r,x17i);
//stage2
bfly1 s21(x10r,x12r,w0r,w0i,x20r,x20i,x22r,x22i);
bfly2 s22(x11r,x11i,x13r,x13i,x21r,x21i,x23r,x23i);
bfly1 s23(x14r,x16r,w0r,w0i,x24r,x24i,x26r,x26i);
bfly2 s24(x15r,x15i,x17r,x17i,x25r,x25i,x27r,x27i);
//stage3
bfly1 s31(x20r,x24r,w0r,w0i,y0r,y0i,y4r,y4i);
bfly3 s32(x21r,x21i,x25r,x25i,w1r,w1i,y1r,y1i,y5r,y5i);
bfly2 s33(x22r,x22i,x26r,x26i,y2r,y2i,y6r,y6i);
bfly4 s34(x23r,x23i,x27r,x27i,w3r,w3i,y3r,y3i,y7r,y7i);

always@(posedge clk)
case(sel)
  0:begin yr=y0r; yi=y0i; end
  1:begin yr=y1r; yi=y1i; end
  2:begin yr=y2r; yi=y2i; end
  3:begin yr=y3r; yi=y3i; end
  4:begin yr=y4r; yi=y4i; end
  5:begin yr=y5r; yi=y5i; end
  6:begin yr=y6r; yi=y6i; end
  7:begin yr=y7r; yi=y7i; end
endcase
 endmodule

module bfly1(x,y,wr,wi,x0r,x0i,x1r,x1i);// sub module
  input [7:0]x,y,wr,wi;
  output[7:0]x1r,x1i,x0r,x0i;
  assign x0r=x+(y*wr);
  assign x0i=y*wi;
  assign x1r=x+(~(y*wr)+1);
  assign x1i=~(y*wi)+1;
endmodule

module bfly2(xr,xi,yr,yi,x0r,x0i,x1r,x1i); // sub module
  input [7:0]xr,xi,yr,yi;
  output [7:0]x0r,x0i,x1r,x1i;
  assign x0r=xr;
  assign x0i=~yr+1;
  assign x1r=xr;
  assign x1i=yr;
endmodule

module bfly3(xr,xi,yr,yi,wr,wi,x0r,x0i,x1r,x1i); // sub module
  input [7:0]xr,xi,yr,yi,wr,wi;
  output [7:0]x0r,x0i,x1r,x1i;
  wire [15:0]p1,p2,p3,p4;
  wire [7:0]win,yrn,yin;
  wire [8:0]ywr,ywi;
  parameter sht=8'b1000;
  assign yrn=~yr+1;
  assign yin=yi;
  assign win=~wi+1;
 
  assign p1=(yrn*wr)>>sht;
  assign p2=(yin*win)>>sht;
  assign p3=(yrn*win)>>sht;
  assign p4=(yin*wr)>>sht;
  assign ywr=(~p1+1)+p2;
  assign ywi=p3+p4;
 
  assign x0r=xr+ywr;
  assign x0i=xi+ywi;
  assign x1r=xr+(~ywr+1);
  assign x1i=xi+(~ywi+1);
endmodule

module bfly4(xr,xi,yr,yi,wr,wi,x0r,x0i,x1r,x1i); // sub module
  input [7:0]xr,xi,yr,yi,wr,wi;
  output [7:0]x0r,x0i,x1r,x1i;
  wire [15:0]p1,p2;
  wire [7:0]win,yrn,yin;
  wire [8:0]ywr,ywi;
  parameter sht=8'b1000;
  assign yrn=~yr+1;
  assign yin=~yi+1;
  assign win=~wi+1;
    assign p1=(yrn*win)>>sht;
  assign p2=(yin*win)>>sht;
  assign ywr=p1+(~p2+1);
  assign ywi=p1+p2;
   assign x0r=xr+ywr;
  assign x0i=xi+ywi;
  assign x1r=xr+(~ywr+1);
  assign x1i=xi+(~ywi+1);
endmodule

 

28 comments:

  1. can you give me the Block diagram for this..that you have assumed wires etc i need to see i am confused with the code

    ReplyDelete
  2. Please, can you send me more information about your code? I want to understand it better ant.linares@gmail.com

    ReplyDelete
  3. please can u give me some explanation of your code,example..how did u manage to represent the fractions in you registers etc .my email:velpulaakshaypaul@gmail.com

    ReplyDelete
  4. hi lalitha.....in the program why you didn't used w2r and w2i which is used to impliment in the butterfly 2...............and also send us the explanation regarding shifter which is used in butterfly 3&4........and also if u have any block diagram regarding program,please send to my mail...ID is mnaveenkumar485@gmail.com..............thank you.....

    ReplyDelete
    Replies
    1. w2r=0 & w2i= -j , if you derive the real and imag parts of this butterfly diagram it doesn't needs any twiddle factor value,, the output requires only the input values so the twiddle factor is not used for this butterfly.... the o/p is x0=xr-yr & x1=xr+yr... hope its okay..

      Delete
  5. hi...i want to know how u managed decimal values in ur code..can u explain ur code...my id is tasa.priya@gmail.com

    ReplyDelete
    Replies
    1. the decimal values are converted to binary by IEEE 754 format

      Delete
  6. can u please explain the code... my id is sunkarapavani1@gmail.com

    ReplyDelete
  7. i think you have given twiddle factors as floating point values
    and how to verify the output
    will out put also be in floating point

    ReplyDelete
    Replies
    1. the output also requires the conversion of binary to decimal by IEEE 754, for decimal values calculate manually

      Delete
  8. Me also.......give me a explanation. send me a complete discretion on my mail Id. My mail Id is Radha.Wadiwala@gmail.com

    ReplyDelete
  9. Kindly send me the explanation for the code to my mail id shekhar.tcom@gmail.com

    ReplyDelete
  10. can you please give the block diagram for this code ?? Thank you.
    EMAIL : 94simanta@gmail.com

    ReplyDelete
  11. the twiddle factor is represented in IEEE 754 format of 8-bit,
    but IEEE 754 of 32-bit conversion is only available as i saw, so can you please say how did you find that twiddle factor binary value because i need to develop for 16-point and radix-4 16-point, please help me... answer please,,, explain twiddle factor alone it is very important for my project, please mam roselinramya04@gmail.com

    ReplyDelete
  12. can you give me theoretical calculation corresponding to this code to my mail id meghadoddamani95@gmail.com

    ReplyDelete
  13. Can you please mail the explaination of this code to my mail id?
    E-mail : appu95sharma@gmail.com

    ReplyDelete
  14. Can you please mail the explaination of this code to my mail id?
    Email:sonalikangralkar1996@gmail.com

    ReplyDelete
  15. Can u please mail the explanation and block diagram of this code to my mail id? It's very urgent and too important for my final year projecr

    ReplyDelete
  16. Can u please mail the explanation and block diagram of this code to my mail id? It's very urgent and too important for my final year project..plzz help...
    My id- bindupal076@gmail.com

    ReplyDelete
  17. Could u please mail the explanation and block diagram of this code to my mail id too? It's very urgent for my final year project.
    chippyjoseph1994@gmail.com

    ReplyDelete
  18. plz mail me - complete information about the twiddle factors and module details

    ReplyDelete
  19. I want verilog code for 16 bit data

    ReplyDelete
  20. Send me code with more information

    ReplyDelete
  21. please send a block diagram at anvesh27.ap@gmail.com

    ReplyDelete
  22. can u give some other version of 8 point fft
    e mail :dhushyanths981@gmail.com

    ReplyDelete
  23. can u send block diagram and explanation on
    vj26869@gmail.com

    ReplyDelete