[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [f-cpu] magnetude comparison




Michael Riepe a écrit :

On Sun, Feb 29, 2004 at 08:50:39PM +0100, gaetan@xeberon.net wrote:
[...]

i've found this way:

function compare_vector(a, b : std_ulogic_vector(3 downto 0)) return std_ulogic is

[...]

it seems to work...

For vectors of four(!) bits, yes.


what do you think about this new version:

-- estimated delay
-- 2 < L <= 4 : d=4/t=5
-- 5 < L <= 8 : d=5/t=6
-- 9 < L <= 16 : d=6/t=7
-- 17 < L <= 32 : d=7/t=8
-- 33 < L <= 64 : d=8/t=9
function compare_vector(a, b : std_ulogic_vector) return std_ulogic is
constant L : natural := a'length;
constant aa : std_ulogic_vector(L-1 downto 0) := a;
constant bb : std_ulogic_vector(L-1 downto 0) := b;
variable pp, vv: std_ulogic_vector(L-1 downto 0);
variable p, v, swap : std_ulogic;
variable step, level, left : natural;
begin

-- (d=0/t=0)
for i in L-1 downto 0 loop
pp(i) := b(i);
vv(i) := a(i) xor b(i);
end loop;
-- (d=1/t=2)
for level in 1 to 15 loop
step := 2**level;
left := L/step;
for i in 0 to left-1 loop
if (vv(2*i)='0') then
pp(i) := pp(2*i+1);
else
pp(i) := pp(2*i);
end if; -- d=1/t=1
vv(i) := vv(2*i+1) or vv(2*i); -- d=1/t=1
end loop;
exit when step >= L;
-- cost for each loop : d=1/t=1
end loop;
swap := pp(0) and vv(0); -- d=1/t=1

-- print_vector("a", a); -- print_vector("b", b); -- print_stdval("swap?", swap); return swap; end;

i estimate the delay around 7 or 8 bits for 32 bit or 64 bit. It's easy to cut between the first and second stage...
it's not I don't want to use your way with the compound adder, but i have a method using Leading One Predictor
(which assumed than mantissa A should be greater than mantissa B, and so, the problem is when exponents
are equals, the document i have use a comparator. I propose to put it in the first stage). I use a compound adder
anyway (for rounding, not for normalization).
With leading one predictor, it's really fast to get the number of shift to apply to the mantissa in the normalisation
process.
See the document:
http://citeseer.nj.nec.com/bruguera98rounding.html
page 6 for a schematic...


--

~~ Gaetan ~~
http://www.xeberon.net


*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu in the body. http://f-cpu.seul.org/