Line 357... |
Line 357... |
|
|
--! Función que devuelve un vector en punto flotante IEEE754 a través de un
|
--! Función que devuelve un vector en punto flotante IEEE754 a través de un
|
function ap_slv_calc_xyvec (x,y:integer; cam:apCamera) return v3f;
|
function ap_slv_calc_xyvec (x,y:integer; cam:apCamera) return v3f;
|
|
|
--! Función que devuelve una cadena con el número flotante IEEE 754 ó a una cadena de cifras hexadecimales.
|
--! Función que devuelve una cadena con el número flotante IEEE 754 ó a una cadena de cifras hexadecimales.
|
function ap_slvf2string(sl:std_logic_vector) return string;
|
procedure ap_slvf2string(l:inout line;sl:std_logic_vector);
|
function ap_slv2hex (s:std_logic_vector) return string;
|
procedure ap_slv2hex (l:inout line;h:in std_logic_vector) ;
|
--! Función que devuelve una cadena con el estado de macState.
|
--! Función que devuelve una cadena con el estado de macState.
|
function ap_macState2string(s:macState) return string;
|
procedure ap_macState2string(l:inout line;s:in macState);
|
|
|
--! Función que devuelve la cadena de caracteres de 8 datos en punto flotante IEEE 754.
|
|
function ap_vblk082string(v8:vectorblock08) return string;
|
|
|
|
--! Función que devuelve la cadena de caracteres de 12 datos en punto flotante IEEE 754.
|
|
function ap_vblk122string(v12:vectorblock12) return string;
|
|
|
|
--! Función que convierte un array de 2 std_logic_vectors que contienen un par de direcciones en string
|
--! Función que convierte un array de 2 std_logic_vectors que contienen un par de direcciones en string
|
function ap_vnadd022string(va2:vectorblockadd02) return string;
|
procedure ap_vnadd022string(l:inout line; va2:in vectorblockadd02);
|
|
|
--! Función que devuelve una cadena de caracteres con el estado de la maquina de estados que controla las interrupciones
|
--! Función que devuelve una cadena de caracteres con el estado de la maquina de estados que controla las interrupciones
|
function ap_iCtrlState2string(i:iCtrlState) return string;
|
procedure ap_iCtrlState2string(l:inout line;i:in iCtrlState) ;
|
|
|
--! Función que devuelve una cadena con los componentes de un vector R3 en punto flotante IEEE754
|
--! Función que devuelve una cadena con los componentes de un vector R3 en punto flotante IEEE754
|
function ap_v3f2string(v:v3f) return string;
|
procedure ap_v3f2string(l:inout line;v:in v3f);
|
|
|
--! Función que formatea una instrucción
|
--! Función que formatea una instrucción
|
function ap_format_instruction(i:string;ac_o,bd_o,ac_f,bd_f:std_logic_vector;comb:std_logic) return std_logic_vector;
|
function ap_format_instruction(i:string;ac_o,bd_o,ac_f,bd_f:std_logic_vector;comb:std_logic) return std_logic_vector;
|
|
|
--! Función que devuelve una cadena de caracteres de un solo caracter con el valor de un bit std_logic
|
--! Función que devuelve una cadena de caracteres de un solo caracter con el valor de un bit std_logic
|
function ap_sl2string(s:std_logic) return string;
|
procedure ap_sl2string(l:inout line;s:std_logic);
|
|
|
|
--! Procedure
|
|
procedure ap_xfp122string(l:inout line;vb12:in vectorblock12);
|
|
procedure ap_xfp082string(l:inout line;vb08:in vectorblock08);
|
|
procedure ap_xfp062string(l:inout line;vb06:in vectorblock06);
|
|
procedure ap_xfp042string(l:inout line;vb04:in vectorblock04);
|
|
|
end package;
|
end package;
|
|
|
|
|
package body arithpack is
|
package body arithpack is
|
|
|
function ap_sl2string(s:std_logic) return string is
|
procedure ap_xfp122string(l:inout line; vb12:in vectorblock12) is
|
|
|
|
begin
|
|
write(l,string'("<< "));
|
|
for i in 11 downto 0 loop
|
|
write(l,string'(integer'image(i)));
|
|
write(l,string'(" "));
|
|
ap_slvf2string(l,vb12(i));
|
|
end loop;
|
|
write(l,string'(" >>"));
|
|
end procedure;
|
|
|
|
procedure ap_xfp082string(l:inout line; vb08:in vectorblock08) is
|
|
|
|
begin
|
|
write(l,string'("<< "));
|
|
for i in 07 downto 0 loop
|
|
write(l,string'(" ["&integer'image(i)&"]"));
|
|
write(l,string'(" "));
|
|
ap_slvf2string(l,vb08(i));
|
|
end loop;
|
|
write(l,string'(" >>"));
|
|
end procedure;
|
|
|
|
procedure ap_xfp062string(l:inout line; vb06:in vectorblock06) is
|
|
|
|
begin
|
|
write(l,string'("<< "));
|
|
for i in 05 downto 0 loop
|
|
write(l,string'(integer'image(i)));
|
|
write(l,string'(" "));
|
|
ap_slvf2string(l,vb06(i));
|
|
end loop;
|
|
write(l,string'(" >>"));
|
|
end procedure;
|
|
|
|
procedure ap_xfp042string(l:inout line; vb04:in vectorblock04) is
|
|
|
|
begin
|
|
write(l,string'("<< "));
|
|
for i in 03 downto 0 loop
|
|
write(l,string'(integer'image(i)));
|
|
write(l,string'(" "));
|
|
ap_slvf2string(l,vb04(i));
|
|
end loop;
|
|
write(l,string'(" >>"));
|
|
end procedure;
|
|
|
|
|
|
procedure ap_sl2string(l:inout line; s:in std_logic)is
|
variable tmp:string(1 to 1);
|
variable tmp:string(1 to 1);
|
begin
|
begin
|
|
|
case s is
|
case s is
|
when '1' =>
|
when '1' =>
|
Line 412... |
Line 461... |
when 'H' =>
|
when 'H' =>
|
tmp:="H";
|
tmp:="H";
|
when others =>
|
when others =>
|
tmp:="-"; -- Don't care
|
tmp:="-"; -- Don't care
|
end case;
|
end case;
|
|
write(l,string'("<< "));
|
|
write(l,string'(tmp));
|
|
write(l,string'(" >>"));
|
|
|
return tmp;
|
|
end function;
|
|
|
end procedure;
|
|
|
function ap_format_instruction(i:string;ac_o,bd_o,ac_f,bd_f:std_logic_vector;comb:std_logic) return std_logic_vector is
|
function ap_format_instruction(i:string;ac_o,bd_o,ac_f,bd_f:std_logic_vector;comb:std_logic) return std_logic_vector is
|
|
|
alias aco : std_logic_vector (4 downto 0) is ac_o;
|
alias aco : std_logic_vector (4 downto 0) is ac_o;
|
alias acf : std_logic_vector (4 downto 0) is ac_f;
|
alias acf : std_logic_vector (4 downto 0) is ac_f;
|
Line 429... |
Line 482... |
begin
|
begin
|
|
|
case it is
|
case it is
|
when "mag" =>
|
when "mag" =>
|
ins(31 downto 29) := "100";
|
ins(31 downto 29) := "100";
|
ins(04 downto 00) := x"18";
|
ins(04 downto 00) := '1'&x"8";
|
when "nrm" =>
|
when "nrm" =>
|
ins(31 downto 29) := "101";
|
ins(31 downto 29) := "101";
|
ins(04 downto 00) := x"1d";
|
ins(04 downto 00) := '1'&x"d";
|
when "add" =>
|
when "add" =>
|
ins(31 downto 29) := "001";
|
ins(31 downto 29) := "001";
|
ins(04 downto 00) := x"0a";
|
ins(04 downto 00) := '0'&x"a";
|
when "sub" =>
|
when "sub" =>
|
ins(31 downto 29) := "011";
|
ins(31 downto 29) := "011";
|
ins(04 downto 00) := x"0a";
|
ins(04 downto 00) := '0'&x"a";
|
when "dot" =>
|
when "dot" =>
|
ins(31 downto 29) := "000";
|
ins(31 downto 29) := "000";
|
ins(04 downto 00) := x"17";
|
ins(04 downto 00) := '1'&x"7";
|
when "crs" =>
|
when "crs" =>
|
ins(31 downto 29) := "010";
|
ins(31 downto 29) := "010";
|
ins(04 downto 00) := x"0e";
|
ins(04 downto 00) := '0'&x"e";
|
when others =>
|
when others =>
|
ins(31 downto 29) := "111";
|
ins(31 downto 29) := "111";
|
ins(04 downto 00) := x"05";
|
ins(04 downto 00) := '0'&x"5";
|
end case;
|
end case;
|
ins(28 downto 24) := aco;
|
ins(28 downto 24) := aco;
|
ins(23 downto 19) := acf;
|
ins(23 downto 19) := acf;
|
ins(18 downto 14) := bdo;
|
ins(18 downto 14) := bdo;
|
ins(13 downto 09) := bdf;
|
ins(13 downto 09) := bdf;
|
Line 462... |
Line 515... |
|
|
end function;
|
end function;
|
|
|
|
|
|
|
function ap_v3f2string(v:v3f) return string is
|
procedure ap_v3f2string(l:inout line;v:in v3f) is
|
variable tmp:string (1 to 1024);
|
|
begin
|
begin
|
tmp:="[X]"&ap_slvf2string(v(0))&"[Y]"&ap_slvf2string(v(1))&"[Z]"&ap_slvf2string(v(2));
|
write(l,string'("<< "));
|
return tmp;
|
for i in 02 downto 0 loop
|
end function;
|
write(l,string'(integer'image(i)));
|
|
write(l,string'(" "));
|
|
ap_slvf2string(l,v(i));
|
|
end loop;
|
|
write(l,string'(" >>"));
|
|
|
function ap_iCtrlState2string(i:iCtrlState) return string is
|
end procedure;
|
|
|
|
procedure ap_iCtrlState2string(l:inout line;i:in iCtrlState) is
|
variable tmp:string (1 to 9);
|
variable tmp:string (1 to 9);
|
|
|
begin
|
begin
|
|
|
|
write(l,string'("<< "));
|
case i is
|
case i is
|
when WAITING_FOR_AN_EVENT =>
|
when WAITING_FOR_AN_EVENT =>
|
tmp:="WAIT_EVNT";
|
tmp:="WAIT_EVNT";
|
when FIRING_INTERRUPTIONS =>
|
when FIRING_INTERRUPTIONS =>
|
tmp:="FIRE_INTx";
|
tmp:="FIRE_INTx";
|
when SUSPEND =>
|
when SUSPEND =>
|
tmp:="SUSPENDED";
|
tmp:="SUSPENDED";
|
when others =>
|
when others =>
|
tmp:="ILGL__VAL";
|
tmp:="ILGL__VAL";
|
end case;
|
end case;
|
|
write(l,string'(tmp));
|
|
write(l,string'(" >>"));
|
|
|
return tmp;
|
end procedure;
|
|
|
end function;
|
procedure ap_vnadd022string(l:inout line;va2:in vectorblockadd02) is
|
|
|
function ap_vnadd022string(va2:vectorblockadd02) return string is
|
|
variable tmp:string (1 to 1024);
|
|
begin
|
begin
|
tmp:="[01]"&ap_slv2hex(va2(1))&" [00]"&ap_slv2hex(va2(0));
|
|
return tmp;
|
|
end function;
|
|
|
|
function ap_vblk122string(v12:vectorblock12) return string is
|
write(l,string'("<<[1] "));
|
variable tmp:string (1 to 1024);
|
ap_slv2hex(l,va2(1));
|
begin
|
write(l,string'(" [0] "));
|
|
ap_slv2hex(l,va2(0));
|
|
write(l,string'(" >>"));
|
|
|
tmp:="["&integer'image(11)&"]";
|
end procedure;
|
for i in 11 downto 0 loop
|
|
tmp:=tmp&ap_slvf2string(v12(i));
|
|
if i>0 then
|
|
tmp:=tmp&"["&integer'image(i)&"]";
|
|
end if;
|
|
end loop;
|
|
return tmp;
|
|
|
|
|
|
end function;
|
|
|
|
function ap_vblk082string(v8:vectorblock08) return string is
|
|
variable tmp:string (1 to 1024);
|
|
begin
|
|
|
|
tmp:="["&integer'image(7)&"]";
|
procedure ap_macState2string(l:inout line;s:in macState) is
|
for i in 7 downto 0 loop
|
|
tmp:=tmp&ap_slvf2string(v8(i));
|
|
if i>0 then
|
|
tmp:=tmp&"["&integer'image(i)&"]";
|
|
end if;
|
|
end loop;
|
|
return tmp;
|
|
|
|
|
|
end function;
|
|
|
|
|
|
function ap_macState2string(s:macState) return string is
|
|
variable tmp:string (1 to 6);
|
variable tmp:string (1 to 6);
|
begin
|
begin
|
|
|
|
write(l,string'("<< "));
|
case s is
|
case s is
|
when LOAD_INSTRUCTION =>
|
when LOAD_INSTRUCTION =>
|
tmp:="LD_INS";
|
tmp:="LD_INS";
|
when FLUSH_ARITH_PIPELINE =>
|
when FLUSH_ARITH_PIPELINE =>
|
tmp:="FL_ARP";
|
tmp:="FL_ARP";
|
when EXECUTE_INSTRUCTION =>
|
when EXECUTE_INSTRUCTION =>
|
tmp:="EX_INS";
|
tmp:="EX_INS";
|
when others =>
|
when others =>
|
tmp:="HEL_ON";
|
tmp:="HEL_ON";
|
end case;
|
end case;
|
return tmp;
|
write(l,string'(tmp));
|
end function;
|
write(l,string'(" >>"));
|
|
|
|
end procedure;
|
|
|
constant hexchars : string (1 to 16) := "0123456789ABCDEF";
|
constant hexchars : string (1 to 16) := "0123456789ABCDEF";
|
function ap_slv2hex (s:std_logic_vector) return string is
|
procedure ap_slv2hex (l:inout line;h:in std_logic_vector) is
|
variable x64 : std_logic_vector(63 downto 0):=x"0000000000000000";
|
variable index_high,index_low,highone,nc : integer;
|
variable str : string (1 to 16);
|
begin
|
begin
|
highone := h'high-h'low;
|
x64(s'high downto s'low):=s;
|
nc:=0;
|
for i in 15 downto 0 loop
|
for i in h'high downto h'low loop
|
str(i+1):=hexchars(1+ieee.std_logic_unsigned.conv_integer(x64(i*4+3 downto i*4)));
|
if h(i)/='0' and h(i)/='1' then
|
|
nc:=1;
|
|
end if;
|
end loop;
|
end loop;
|
return str;
|
|
end function;
|
if nc=1 then
|
|
for i in h'high downto h'low loop
|
|
ap_sl2string(l,h(i));
|
|
end loop;
|
|
else
|
|
for i in (highone)/4 downto 0 loop
|
|
index_low:=i*4;
|
|
if (index_low+3)>highone then
|
|
index_high := highone;
|
|
else
|
|
index_high := i*4+3;
|
|
end if;
|
|
write(l,hexchars(1+ieee.std_logic_unsigned.conv_integer(h(index_high+h'low downto index_low+h'low))));
|
|
end loop;
|
|
end if;
|
|
end procedure;
|
|
|
function ap_slv2int (sl:std_logic_vector) return integer is
|
function ap_slv2int (sl:std_logic_vector) return integer is
|
alias s : std_logic_vector (sl'high downto sl'low) is sl;
|
alias s : std_logic_vector (sl'high downto sl'low) is sl;
|
variable i : integer;
|
variable i : integer;
|
begin
|
begin
|
Line 580... |
Line 630... |
variable sef : std_logic_vector (31 downto 0);
|
variable sef : std_logic_vector (31 downto 0);
|
begin
|
begin
|
--! Signo
|
--! Signo
|
if (f<0.0) then
|
if (f<0.0) then
|
sef(31) := '1';
|
sef(31) := '1';
|
|
faux:=f*(-1.0);
|
else
|
else
|
sef(31) := '0';
|
sef(31) := '0';
|
|
faux:=f;
|
end if;
|
end if;
|
|
|
--! Exponente
|
--! Exponente
|
sef(30 downto 23) := conv_std_logic_vector(integer(floor(log(f,2.0))),8);
|
sef(30 downto 23) := conv_std_logic_vector(127+integer(floor(log(faux,2.0))),8);
|
|
|
--! Fraction
|
--! Fraction
|
faux :=f/floor(log(f,2.0));
|
faux :=faux/(2.0**real(floor(log(faux,2.0))));
|
faux := faux - 1.0;
|
faux := faux - 1.0;
|
|
|
sef(22 downto 0) := conv_std_logic_vector(integer(faux),23);
|
sef(22 downto 0) := conv_std_logic_vector(integer(faux*(2.0**23.0)),23);
|
|
|
return sef;
|
return sef;
|
|
|
end function;
|
end function;
|
|
|
function ap_slv2fp(sl:std_logic_vector) return real is
|
function ap_slv2fp(sl:std_logic_vector) return real is
|
variable expo,frc:integer;
|
variable frc:integer;
|
alias s: std_logic_vector(31 downto 0) is sl;
|
alias s: std_logic_vector(31 downto 0) is sl;
|
variable f: real;
|
variable f,expo: real;
|
|
|
begin
|
begin
|
|
|
|
|
expo:=ap_slv2int(s(30 downto 23)) - 127;
|
expo:=real(ap_slv2int(s(30 downto 23)) - 127);
|
expo:=2**expo;
|
expo:=(2.0)**(expo);
|
frc:=ap_slv2int('1'&s(22 downto 0));
|
frc:=ap_slv2int('1'&s(22 downto 0));
|
f:=real(frc)*(2.0**(-23.0));
|
f:=real(frc)*(2.0**(-23.0));
|
f:=f*real(expo);
|
f:=f*real(expo);
|
|
|
if s(31)='1' then
|
if s(31)='1' then
|
Line 618... |
Line 670... |
else
|
else
|
return f;
|
return f;
|
end if;
|
end if;
|
|
|
|
|
|
|
|
|
end function;
|
end function;
|
|
|
function ap_slv_calc_xyvec (x,y:integer; cam:apCamera) return v3f is
|
function ap_slv_calc_xyvec (x,y:integer; cam:apCamera) return v3f is
|
|
|
|
|
Line 630... |
Line 684... |
begin
|
begin
|
|
|
dx := cam.width/real(cam.resx);
|
dx := cam.width/real(cam.resx);
|
dy := cam.height/real(cam.resy);
|
dy := cam.height/real(cam.resy);
|
|
|
--! Eje X: Tomando el dedo índice de la mano derecha, este eje queda apuntando en la direcci&on en la que mira la cámara u observador siempre.
|
--! Eje Z: Tomando el dedo índice de la mano derecha, este eje queda apuntando en la direcci&on en la que mira la cámara u observador siempre.
|
v(0):=ap_fp2slv(cam.dist);
|
v(0):=ap_fp2slv(cam.dist);
|
|
|
--! Eje Y: Tomando el dedo corazón de la mano derecha, este eje queda apuntando a la izquierda del observador, desde el observador.
|
--! Eje X: Tomando el dedo corazón de la mano derecha, este eje queda apuntando a la izquierda del observador, desde el observador.
|
v(1):=ap_fp2slv(dx*real(cam.resx)*0.5-dx*0.5);
|
v(2):=ap_fp2slv(dx*real(cam.resx)*0.5-real(x)*dx-dx*0.5);
|
|
|
--! Eje Z: Tomando el dedo pulgar de la mano derecha, este eje queda apuntando hacia arriba del observador, desde el observador.
|
--! Eje Y: Tomando el dedo pulgar de la mano derecha, este eje queda apuntando hacia arriba del observador, desde el observador.
|
v(2):=ap_fp2slv(dy*real(cam.resy)*0.5-dy*0.5);
|
v(1):=ap_fp2slv(dy*real(cam.resy)*0.5-real(y)*dy-dy*0.5);
|
|
|
return v;
|
return v;
|
|
|
end function;
|
end function;
|
|
|
function ap_slvf2string(sl:std_logic_vector) return string is
|
procedure ap_slvf2string(l:inout line;sl:std_logic_vector) is
|
alias f: std_logic_vector(31 downto 0) is sl;
|
alias f: std_logic_vector(31 downto 0) is sl;
|
variable r: real;
|
variable r: real;
|
|
|
begin
|
begin
|
|
|
r:=ap_slv2fp(f);
|
r:=ap_slv2fp(f);
|
return real'image(r);
|
write(l,string'(real'image(r)));
|
|
write(l,string'(" [ s:"));
|
|
ap_slv2hex(l,f(31 downto 31));
|
|
write(l,string'(" f: "));
|
|
ap_slv2hex(l,f(30 downto 23));
|
|
write(l,string'(" m: "));
|
|
ap_slv2hex(l,f(22 downto 00));
|
|
write(l,string'(" ]"));
|
|
|
end function;
|
end procedure;
|
|
|
|
|
|
|
|
|
end package body;
|
end package body;
|
No newline at end of file
|
No newline at end of file
|