Cordic algorithm verilog implementation (simple version)

Cordic algorithm verilog implementation (simple version) (reproduced) module cordic(clk, phi, cos, sin); parameter W = 13, W_Z = 14; input clk; input [W_Z-1:0] phi; output[W-1 :0] cos, sin; reg [W-1:0] cos, sin; reg [W-1:0] x[8:0], y[8:0]; reg [W_Z-1:0] z [7:0]; always @(posedge clk)begin x[0] <= 13'h4D; // Correct the scale factor of the CORDIC algorithm, the reciprocal of An y[0] <= 13'h00; z[0] < = phi; // rotate 45 degrees if(z[0][W_Z-1]) begin x[1] <= x[0] + y[0]; y[1] <= y[0] - x[ 0]; z[1] <= z[0] + 14'h65; end else begin x[1] <= x[0] - y[0]; y[1] <= y[0] + x[ 0]; z[1] <= z[0] - 14'h65; end // rotate 26.57 degrees if(z[1][W_Z-1]) begin x[2] <= x[1] + {{ 1{y[1][W-1]}}, y[1][W-1:1]}; y[2] <= y[1] - {{1{x[1][W-1 ]}}, x[1][W-1:1]}; z[2] <= z[1] + 14'h3B; end else begin x[2] <= x[1] - {{1{ y[1][W-1]}}, y[1][W-1:1]}; y[2] <= y[1] + {{1{x[1][W-1]} }, x[1][W-1:1]}; z[2] <= z[1] - 14'h3B; end // rotate 14.04 degrees if(z[2][W_Z-1])begin x [3] <= x[2] + {{2{y[2][W-1]}}, y[2][W-1:2]}; y[3] <= y[2] - {{2{x[2][W-1]}}, x[2][W-1:2]}; z[3] <= z[2 ] + 14'h1F; end else begin x[3] <= x[2] - {{2{y[2][W-1]}}, y[2][W-1:2]}; y [3] <= y[2] + {{2{x[2][W-1]}}, x[2][W-1:2]}; z[3] <= z[2] - 14'h1F; end // rotate 7.13 degrees if(z[3][W_Z-1]) begin x[4] <= x[3] + {{3{y[3][W-1]}}, y[3][W-1:3]}; y[4] <= y[3] - {{3{x[3][W-1]}}, x[3][W-1:3 ]}; z[4] <= z[3] + 14'h10; end else begin x[4] <= x[3] - {{3{y[3][W-1]}}, y[ 3][W-1:3]}; y[4] <= y[3] + {{3{x[3][W-1]}}, x[3][W-1:3]} ;z[4] <= z[3] - 14'h10; end // rotate 3.58 degrees if(z[4][W_Z-1])begin x[5] <= x[4] + {{4{ y[4][W-1]}}, y[4][W-1:4]}; y[5] <= y[4] - {{4{x[4][W-1]} }, x[4][W-1:4]}; z[5] <= z[4] + 14'h8; end else begin x[5] <= x[4] - {{4{y[ 4][W-1]}}, y[4][W-1:4]}; y[5] <= y[4] + {{4{x[4][W-1]}}, x[4][W-1:4]}; z[5] <= z[4] - 14'h8; end // rotate 1.79 degrees if(z[5][W_Z-1])begin x[6 ] <= x[5] + {{5{y[5][W-1]}}, y[5][W-1:5]}; y[6] <= y[5] - {{ 5{x[5][W-1]}}, x[5][W-1:5]}; z[6] <= z[5] + 14'h4; end else begin x[6] < = x[5] - {{5{y[5][W-1]}}, y[5][W-1:5]}; y[6] <= y[5] + {{5{ x[5][W-1]}}, x[5][W-1:5]}; z[6] <= z[5] - 1 4'h4; end // rotate 0.90 degrees if(z[6][W_Z-1])begin x[7] <= x[6] + {{6{y[6][W-1]}}, y[6][W-1:6]}; y[7] <= y[6] - {{6{x[6][W-1]}},x[6][W-1:6 ]}; z[7] <= z[6] + 14'h2; end else begin x[7] <= x[6] - {{6{y[6][W-1]}}, y[ 6][W-1:6]}; y[7] <= y[6] + {{6{x[6][W-1]}}, x[6][W-1:6]} ;z[7] <= z[6] - 14'h2; end // rotate 0.45 degrees if(z[7][W_Z-1])begin x[8] <= x[7] + {{7{ y[7][W-1]}}, y[7][W-1:7]}; y[8] <= y[7] - {{7{x[7][W-1]} }, x[7][W-1:7]}; end else begin x[8] <= x[7] - {{7{y[7][W-1]}}, y[7][ W-1:7]}; y[8] <= y[7] + {{7{x[7][W-1]}}, x[7][W-1:7]}; end cos <= x[8]; sin <= y[8]; endendmodule

Utco

Hongkong Onice Limited , https://www.ousibangvape.com