Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module rotation_cordic_a( output logic [15:0] xprime, output logic [15:0] yprime,output logic [15:0] zprime, input logic [15:0] x,input logic [15:0] y,input logic [15:0] z,input logic Clk, Reset, Start, input int i);
- logic[15:0] alpha = 16'b0100000000000000;
- logic[15:0] alphashift;
- logic[15:0] yshift;
- logic[15:0] xshift;
- logic[15:0] zshift;
- logic[15:0] regx;
- logic[15:0] regy; //<----------Need to store x,y and z here
- logic[15:0] regz;
- always_ff@(posedge Clk)
- begin
- if(Reset)
- begin
- xprime <= 0;
- yprime <= 0;
- zprime <= 0;
- end
- else if (Start)
- begin
- if(z[15]==0)
- begin
- xprime <= regx - (yshift);//check that its arithmetic shift
- yprime <= regy + ((xshift)); //check that its arithmetic shift
- zprime <= regz - (alphashift); //check that its arithmetic shift
- end
- if(z[15]==1)
- begin
- xprime <= regx + (yshift);//check that its arithmetic shift
- yprime <= regy - ((xshift)); //check that its arithmetic shift
- zprime <= regz + (alphashift); //check that its arithmetic shift //not accurate sice we are not using atan, also already does 2's complement.
- end
- end //end of if start block
- end //end of the always_ff block
- always_comb
- begin
- //shifting
- alphashift = alpha>>>i;
- yshift = y>>>i;
- xshift = x>>>i;
- zshift = z>>>i;
- //loading the numbers
- regx = x;
- regy = y; //<--------Trying to store x,y and z
- regz = z;
- //Two's complement
- if(x[15]==1)
- begin
- regx[15]=!regx[15];
- regx= (!regx)+1;
- end
- if(y[15]==1)
- begin
- regy[15]=!regy[15];
- regy= (!regy)+1;
- end
- if(z[15]==1)
- begin
- regz[15]=!regz[15];
- regz= (!regz)+1;
- end
- end//end of always_comb
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement