Advertisement
Guest User

Untitled

a guest
Dec 21st, 2012
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. 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);
  2.  
  3. logic[15:0] alpha = 16'b0100000000000000;
  4. logic[15:0] alphashift;
  5. logic[15:0] yshift;
  6. logic[15:0] xshift;
  7. logic[15:0] zshift;
  8.  
  9. logic[15:0] regx;
  10. logic[15:0] regy; //<----------Need to store x,y and z here
  11. logic[15:0] regz;
  12.  
  13.  
  14. always_ff@(posedge Clk)
  15.  
  16. begin
  17.  
  18. if(Reset)
  19.  
  20. begin
  21.  
  22. xprime <= 0;
  23. yprime <= 0;
  24. zprime <= 0;
  25.  
  26.  
  27.  
  28. end
  29.  
  30. else if (Start)
  31.  
  32. begin
  33.  
  34.  
  35. if(z[15]==0)
  36.  
  37. begin
  38. xprime <= regx - (yshift);//check that its arithmetic shift
  39. yprime <= regy + ((xshift)); //check that its arithmetic shift
  40. zprime <= regz - (alphashift); //check that its arithmetic shift
  41. end
  42.  
  43. if(z[15]==1)
  44.  
  45. begin
  46. xprime <= regx + (yshift);//check that its arithmetic shift
  47. yprime <= regy - ((xshift)); //check that its arithmetic shift
  48. zprime <= regz + (alphashift); //check that its arithmetic shift //not accurate sice we are not using atan, also already does 2's complement.
  49. end
  50.  
  51.  
  52. end //end of if start block
  53.  
  54. end //end of the always_ff block
  55.  
  56. always_comb
  57. begin
  58. //shifting
  59. alphashift = alpha>>>i;
  60. yshift = y>>>i;
  61. xshift = x>>>i;
  62. zshift = z>>>i;
  63.  
  64. //loading the numbers
  65. regx = x;
  66. regy = y; //<--------Trying to store x,y and z
  67. regz = z;
  68.  
  69. //Two's complement
  70. if(x[15]==1)
  71. begin
  72. regx[15]=!regx[15];
  73. regx= (!regx)+1;
  74. end
  75.  
  76. if(y[15]==1)
  77. begin
  78. regy[15]=!regy[15];
  79. regy= (!regy)+1;
  80. end
  81.  
  82. if(z[15]==1)
  83. begin
  84. regz[15]=!regz[15];
  85. regz= (!regz)+1;
  86. end
  87.  
  88. end//end of always_comb
  89. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement