1 |
151 |
jguarin200 |
library ieee;
|
2 |
|
|
use ieee.std_logic_1164.all;
|
3 |
153 |
jguarin200 |
use ieee.std_logic_arith.all;
|
4 |
|
|
use ieee.math_real.all;
|
5 |
151 |
jguarin200 |
|
6 |
153 |
jguarin200 |
library std;
|
7 |
|
|
use std.textio.all;
|
8 |
|
|
|
9 |
151 |
jguarin200 |
--! Memory Compiler Library
|
10 |
|
|
library lpm;
|
11 |
|
|
use lpm.all;
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
package arithpack is
|
16 |
|
|
--! Estados para la maquina de estados.
|
17 |
|
|
type macState is (LOAD_INSTRUCTION,FLUSH_ARITH_PIPELINE,EXECUTE_INSTRUCTION);
|
18 |
|
|
--! Estados para el controlador de interrupciones.
|
19 |
|
|
type iCtrlState is (WAITING_FOR_AN_EVENT,FIRING_INTERRUPTIONS,SUSPEND);
|
20 |
152 |
jguarin200 |
|
21 |
|
|
--! Float data blocks
|
22 |
|
|
constant floatwidth : integer := 32;
|
23 |
|
|
constant widthadmemblock : integer := 9;
|
24 |
|
|
|
25 |
|
|
type vectorblock12 is array (11 downto 0) of std_logic_vector(floatwidth-1 downto 0);
|
26 |
|
|
type vectorblock08 is array (07 downto 0) of std_logic_vector(floatwidth-1 downto 0);
|
27 |
|
|
type vectorblock06 is array (05 downto 0) of std_logic_vector(floatwidth-1 downto 0);
|
28 |
|
|
type vectorblock04 is array (03 downto 0) of std_logic_vector(floatwidth-1 downto 0);
|
29 |
|
|
type vectorblock03 is array (02 downto 0) of std_logic_vector(floatwidth-1 downto 0);
|
30 |
|
|
type vectorblock02 is array (01 downto 0) of std_logic_vector(floatwidth-1 downto 0);
|
31 |
|
|
type vectorblockadd02 is array (01 downto 0) of std_logic_vector(widthadmemblock-1 downto 0);
|
32 |
|
|
|
33 |
153 |
jguarin200 |
type v3f is array(02 downto 0) of std_logic_vector(31 downto 0);
|
34 |
152 |
jguarin200 |
|
35 |
153 |
jguarin200 |
|
36 |
|
|
|
37 |
151 |
jguarin200 |
--! Constante de reseteo
|
38 |
|
|
constant rstMasterValue : std_logic :='0';
|
39 |
|
|
--! Constantes periodicas.
|
40 |
|
|
constant tclk : time := 20 ns;
|
41 |
|
|
constant tclk_2 : time := tclk/2;
|
42 |
|
|
constant tclk_4 : time := tclk/4;
|
43 |
|
|
|
44 |
152 |
jguarin200 |
|
45 |
|
|
component raytrac
|
46 |
|
|
port (
|
47 |
|
|
|
48 |
|
|
clk : in std_logic;
|
49 |
|
|
rst : in std_logic;
|
50 |
|
|
|
51 |
|
|
--! Señal de lectura de alguna de las colas de resultados.
|
52 |
|
|
rd : in std_logic;
|
53 |
|
|
|
54 |
|
|
--! Señal de escritura en alguno de los bloques de memoria de operandos o en la cola de instrucciones.
|
55 |
|
|
wr : in std_logic;
|
56 |
|
|
|
57 |
|
|
--! Direccion de escritura o lectura
|
58 |
|
|
add : in std_logic_vector (12 downto 0);
|
59 |
|
|
|
60 |
|
|
--! datos de entrada
|
61 |
|
|
d : in std_logic_vector (31 downto 0);
|
62 |
|
|
|
63 |
|
|
--! Interrupciones
|
64 |
|
|
int : out std_logic_vector (7 downto 0);
|
65 |
|
|
|
66 |
|
|
--! Salidas
|
67 |
|
|
q : out std_logic_vector (31 downto 0)
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
);
|
72 |
|
|
end component;
|
73 |
|
|
|
74 |
|
|
--! Componentes Aritméticos
|
75 |
|
|
|
76 |
|
|
component fadd32
|
77 |
|
|
port (
|
78 |
|
|
clk : in std_logic;
|
79 |
|
|
dpc : in std_logic;
|
80 |
|
|
a32 : in std_logic_vector (31 downto 0);
|
81 |
|
|
b32 : in std_logic_vector (31 downto 0);
|
82 |
|
|
c32 : out std_logic_vector (31 downto 0)
|
83 |
|
|
);
|
84 |
|
|
end component;
|
85 |
|
|
component fmul32
|
86 |
|
|
port (
|
87 |
|
|
clk : in std_logic;
|
88 |
|
|
a32 : in std_logic_vector (31 downto 0);
|
89 |
|
|
b32 : in std_logic_vector (31 downto 0);
|
90 |
|
|
p32 : out std_logic_vector (31 downto 0)
|
91 |
|
|
);
|
92 |
|
|
end component;
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
--! Contadores para la máquina de estados.
|
96 |
|
|
|
97 |
151 |
jguarin200 |
component customCounter
|
98 |
|
|
generic (
|
99 |
|
|
EOBFLAG : string ;
|
100 |
|
|
ZEROFLAG : string ;
|
101 |
|
|
BACKWARDS : string ;
|
102 |
|
|
EQUALFLAG : string ;
|
103 |
|
|
subwidth : integer;
|
104 |
|
|
width : integer
|
105 |
|
|
|
106 |
|
|
);
|
107 |
|
|
port (
|
108 |
|
|
clk,rst,go,set : in std_logic;
|
109 |
|
|
setValue,cmpBlockValue : in std_Logic_vector(width-1 downto subwidth);
|
110 |
|
|
zero_flag,eob_flag,eq_flag : out std_logic;
|
111 |
|
|
count : out std_logic_vector(width-1 downto 0)
|
112 |
|
|
);
|
113 |
|
|
end component;
|
114 |
|
|
|
115 |
155 |
jguarin200 |
--! LPM_MULTIPLIER
|
116 |
|
|
component lpm_mult
|
117 |
|
|
generic (
|
118 |
|
|
lpm_hint : string;
|
119 |
|
|
lpm_pipeline : natural;
|
120 |
|
|
lpm_representation : string;
|
121 |
|
|
lpm_type : string;
|
122 |
|
|
lpm_widtha : natural;
|
123 |
|
|
lpm_widthb : natural;
|
124 |
|
|
lpm_widthp : natural
|
125 |
|
|
);
|
126 |
|
|
port (
|
127 |
|
|
dataa : in std_logic_vector ( lpm_widtha-1 downto 0 );
|
128 |
|
|
datab : in std_logic_vector ( lpm_widthb-1 downto 0 );
|
129 |
|
|
result : out std_logic_vector( lpm_widthp-1 downto 0 )
|
130 |
|
|
);
|
131 |
|
|
end component;
|
132 |
151 |
jguarin200 |
--! LPM Memory Compiler.
|
133 |
|
|
component scfifo
|
134 |
|
|
generic (
|
135 |
|
|
add_ram_output_register :string;
|
136 |
|
|
almost_full_value :natural;
|
137 |
|
|
allow_wrcycle_when_full :string;
|
138 |
|
|
intended_device_family :string;
|
139 |
|
|
lpm_hint :string;
|
140 |
|
|
lpm_numwords :natural;
|
141 |
|
|
lpm_showahead :string;
|
142 |
|
|
lpm_type :string;
|
143 |
|
|
lpm_width :natural;
|
144 |
|
|
lpm_widthu :natural;
|
145 |
|
|
overflow_checking :string;
|
146 |
|
|
underflow_checking :string;
|
147 |
|
|
use_eab :string
|
148 |
|
|
);
|
149 |
|
|
port(
|
150 |
|
|
rdreq : in std_logic;
|
151 |
|
|
aclr : in std_logic;
|
152 |
|
|
empty : out std_logic;
|
153 |
|
|
clock : in std_logic;
|
154 |
|
|
q : out std_logic_vector(lpm_width-1 downto 0);
|
155 |
|
|
wrreq : in std_logic;
|
156 |
|
|
data : in std_logic_vector(lpm_width-1 downto 0);
|
157 |
|
|
almost_full : out std_logic;
|
158 |
|
|
full : out std_logic
|
159 |
|
|
);
|
160 |
|
|
end component;
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
component altsyncram
|
164 |
|
|
generic (
|
165 |
|
|
address_aclr_b : string;
|
166 |
|
|
address_reg_b : string;
|
167 |
|
|
clock_enable_input_a : string;
|
168 |
|
|
clock_enable_input_b : string;
|
169 |
|
|
clock_enable_output_b : string;
|
170 |
|
|
intended_device_family : string;
|
171 |
|
|
lpm_type : string;
|
172 |
|
|
numwords_a : natural;
|
173 |
|
|
numwords_b : natural;
|
174 |
|
|
operation_mode : string;
|
175 |
|
|
outdata_aclr_b : string;
|
176 |
|
|
outdata_reg_b : string;
|
177 |
|
|
power_up_uninitialized : string;
|
178 |
|
|
ram_block_type : string;
|
179 |
|
|
rdcontrol_reg_b : string;
|
180 |
|
|
read_during_write_mode_mixed_ports : string;
|
181 |
|
|
widthad_a : natural;
|
182 |
|
|
widthad_b : natural;
|
183 |
|
|
width_a : natural;
|
184 |
|
|
width_b : natural;
|
185 |
|
|
width_byteena_a : natural
|
186 |
|
|
);
|
187 |
|
|
port (
|
188 |
|
|
wren_a : in std_logic;
|
189 |
|
|
clock0 : in std_logic;
|
190 |
|
|
address_a : in std_logic_vector(8 downto 0);
|
191 |
|
|
address_b : in std_logic_vector(8 downto 0);
|
192 |
|
|
rden_b : in std_logic;
|
193 |
|
|
q_b : out std_logic_vector(31 downto 0);
|
194 |
|
|
data_a : in std_logic_vector(31 downto 0)
|
195 |
|
|
|
196 |
|
|
);
|
197 |
|
|
end component;
|
198 |
|
|
|
199 |
|
|
--! Maquina de Estados.
|
200 |
|
|
component sm
|
201 |
152 |
jguarin200 |
|
202 |
151 |
jguarin200 |
port (
|
203 |
|
|
|
204 |
|
|
--! Señales normales de secuencia.
|
205 |
|
|
clk,rst: in std_logic;
|
206 |
152 |
jguarin200 |
--! Vector con las instrucción codficada
|
207 |
151 |
jguarin200 |
instrQq:in std_logic_vector(31 downto 0);
|
208 |
152 |
jguarin200 |
--! Señal de cola vacia.
|
209 |
151 |
jguarin200 |
instrQ_empty:in std_logic;
|
210 |
|
|
adda,addb:out std_logic_vector (8 downto 0);
|
211 |
|
|
sync_chain_0,instrRdAckd:out std_logic;
|
212 |
|
|
full_r: in std_logic; --! Indica que la cola de resultados no puede aceptar mas de 32 elementos.
|
213 |
|
|
--! End Of Instruction Event
|
214 |
|
|
eoi : out std_logic;
|
215 |
|
|
|
216 |
|
|
--! DataPath Control uca code.
|
217 |
|
|
dpc_uca : out std_logic_vector (2 downto 0);
|
218 |
|
|
state : out macState
|
219 |
|
|
);
|
220 |
|
|
end component;
|
221 |
|
|
--! Maquina de Interrupciones
|
222 |
|
|
component im
|
223 |
|
|
generic (
|
224 |
|
|
num_events : integer ;
|
225 |
|
|
cycles_to_wait : integer
|
226 |
|
|
);
|
227 |
|
|
port (
|
228 |
|
|
clk,rst: in std_logic;
|
229 |
|
|
rfull_events: in std_logic_vector(num_events-1 downto 0); --! full results queue events
|
230 |
|
|
eoi_events: in std_logic_vector(num_events-1 downto 0); --! end of instruction related events
|
231 |
|
|
eoi_int: out std_logic_vector(num_events-1 downto 0);--! end of instruction related interruptions
|
232 |
|
|
rfull_int: out std_logic_vector(num_events-1downto 0); --! full results queue related interruptions
|
233 |
|
|
state: out iCtrlState
|
234 |
|
|
);
|
235 |
|
|
end component;
|
236 |
|
|
--! Bloque de memorias
|
237 |
|
|
component memblock
|
238 |
|
|
generic (
|
239 |
|
|
blocksize : integer;
|
240 |
|
|
external_writeable_blocks : integer;
|
241 |
|
|
external_readable_blocks : integer;
|
242 |
|
|
external_readable_widthad : integer;
|
243 |
|
|
external_writeable_widthad : integer
|
244 |
|
|
);
|
245 |
|
|
port (
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
clk,rst,dpfifo_rd,normfifo_rd,dpfifo_wr,normfifo_wr : in std_logic;
|
249 |
|
|
instrfifo_rd : in std_logic;
|
250 |
|
|
resultfifo_wr: in std_logic_vector(external_readable_blocks-1 downto 0);
|
251 |
|
|
instrfifo_empty: out std_logic; ext_rd,ext_wr: in std_logic;
|
252 |
|
|
ext_wr_add : in std_logic_vector(external_writeable_widthad+widthadmemblock-1 downto 0);
|
253 |
|
|
ext_rd_add : in std_logic_vector(external_readable_widthad-1 downto 0);
|
254 |
152 |
jguarin200 |
ext_d: in std_logic_vector(floatwidth-1 downto 0);
|
255 |
|
|
int_d : in std_logic_vector(external_readable_blocks*floatwidth-1 downto 0);
|
256 |
151 |
jguarin200 |
resultfifo_full : out std_logic_vector(3 downto 0);
|
257 |
152 |
jguarin200 |
ext_q,instrfifo_q : out std_logic_vector(floatwidth-1 downto 0);
|
258 |
|
|
int_q : out std_logic_vector(external_writeable_blocks*floatwidth-1 downto 0);
|
259 |
151 |
jguarin200 |
int_rd_add : in std_logic_vector(2*widthadmemblock-1 downto 0);
|
260 |
152 |
jguarin200 |
dpfifo_d : in std_logic_vector(floatwidth*2-1 downto 0);
|
261 |
|
|
normfifo_d : in std_logic_vector(floatwidth*3-1 downto 0);
|
262 |
|
|
dpfifo_q : out std_logic_vector(floatwidth*2-1 downto 0);
|
263 |
|
|
normfifo_q : out std_logic_vector(floatwidth*3-1 downto 0)
|
264 |
151 |
jguarin200 |
);
|
265 |
|
|
end component;
|
266 |
|
|
--! Bloque decodificacion DataPath Control.
|
267 |
|
|
component dpc
|
268 |
|
|
port (
|
269 |
|
|
clk,rst : in std_logic;
|
270 |
152 |
jguarin200 |
paraminput : in std_logic_vector ((12*floatwidth)-1 downto 0); --! Vectores A,B,C,D
|
271 |
|
|
prd32blko : in std_logic_vector ((06*floatwidth)-1 downto 0); --! Salidas de los 6 multiplicadores.
|
272 |
|
|
add32blko : in std_logic_vector ((04*floatwidth)-1 downto 0); --! Salidas de los 4 sumadores.
|
273 |
|
|
sqr32blko,inv32blko : in std_logic_vector (floatwidth-1 downto 0); --! Salidas de la raiz cuadradas y el inversor.
|
274 |
|
|
fifo32x23_q : in std_logic_vector (03*floatwidth-1 downto 0); --! Salida de la cola intermedia.
|
275 |
|
|
fifo32x09_q : in std_logic_vector (02*floatwidth-1 downto 0); --! Salida de las colas de producto punto.
|
276 |
151 |
jguarin200 |
unary,crossprod,addsub : in std_logic; --! Bit con el identificador del bloque AB vs CD e identificador del sub bloque (A/B) o (C/D).
|
277 |
152 |
jguarin200 |
sync_chain_0 : in std_logic; --! Señal de dato valido que se va por toda la cadena de sincronizacion.
|
278 |
|
|
eoi_int : in std_logic; --! Señal de interrupción de final de instrucci&ocaute;n.
|
279 |
|
|
eoi_demuxed_int : out std_logic_vector (3 downto 0); --! Señal de interrup&ocaute;n de final de instrucción pero esta vez va asociada a la instruccón UCA.
|
280 |
|
|
sqr32blki,inv32blki : out std_logic_vector (floatwidth-1 downto 0); --! Salidas de las 2 raices cuadradas y los 2 inversores.
|
281 |
|
|
fifo32x26_d : out std_logic_vector (03*floatwidth-1 downto 0); --! Entrada a la cola intermedia para la normalización.
|
282 |
|
|
fifo32x09_d : out std_logic_vector (02*floatwidth-1 downto 0); --! Entrada a las colas intermedias del producto punto.
|
283 |
|
|
prd32blki : out std_logic_vector ((12*floatwidth)-1 downto 0); --! Entrada de los 12 factores en el bloque de multiplicación respectivamente.
|
284 |
|
|
add32blki : out std_logic_vector ((08*floatwidth)-1 downto 0); --! Entrada de los 8 sumandos del bloque de 4 sumadores.
|
285 |
151 |
jguarin200 |
resw : out std_logic_vector (4 downto 0); --! Salidas de escritura y lectura en las colas de resultados.
|
286 |
|
|
fifo32x09_w : out std_logic;
|
287 |
|
|
fifo32x23_w,fifo32x09_r : out std_logic;
|
288 |
|
|
fifo32x23_r : out std_logic;
|
289 |
|
|
resf_vector : in std_logic_vector(3 downto 0); --! Entradas de la señal de full de las colas de resultados.
|
290 |
|
|
resf_event : out std_logic; --! Salida decodificada que indica que la cola de resultados de la operación que está en curso.
|
291 |
152 |
jguarin200 |
resultoutput : out std_logic_vector ((08*floatwidth)-1 downto 0) --! 8 salidas de resultados, pues lo máximo que podrá calcularse por cada clock son 2 vectores.
|
292 |
151 |
jguarin200 |
);
|
293 |
|
|
end component;
|
294 |
|
|
--! Bloque Aritmetico de Sumadores y Multiplicadores (madd)
|
295 |
|
|
component arithblock
|
296 |
|
|
port (
|
297 |
|
|
|
298 |
|
|
clk : in std_logic;
|
299 |
|
|
rst : in std_logic;
|
300 |
|
|
|
301 |
|
|
dpc : in std_logic;
|
302 |
|
|
|
303 |
|
|
f : in std_logic_vector (12*32-1 downto 0);
|
304 |
|
|
a : in std_logic_vector (8*32-1 downto 0);
|
305 |
|
|
|
306 |
|
|
s : out std_logic_vector (4*32-1 downto 0);
|
307 |
|
|
p : out std_logic_vector (6*32-1 downto 0)
|
308 |
|
|
|
309 |
|
|
);
|
310 |
|
|
end component;
|
311 |
|
|
--! Bloque de Raiz Cuadrada
|
312 |
|
|
component sqrt32
|
313 |
|
|
port (
|
314 |
|
|
|
315 |
|
|
clk : in std_logic;
|
316 |
|
|
rd32: in std_logic_vector(31 downto 0);
|
317 |
|
|
sq32: out std_logic_vector(31 downto 0)
|
318 |
|
|
);
|
319 |
|
|
end component;
|
320 |
|
|
--! Bloque de Inversores.
|
321 |
|
|
component invr32
|
322 |
|
|
port (
|
323 |
|
|
|
324 |
|
|
clk : in std_logic;
|
325 |
|
|
dvd32 : in std_logic_vector(31 downto 0);
|
326 |
|
|
qout32 : out std_logic_vector(31 downto 0)
|
327 |
|
|
);
|
328 |
|
|
end component;
|
329 |
153 |
jguarin200 |
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
type apCamera is record
|
334 |
|
|
resx,resy : integer;
|
335 |
|
|
width,height : real;
|
336 |
|
|
dist : real;
|
337 |
|
|
end record;
|
338 |
|
|
|
339 |
|
|
--! Función que convierte un std_logic_vector en un numero entero
|
340 |
|
|
function ap_slv2int(sl:std_logic_vector) return integer;
|
341 |
|
|
|
342 |
|
|
--! Función que convierte un número flotante IEE754 single float, en un número std_logic_vector.
|
343 |
|
|
function ap_fp2slv (f:real) return std_logic_vector;
|
344 |
|
|
|
345 |
|
|
--! Función que convierte un número std_logic_vector en un ieee754 single float.
|
346 |
|
|
function ap_slv2fp (sl:std_logic_vector) return real;
|
347 |
|
|
|
348 |
|
|
--! Función que devuelve un vector en punto flotante IEEE754 a través de un
|
349 |
|
|
function ap_slv_calc_xyvec (x,y:integer; cam:apCamera) return v3f;
|
350 |
|
|
|
351 |
155 |
jguarin200 |
--! Función que devuelve una cadena con el número flotante IEEE 754.
|
352 |
|
|
function ap_slvf2string(sl:std_logic_vector) return string;
|
353 |
153 |
jguarin200 |
|
354 |
155 |
jguarin200 |
--! Función para escribir en una sola línea una cadena de caracteres.
|
355 |
|
|
procedure ap_print(f:in text;s:in string);
|
356 |
153 |
jguarin200 |
|
357 |
|
|
|
358 |
|
|
|
359 |
151 |
jguarin200 |
end package;
|
360 |
153 |
jguarin200 |
|
361 |
|
|
|
362 |
|
|
package body arithpack is
|
363 |
|
|
|
364 |
155 |
jguarin200 |
procedure ap_print(f:in text;s:in string) is
|
365 |
|
|
variable l:line;
|
366 |
|
|
begin
|
367 |
|
|
write(l,s);
|
368 |
|
|
writeline(f,l);
|
369 |
|
|
end procedure
|
370 |
|
|
|
371 |
153 |
jguarin200 |
function ap_slv2int (sl:std_logic_vector) return integer is
|
372 |
|
|
alias s : std_logic_vector (sl'high downto sl'low) is sl;
|
373 |
|
|
variable i : integer;
|
374 |
|
|
begin
|
375 |
|
|
i:=0;
|
376 |
|
|
for index in s'high downto s'low loop
|
377 |
|
|
if s(index)='1' then
|
378 |
|
|
i:=i*2+1;
|
379 |
|
|
else
|
380 |
|
|
i:=i*2;
|
381 |
|
|
end if;
|
382 |
|
|
end loop;
|
383 |
|
|
return i;
|
384 |
|
|
|
385 |
|
|
end function;
|
386 |
|
|
function ap_fp2slv (f:real) return std_logic_vector is
|
387 |
|
|
variable faux : real;
|
388 |
|
|
variable sef : std_logic_vector (31 downto 0);
|
389 |
|
|
begin
|
390 |
|
|
--! Signo
|
391 |
|
|
if (f<0.0) then
|
392 |
|
|
sef(31) := '1';
|
393 |
|
|
else
|
394 |
|
|
sef(31) := '0';
|
395 |
|
|
end if;
|
396 |
|
|
|
397 |
|
|
--! Exponente
|
398 |
|
|
sef(30 downto 23) := conv_std_logic_vector(integer(floor(log(f,2.0))),8);
|
399 |
|
|
|
400 |
|
|
--! Fraction
|
401 |
|
|
faux :=f/floor(log(f,2.0));
|
402 |
|
|
faux := faux - 1.0;
|
403 |
|
|
|
404 |
|
|
sef(22 downto 0) := conv_std_logic_vector(integer(faux),23);
|
405 |
|
|
|
406 |
|
|
return sef;
|
407 |
|
|
|
408 |
|
|
end function;
|
409 |
|
|
|
410 |
|
|
function ap_slv2fp(sl:std_logic_vector) return real is
|
411 |
|
|
variable expo,frc:integer;
|
412 |
|
|
alias s: std_logic_vector(31 downto 0) is sl;
|
413 |
|
|
variable f: real;
|
414 |
|
|
|
415 |
|
|
begin
|
416 |
|
|
|
417 |
|
|
|
418 |
|
|
expo:=ap_slv2int(s(30 downto 23)) - 127;
|
419 |
|
|
expo:=2**expo;
|
420 |
|
|
frc:=ap_slv2int('1'&s(22 downto 0));
|
421 |
|
|
f:=real(frc)*(2.0**(-23.0));
|
422 |
|
|
f:=f*real(expo);
|
423 |
|
|
|
424 |
|
|
if s(31)='1' then
|
425 |
|
|
return -f;
|
426 |
|
|
else
|
427 |
|
|
return f;
|
428 |
|
|
end if;
|
429 |
|
|
|
430 |
|
|
|
431 |
|
|
end function;
|
432 |
|
|
|
433 |
|
|
function ap_slv_calc_xyvec (x,y:integer; cam:apCamera) return v3f is
|
434 |
|
|
|
435 |
|
|
|
436 |
|
|
variable dx,dy : real;
|
437 |
|
|
variable v : v3f;
|
438 |
|
|
begin
|
439 |
|
|
|
440 |
|
|
dx := cam.width/real(cam.resx);
|
441 |
|
|
dy := cam.height/real(cam.resy);
|
442 |
|
|
|
443 |
|
|
--! 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.
|
444 |
|
|
v(0):=ap_fp2slv(cam.dist);
|
445 |
|
|
|
446 |
|
|
--! Eje Y: Tomando el dedo corazón de la mano derecha, este eje queda apuntando a la izquierda del observador, desde el observador.
|
447 |
|
|
v(1):=ap_fp2slv(dx*real(cam.resx)*0.5-dx*0.5);
|
448 |
|
|
|
449 |
|
|
--! Eje Z: Tomando el dedo pulgar de la mano derecha, este eje queda apuntando hacia arriba del observador, desde el observador.
|
450 |
|
|
v(2):=ap_fp2slv(dy*real(cam.resy)*0.5-dy*0.5);
|
451 |
|
|
|
452 |
|
|
return v;
|
453 |
|
|
|
454 |
|
|
end function;
|
455 |
155 |
jguarin200 |
|
456 |
|
|
function ap_slvf2string(sl:std_logic_vector) return string is
|
457 |
|
|
alias f: std_logic_vector(31 downto 0) is sl;
|
458 |
|
|
variable r: real;
|
459 |
|
|
|
460 |
|
|
begin
|
461 |
|
|
|
462 |
|
|
r:=ap_slv2fp(f);
|
463 |
|
|
return real'image(r);
|
464 |
|
|
|
465 |
|
|
end function;
|
466 |
|
|
|
467 |
|
|
|
468 |
|
|
|
469 |
153 |
jguarin200 |
|
470 |
|
|
end package body;
|