Continue to Site

# cordic code compression

Status
Not open for further replies.

#### student13

##### Newbie level 6
can anyone help me with documents or methods as to how to compress the following cordic code? actually it is using almost all of the resources, but i still have to implement many more blocks, hence the need for compression.

module cordicnew(z0,x0,y0,xn,yn,clk);
input signed [15:0]z0,x0,y0;
input clk;
output reg signed [16:0]xn,yn;
//parameter [3:0]iter=4'd14;
reg [15:0] thetai [7:0];
reg [3:0]ii=4'd0;
//reg [3:0]i;
reg signed [16:0]xi,yi,xtemp,ytemp;
reg signed [15:0]zi;
reg init=0;
//reg [15:0]pi=16'b0110010010000111;
reg [15:0]pi2=16'b0011001001000011;
initial
begin
thetai[0]=16'b0001100100100001;
thetai[1]=16'b0000111011010110;
thetai[2]=16'b0000011111010110;
thetai[3]=16'b0000001111111010;
thetai[4]=16'b0000000111111111;
thetai[5]=16'b0000000011111111;
thetai[6]=16'b0000000001111111;
thetai[7]=16'b0000000000111111;
end
//initial

always @(posedge clk)
begin
if( init ==0)
begin
if(z0[15]==0)
begin
if(z0[14:13]>2'd1)
begin
xi<=0-{y0[15],y0};
yi<={x0[15],x0};
zi=z0-pi2;
end
else
begin
xi<={x0[15],x0};
yi<={y0[15],y0};
zi=z0;
end
end
else if(z0[15]==1)
begin
if(z0[14:13]>2'd1)
begin
xi<={y0[15],y0};
yi<=0-{x0[15],x0};
zi=z0+pi2;
end
else
begin
xi<={x0[15],x0};
yi<={y0[15],y0};
zi=z0;
end
end
xn=0;
yn=0;
init=1;
end
else
begin
//for(ii=0;ii<iter;ii=ii+4'd1)
//begi
ytemp=(yi>>>ii);
xtemp=(xi>>>ii);
if(zi[15]==0)
begin
xn=xi-ytemp;
yn=yi+xtemp;
zi=zi-thetai[ii];
end
else
begin
xn=xi+ytemp;
yn=yi-xtemp;
zi=zi+thetai[ii];
end
xi<=xn;
yi<=yn;
ii=ii+4'd1;
end
//xn=xn/An;
//yn=yn/An;
end
//en
endmodule

Status
Not open for further replies.