필터 지우기
필터 지우기

I want to design a divider using cordic function, for high number / low number (30/2) can anyone help me.?

조회 수: 2 (최근 30일)
I have already design the divider using cordic, but this is working only for when numerator is low and denomerator is high.
for example : x/y , 6/20 = 0.3. but when i give 20/6 it shows output is 1.
x = 6;
y = 20;
z = 0;
format long
k = zeros(20,3);
for i = 1:20
if x > 0
x = x - y*2^(-i);
z = z + 2^(-i);
else
x = x + y*2^(-i);
z = z - 2^(-i);
end
k(i,:) = [i 6/20 z];
end
Can anyone help ,how to design the divider using the cordic for higher number / Lower number (eg : 30/2).

채택된 답변

Walter Roberson
Walter Roberson 2022년 5월 18일
Do not start with i=1. Start with i being the negative of the number of bits before the decimal place.
I believe that your else is incorrect. I believe you should be working with 2^(-(i-1)) so that you "undo" the previous step
  댓글 수: 2
Walter Roberson
Walter Roberson 2022년 5월 19일
In the case where your numerator and denominator are both non-negative or both negative, then you expect a non-negative output; take the absolute values of numerator and denominator, set a flag indicating that you are expecting non-negative, and proceed.
In the case where either numerator or denominator are negative, but not both, then you expect a negative output; take the absolute values of numerator and demoninator, set a flag indicating that you are expecting negative, and proceed.
You are now certain to not be working with negative.
At each step, calculate
x_new = x - y*2^(-i);
If x_new is positive, then
x = x_new;
z = z + 2^(-i);
and otherwise do not change x or z; either way, continue the loop. Stop when x is 0.
Walter Roberson
Walter Roberson 2022년 5월 19일
oh, and at the end if the negative flag is set then take negative of the answer.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by