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

Re: [f-cpu] magnetude comparison




Yann Guidon a écrit :



Does anyone have an idea for it :) ?

this idea was investigated in the INC unit.

it's a sort of cascade/tree of ANDN or something like that.

it should be described in the manual.

hope this helps,

i've found this way:

function compare_vector(a, b : std_ulogic_vector(3 downto 0)) return std_ulogic is
variable ppp, vvv: std_ulogic_vector(3 downto 0);
variable pp, vv: std_ulogic_vector(1 downto 0);
variable p, v, swap: std_ulogic;
begin
-- (d=0/t=0)
for i in 3 downto 0 loop
ppp(i) := b(i);
vvv(i) := a(i) xor b(i);
end loop;
-- (d=1/t=2)
for i in 1 downto 0 loop
if (vvv(2*i+1)='1') then
pp(i) := ppp(2*i+1);
else
pp(i) := ppp(2*i);
end if;
vv(i) := vvv(2*i+1) or vvv(2*i);
end loop;
-- (d=2/t=3)
if (vv(1)='1') then
p := pp(1);
else
p := pp(0);
end if;
v := vv(1) or vvv(0);
-- (d=3/t=4)
swap := p and v;
-- (d=4/t=5)
print_vector("a", a);
print_vector("b", b);
print_stdval("p", p);
print_stdval("v", v);
print_stdval("swap?", swap); return swap; end;

it seems to work...

--

~~ 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/