Digital Signal Processing Reference
In-Depth Information
arcTan[15] = 16'h0000;
end
always @*
begin
x[0] = K;
y[0] = 0;
theta[0] = theta_d;
CE_task(x[0], y[0], theta[0], arcTan[0], 4'd1, x[1],y[1], theta[1]);
for (i=0; i < N-1; i=i+1)
begin
CE_task(x_pipeline[i], y_pipeline[i], theta_pipeline[i],
arcTan[i+1], i+2, x[i+2], y[i+2], theta[i+2]);
end
end
always @(posedge clk)
begin
for(i=0; i < N-1; i=i+1)
begin
x_pipeline[i] < = x[i+1];
y_pipeline[i] < = y[i+1];
theta_pipeline[i] < = theta[i+1];
end
end
assign cos_theta = x_pipeline[N-2];
assign sine_theta =y_pipeline[N-2];
task CE_task(
input signed [M - 1:0] x_i,
input signed [M - 1:0] y_i,
input signed [N - 1:0] theta_i,
input signed [N - 1:0] Delta_theta,
input [3:0]i,
output reg signed [M - 1:0] x_iP1,
output reg signed [M - 1:0] y_iP1,
output reg signed [N - 1:0] theta_iP1);
reg sigma, sigma_bar;
reg signed [M - 1:0] x_input, y_input;
reg signed [M - 1:0] x_shifted, y_shifted, x_bar_shifted,
y_bar_shifted;
reg signed [N - 1:0] Delta_theta_input, Delta_theta_bar;
begin
sigma = theta_i[N-1]; // Sign bit of the angle
sigma_bar = _sigma;
x_shifted = x_i >>> i; // Shift by 2^-i
y_shifted = y_i >>> i; // Shift by 2^-i
x_bar_shifted = _x_shifted + 1;
y_bar_shifted = _y_shifted + 1;
Delta_theta_bar = _Delta_theta + 1;
if ((sigma)||(theta_i == 0))
begin
x_input = x_bar_shifted; // Subtract if sigma is negative
y_input = y_shifted; // Add if sigma is negative
Search WWH ::




Custom Search