always @(posedge CLK or negedge REST)//ACD數(shù)據(jù)輸入
if(!REST) N <= 16'h0000;
else if(!CS) begin ADCMEMORY[N] <= ADCDAT;N <= N+1'b1; end
always @(N)
if(N==FFTN-1) FULL <= 1'b1;
else FULL <= 1'b0;
always @(posedge CLK_50M or negedge REST)
if(!REST) begin BUSY <= 1'b0;j <= 16'h0000;f <= FFTN/16'd2; end
else if(N==FFTN-1)
begin
BUSY <= 1'b1;
for(i=16'h0000;i
begin
if(i
begin
temp <= ADCMEMORY[j];
ADCMEMORY[j] <= ADCMEMORY[i];
ADCMEMORY[i] <= temp;
end
k <= FFTN/16'd2;
while(k<=j)
begin
j <= j-k;
k <= k/16'd2;
end
j <= j+k;
end
for(i=16'h0000;i
begin
DOREMEMORY[i] <= ADCMEMORY[i];
DOIMMEMORY[i] <= 0;
end
for(l=16'd1;f!=16'd1;l=l+1'b1) f <= f/2;
for(m=16'd1;m<=l;m=m+1'b1)
begin
le <= 16'd2<<(m-1);
lei <= le/2;
u[0] <= 16'd1;
u[1] <= 16'd0;
w[0] <= cos(Pi/lei);
w[1] <= -sin(Pi/lei);
for(j=0;j<=lei-1;j=j+1'b1)
begin
ip <= i+lei;
EE(DOREMEMORY[ip],DOIMMEMORY[ip],u[0],u[1],v[0],v[1]);
DOREMEMORY[ip] <= DOREMEMORY[i]-v[0];
DOIMMEMORY[ip] <= DOIMMEMORY[ip]-v[1];
DOREMEMORY[i] <= DOREMEMORY[i]+v[0];
DOIMMEMORY[i] <= DOIMMEMORY[i]+v[1];
end
EE(u[0],u[1],w[0],w[1],u[0],u[1]);
end
BUSY <= 1'b0;
end
always @(posedge CLK or posedge EXT or negedge BUSY or negedge CS)
if((!CS)&&(!BUSY)&&EXT)
begin
OUTDAT <= {DOIMMEMORY[N],DOREMEMORY[N]};
N <= N-1'b1;
end
//task EE(ARE,AIM,BRE,BIM,CRE,CIM);
task EE;
input [31:0] ARE,AIM,BRE,BIM;
output [31:0] CRE,CIM;
begin
CRE=ARE*BRE-AIM*BIM;
CIM=ARE*BIM+AIM*BRE;
end
endtask
endmodule