1 |
5 |
arroxo2 |
-------------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- Generated by ModelSim SE 6.2b
|
4 |
|
|
--
|
5 |
|
|
--
|
6 |
|
|
-------------------------------------------------------------------------------------
|
7 |
|
|
--
|
8 |
|
|
-- "gen_vectorial.vhd" design file
|
9 |
|
|
--
|
10 |
|
|
-------------------------------------------------------------------------------------
|
11 |
|
|
--
|
12 |
|
|
-- Environment Definition
|
13 |
|
|
--
|
14 |
|
|
-- "gen_vectorial.mpf"
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
-------------------------------------------------------------------------------------
|
18 |
|
|
|
19 |
|
|
-- CREATION DATE : 18-Jun-2007
|
20 |
|
|
-- AUTOR : DIEGO P
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
--------------------------------------------------------------------------------
|
24 |
|
|
-- GENERADOR VECTORIAL DE VECTORES DE TEST, EN FOMATO SERIE O BUS
|
25 |
|
|
--------------------------------------------------------------------------------
|
26 |
|
|
|
27 |
|
|
-- DEFINITION
|
28 |
|
|
--------------------------------------------------------------------------------
|
29 |
|
|
--
|
30 |
|
|
-- La eleccion del ancho de bus es configurable como parametro generico
|
31 |
|
|
-- WIDTH = 1 para formato serie
|
32 |
|
|
-- WIDTH max = 16 (formato bus)
|
33 |
|
|
--
|
34 |
|
|
-- Se considera valor por defecto el especificado como parametro generico
|
35 |
|
|
-- DEFAULT_VALUE : STD_LOGIC; (en formato bus se aplica a todos los bits)
|
36 |
|
|
--
|
37 |
|
|
--
|
38 |
|
|
-- DESCRIPTION
|
39 |
|
|
--------------------------------------------------------------------------------
|
40 |
|
|
|
41 |
|
|
-- VALOR A REPRESENTAR (INPUT):
|
42 |
|
|
--
|
43 |
|
|
-- en los indices impares tenemos el valor a generar (salida en "vector"), y en los pares el
|
44 |
|
|
-- numero de ciclos que ese valor debe permanecer activo:
|
45 |
|
|
--
|
46 |
|
|
-- 127 126 125 124 1 0
|
47 |
|
|
-- -----------------------------------------------------------------------
|
48 |
|
|
-- | value | cycles | value | cycles | ... | ... | ? | 0 |
|
49 |
|
|
-- -----------------------------------------------------------------------
|
50 |
|
|
--
|
51 |
|
|
-- p.e. valores : vector_integer := (-1,2,2,4, OTHERS=>0);
|
52 |
|
|
--
|
53 |
|
|
-- El final del vector se indica con un cero en el numero de ciclos.
|
54 |
|
|
-- Los valores de entrada =-1 son considerados alta impedancia en el vector de test generado
|
55 |
|
|
--
|
56 |
|
|
--
|
57 |
|
|
-- LIMITACIONES:
|
58 |
|
|
--
|
59 |
|
|
-- el numero maximo de valores a generar ('values') es 63 (= 128/2 -1)
|
60 |
|
|
-- el valor maximo a representar ('value') es d'65535 (formato serie o paralelo)
|
61 |
|
|
-- el numero maximo de ciclos de reloj ('cycles') por cada bit(serie) o valor(bus) es 65535 (2048us a 32Mhz)
|
62 |
|
|
--
|
63 |
|
|
-- En el formato serie el numero de ciclos indica el numero de ciclos por cada bit, por lo que todos los
|
64 |
|
|
-- bits tienen el mismo numero de ciclos
|
65 |
|
|
--
|
66 |
|
|
-- ERROR DE FORMATO:
|
67 |
|
|
--
|
68 |
|
|
-- No se debe especificar un valor menor a -1 para representar 'Z'.
|
69 |
|
|
-- No se debe especificar un numero de ciclos negativo (error).
|
70 |
|
|
-- El final del vector se indica con un cero en el numero de ciclos (el valor corrrespondiente es ignorado).
|
71 |
|
|
--
|
72 |
|
|
-- Si se produce un error de formato en los valores introducidos, se produce un error (salida "error"=1)
|
73 |
|
|
-- que deshabilita la generation del vector, y su salida será el valor por defecto especificado (DEFAULT_VALUE)
|
74 |
|
|
--
|
75 |
|
|
-- RETARDOS:
|
76 |
|
|
--
|
77 |
|
|
-- Desde que se aplica el trigger hasta que comienza la generacion del vector transcurre 1 ciclo (+ procesamiento)
|
78 |
|
|
--
|
79 |
|
|
-- ABORTADO:
|
80 |
|
|
--
|
81 |
|
|
-- Para abortar la generacion entre triggers aplicar un areset (la salida será el valor por defecto).
|
82 |
|
|
|
83 |
|
|
-- EJEMPLOS:
|
84 |
|
|
--
|
85 |
|
|
--(a) WIDTH = 1 (serial), DEFAULT_VALUE = 'Z':
|
86 |
|
|
--
|
87 |
|
|
-- (-1, 2, 9, 2, 0, 10, OTHERS => 0)
|
88 |
|
|
--
|
89 |
|
|
-- 1- 'Z' for 2*t_clk_period
|
90 |
|
|
-- 2- '1''0''0''1' for 4*(2 cycles/bit)
|
91 |
|
|
-- 3- '0' for 10*t_clk_period
|
92 |
|
|
-- 4- 'Z' (default_value) upto next trigger
|
93 |
|
|
--
|
94 |
|
|
-- _
|
95 |
|
|
-- trigg ______| |____________________________________________________________________________________________________
|
96 |
|
|
--
|
97 |
|
|
-- 1 2____ ____3 4
|
98 |
|
|
-- --------------| |____________| |______________________-------------------------------------------------
|
99 |
|
|
-- _
|
100 |
|
|
-- fin ____________________________________________________________| |______________________________________________
|
101 |
|
|
|
102 |
|
|
--
|
103 |
|
|
--(b) WIDTH > 1 (bus or parallel), DEFAULT_VALUE = '0':
|
104 |
|
|
--
|
105 |
|
|
--
|
106 |
|
|
-- (-1, 13, 9, 33, OTHERS => 0)
|
107 |
|
|
--
|
108 |
|
|
-- 1- "Z......Z" for 13*t_clk_period
|
109 |
|
|
-- 2- "0..01001" for 33*t_clk_period
|
110 |
|
|
-- 3- "0......0" (default_value) upto next trigger
|
111 |
|
|
--
|
112 |
|
|
-- >> min bus width = 4
|
113 |
|
|
--
|
114 |
|
|
-- _
|
115 |
|
|
-- trigg ______| |____________________________________________________________________________________________________
|
116 |
|
|
--
|
117 |
|
|
-- ________1______________________2____________________________________________________3________________________
|
118 |
|
|
-- __0000__X_________ZZZZ_________X________________________1001________________________X__________0000__________
|
119 |
|
|
--
|
120 |
|
|
-- _
|
121 |
|
|
-- fin ____________________________________________________________________________________| |______________________
|
122 |
|
|
--
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
LIBRARY ieee;
|
128 |
|
|
USE ieee.std_logic_1164.all;
|
129 |
|
|
USE ieee.std_logic_arith.all;
|
130 |
|
|
USE ieee.std_logic_signed.all;
|
131 |
|
|
|
132 |
|
|
LIBRARY ieee;
|
133 |
|
|
USE ieee.math_real.all;
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
--===================================================================================
|
137 |
|
|
PACKAGE gen_vectorial_pkg IS
|
138 |
|
|
--===================================================================================
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
-------------------------------------------------------------------------------------
|
142 |
|
|
-- CONSTANTS
|
143 |
|
|
-------------------------------------------------------------------------------------
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
-------------------------------------------------------------------------------------
|
147 |
|
|
-- TYPES
|
148 |
|
|
-------------------------------------------------------------------------------------
|
149 |
|
|
|
150 |
|
|
-- limit for synthesizable ranges
|
151 |
|
|
SUBTYPE nat_synth_65536 IS NATURAL RANGE 0 TO 65535;
|
152 |
|
|
SUBTYPE nat_synth_2048 IS NATURAL RANGE 0 TO 2047;
|
153 |
|
|
SUBTYPE nat_synth_1024 IS NATURAL RANGE 0 TO 1023;
|
154 |
|
|
SUBTYPE nat_synth_512 IS NATURAL RANGE 0 TO 511;
|
155 |
|
|
SUBTYPE nat_synth_256 IS NATURAL RANGE 0 TO 255;
|
156 |
|
|
SUBTYPE nat_synth_128 IS NATURAL RANGE 0 TO 127;
|
157 |
|
|
SUBTYPE nat_synth_64 IS NATURAL RANGE 0 TO 63;
|
158 |
|
|
SUBTYPE nat_synth_32 IS NATURAL RANGE 0 TO 31;
|
159 |
|
|
SUBTYPE nat_synth_16 IS NATURAL RANGE 0 TO 15;
|
160 |
|
|
|
161 |
|
|
SUBTYPE valores_vector IS INTEGER RANGE -1 TO nat_synth_65536'high;
|
162 |
|
|
TYPE vector_integer IS ARRAY (nat_synth_128'high DOWNTO 0) OF valores_vector;
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
-------------------------------------------------------------------------------------
|
166 |
|
|
-- COMPONENTS
|
167 |
|
|
-------------------------------------------------------------------------------------
|
168 |
|
|
|
169 |
|
|
COMPONENT gen_vectorial
|
170 |
|
|
GENERIC (
|
171 |
|
|
WIDTH : NATURAL; -- ancho de bus
|
172 |
|
|
DEFAULT_VALUE : STD_LOGIC -- e.g. '0', '1', 'Z', ...
|
173 |
|
|
);
|
174 |
|
|
PORT (
|
175 |
|
|
clock : IN STD_LOGIC;
|
176 |
|
|
enable : IN STD_LOGIC;
|
177 |
|
|
areset : IN STD_LOGIC;
|
178 |
|
|
trigger : IN STD_LOGIC; -- disparo de la generacion del vector
|
179 |
|
|
valores : IN vector_integer; -- entrada de valores para generar el vector
|
180 |
|
|
vector_out : OUT STD_LOGIC_VECTOR(WIDTH-1 DOWNTO 0); -- vector generado
|
181 |
|
|
fin : OUT STD_LOGIC; -- fin de la generacion
|
182 |
|
|
error : OUT STD_LOGIC -- error de configuracion o formato de valores incorrecto
|
183 |
|
|
);
|
184 |
|
|
END COMPONENT;
|
185 |
|
|
|
186 |
|
|
-------------------------------------------------------------------------------------
|
187 |
|
|
-- FUNCTIONS
|
188 |
|
|
-------------------------------------------------------------------------------------
|
189 |
|
|
|
190 |
|
|
-- devuelve el minimo numero de bits que necesita un entero en representacion binaria
|
191 |
|
|
-- Esta funcion es usada por la funcion "bus_width"
|
192 |
|
|
FUNCTION integer_bits (DATO_ENTRADA : IN valores_vector) RETURN NATURAL;
|
193 |
|
|
|
194 |
|
|
-- calcula el ancho de bus min necesario para la generacion del vector de test segun
|
195 |
|
|
-- el tamaño de los valores a generar
|
196 |
|
|
FUNCTION bus_width (valores: vector_integer) RETURN NATURAL;
|
197 |
|
|
|
198 |
|
|
-- comprueba si los datos para generar el vector de test tienen un formato logico
|
199 |
|
|
-- de acuerdo con lo descrito en la cabecera
|
200 |
|
|
FUNCTION check_format (valores: vector_integer; WIDTH: NATURAL) RETURN BOOLEAN;
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
END gen_vectorial_pkg;
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
--===================================================================================
|
208 |
|
|
PACKAGE BODY gen_vectorial_pkg IS
|
209 |
|
|
--===================================================================================
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
-------------------------------------------------------------------------------------
|
213 |
|
|
-- FUNCTIONS
|
214 |
|
|
-------------------------------------------------------------------------------------
|
215 |
|
|
|
216 |
|
|
FUNCTION integer_bits(DATO_ENTRADA : IN valores_vector) RETURN NATURAL IS
|
217 |
|
|
VARIABLE RESULTADO : nat_synth_16; -- (0..15)
|
218 |
|
|
BEGIN
|
219 |
|
|
|
220 |
|
|
RESULTADO := 0; -- default value
|
221 |
|
|
|
222 |
|
|
FOR I IN 1 TO 15 LOOP
|
223 |
|
|
IF DATO_ENTRADA >= 2**I THEN
|
224 |
|
|
RESULTADO := I;
|
225 |
|
|
END IF;
|
226 |
|
|
END LOOP;
|
227 |
|
|
|
228 |
|
|
RETURN RESULTADO+1; -- (max = 2**16 = 65536 <- T'valores_vector)
|
229 |
|
|
|
230 |
|
|
END integer_bits;
|
231 |
|
|
|
232 |
|
|
|
233 |
|
|
-------------------------------------------------------------------------------------
|
234 |
|
|
FUNCTION bus_width (valores: vector_integer) RETURN NATURAL IS
|
235 |
|
|
VARIABLE min_bits : nat_synth_16; -- (0..15)
|
236 |
|
|
BEGIN
|
237 |
|
|
min_bits:=0;
|
238 |
|
|
|
239 |
|
|
FOR i IN valores'length-1 DOWNTO 1 LOOP
|
240 |
|
|
IF ((i MOD 2) /= 0) THEN
|
241 |
|
|
IF (integer_bits(valores(i)) > min_bits+1) AND (valores(i) > 0) THEN
|
242 |
|
|
min_bits:= integer_bits(valores(i))-1; -- (restar 1 evita que desborde)
|
243 |
|
|
END IF;
|
244 |
|
|
END IF;
|
245 |
|
|
END LOOP;
|
246 |
|
|
|
247 |
|
|
RETURN min_bits+1;
|
248 |
|
|
END FUNCTION;
|
249 |
|
|
|
250 |
|
|
-------------------------------------------------------------------------------------
|
251 |
|
|
FUNCTION check_format (valores: vector_integer; WIDTH: NATURAL) RETURN BOOLEAN IS
|
252 |
|
|
|
253 |
|
|
BEGIN
|
254 |
|
|
-- bus width parameter (in bus format) is not enough or overflows
|
255 |
|
|
IF ((bus_width(valores) > WIDTH) AND (WIDTH > 1)) OR
|
256 |
|
|
(WIDTH > 16) OR
|
257 |
|
|
(WIDTH = 0) THEN
|
258 |
|
|
RETURN FALSE;
|
259 |
|
|
|
260 |
|
|
-- input vector without end value (null)
|
261 |
|
|
ELSIF (valores(valores'low) /= 0) THEN
|
262 |
|
|
RETURN FALSE;
|
263 |
|
|
|
264 |
|
|
-- negative number of cycles for any value
|
265 |
|
|
ELSE
|
266 |
|
|
FOR i IN valores'length-1 DOWNTO 1 LOOP
|
267 |
|
|
IF ((i MOD 2) /= 0) THEN
|
268 |
|
|
IF (valores(i-1) <0) THEN
|
269 |
|
|
RETURN FALSE;
|
270 |
|
|
END IF;
|
271 |
|
|
END IF;
|
272 |
|
|
END LOOP;
|
273 |
|
|
END IF;
|
274 |
|
|
|
275 |
|
|
-- no error by default
|
276 |
|
|
RETURN TRUE;
|
277 |
|
|
END FUNCTION;
|
278 |
|
|
|
279 |
|
|
|
280 |
|
|
END gen_vectorial_pkg;
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
LIBRARY ieee;
|
288 |
|
|
USE ieee.std_logic_1164.all;
|
289 |
|
|
USE ieee.std_logic_arith.all;
|
290 |
|
|
USE ieee.std_logic_signed.all;
|
291 |
|
|
|
292 |
|
|
LIBRARY work;
|
293 |
|
|
USE work.gen_vectorial_pkg.all;
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
--===================================================================================
|
297 |
|
|
ENTITY gen_vectorial IS
|
298 |
|
|
--===================================================================================
|
299 |
|
|
|
300 |
|
|
GENERIC (
|
301 |
|
|
WIDTH : NATURAL; -- ancho de bus
|
302 |
|
|
DEFAULT_VALUE : STD_LOGIC -- e.g. '0', '1', 'Z', ...
|
303 |
|
|
);
|
304 |
|
|
PORT (
|
305 |
|
|
clock : IN STD_LOGIC;
|
306 |
|
|
enable : IN STD_LOGIC;
|
307 |
|
|
areset : IN STD_LOGIC;
|
308 |
|
|
trigger : IN STD_LOGIC; -- disparo de la generacion del vector
|
309 |
|
|
valores : IN vector_integer; -- entrada de valores para generar el vector
|
310 |
|
|
vector_out : OUT STD_LOGIC_VECTOR(WIDTH-1 DOWNTO 0); -- vector de test generado
|
311 |
|
|
fin : OUT STD_LOGIC; -- fin de la generacion
|
312 |
|
|
error : OUT STD_LOGIC -- error de configuracion o formato de valores incorrecto
|
313 |
|
|
);
|
314 |
|
|
END gen_vectorial;
|
315 |
|
|
|
316 |
|
|
-------------------------------------------------------------------------------------
|
317 |
|
|
|
318 |
|
|
ARCHITECTURE gen_vectorial_arch OF gen_vectorial IS
|
319 |
|
|
|
320 |
|
|
SIGNAL valores_reg : vector_integer; -- entrada registrada entre triggers
|
321 |
|
|
|
322 |
|
|
SIGNAL num_cycles : nat_synth_65536; -- cuenta de ciclos de reloj del bit(serie)/valor(bus) actual
|
323 |
|
|
SIGNAL indice : nat_synth_128; -- indice del valor en curso
|
324 |
|
|
SIGNAL fin_cuenta : STD_LOGIC; -- para desabilitar proceso principal desde fin de cuenta hasta siguiente trigger
|
325 |
|
|
|
326 |
|
|
SIGNAL error_aux : STD_LOGIC; -- para permitir lecturas de output port ("error")
|
327 |
|
|
|
328 |
|
|
SIGNAL current_bit : nat_synth_16; -- bit en curso del valor actual
|
329 |
|
|
|
330 |
|
|
SIGNAL first_trigger: BOOLEAN; -- inhibe la generacion hasta que se produzca el primer trigger
|
331 |
|
|
-- (antes del primer trigger aun no esta el valor por defecto
|
332 |
|
|
-- a la salida por lo que es un caso especial)
|
333 |
|
|
|
334 |
|
|
BEGIN
|
335 |
|
|
|
336 |
|
|
-- Proceso de generacion del vector (se recorre el vector "valores" de BMS a LMS):
|
337 |
|
|
|
338 |
|
|
-- 127 126 125 124 1 0
|
339 |
|
|
-- -----------------------------------------------------------------------
|
340 |
|
|
-- | value | cycles | value | cycles | ... | ... | ? | 0 |
|
341 |
|
|
-- -----------------------------------------------------------------------
|
342 |
|
|
-- indice indice-1 indice' indice'-1
|
343 |
|
|
|
344 |
|
|
--==========================================================================
|
345 |
|
|
genera_vector:
|
346 |
|
|
--==========================================================================
|
347 |
|
|
PROCESS (clock, areset)
|
348 |
|
|
|
349 |
|
|
-- para en formato serie pasar de integer a std_logic_vector
|
350 |
|
|
VARIABLE auxiliar : STD_LOGIC_VECTOR(nat_synth_16'high DOWNTO 0);
|
351 |
|
|
|
352 |
|
|
BEGIN
|
353 |
|
|
|
354 |
|
|
IF (areset='1') THEN
|
355 |
|
|
fin <= '0';
|
356 |
|
|
fin_cuenta <= '0';
|
357 |
|
|
indice <= valores_reg'length-1;
|
358 |
|
|
num_cycles <= 0;
|
359 |
|
|
vector_out <= (OTHERS => DEFAULT_VALUE);
|
360 |
|
|
|
361 |
|
|
first_trigger <= FALSE;
|
362 |
|
|
|
363 |
|
|
ELSIF RISING_EDGE(clock) THEN
|
364 |
|
|
|
365 |
|
|
|
366 |
|
|
IF enable='1' THEN
|
367 |
|
|
|
368 |
|
|
----------------------------------------------------------------
|
369 |
|
|
-- valor de salida por defecto
|
370 |
|
|
----------------------------------------------------------------
|
371 |
|
|
vector_out <= (OTHERS => DEFAULT_VALUE);
|
372 |
|
|
|
373 |
|
|
|
374 |
|
|
IF error_aux='0' THEN -- (si no hay error en el formato del vector)
|
375 |
|
|
|
376 |
|
|
---------------------------------------------------------------
|
377 |
|
|
-- pulso de fin (por fin_cuenta)
|
378 |
|
|
---------------------------------------------------------------
|
379 |
|
|
|
380 |
|
|
-- Si el tiempo entre triggers es insuficiente para la generacion, se asigna al
|
381 |
|
|
-- vector su valor por defecto (no se asigna otro valor q no sea el de por defecto)
|
382 |
|
|
|
383 |
|
|
-- [No se usan los valores de entrada registrados con el trigger, porque
|
384 |
|
|
-- aun no se han registrado (hasta el prox ciclo). Asi se consigue evitar otro
|
385 |
|
|
-- ciclo de retraso de la salida desde el trigger]
|
386 |
|
|
|
387 |
|
|
IF (trigger='1') THEN
|
388 |
|
|
|
389 |
|
|
fin <= '0';
|
390 |
|
|
indice <= valores'length-1;
|
391 |
|
|
num_cycles <= 0;
|
392 |
|
|
fin_cuenta <= '0';
|
393 |
|
|
|
394 |
|
|
first_trigger <= TRUE;
|
395 |
|
|
|
396 |
|
|
-- para formato serie: asignacion del primer bit del primer valor
|
397 |
|
|
IF (WIDTH =1) THEN
|
398 |
|
|
IF (valores(valores'length-1) >=0) THEN
|
399 |
|
|
current_bit <= integer_bits(valores(valores'length-1)) -1;
|
400 |
|
|
ELSE
|
401 |
|
|
current_bit <= 0; -- ('Z')
|
402 |
|
|
END IF;
|
403 |
|
|
END IF;
|
404 |
|
|
|
405 |
|
|
-- Si se ha activado fin_cuenta, debe desactivarse "fin" para provocar un pulso de 1 ciclo,
|
406 |
|
|
-- y esperar a siguiente trigger ("fin_cuenta" permanece activo y entra siempre en este caso)
|
407 |
|
|
|
408 |
|
|
ELSIF (fin_cuenta='1') THEN -- fin de generacion de todos los valores
|
409 |
|
|
fin <= '0'; -- cierra pulso de fin
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
----------------------------------------------------------------
|
413 |
|
|
-- generacion del vector si estamos en tiempo entre triggers
|
414 |
|
|
----------------------------------------------------------------
|
415 |
|
|
ELSIF first_trigger = TRUE THEN
|
416 |
|
|
|
417 |
|
|
-- ULTIMO VALOR (nulo)
|
418 |
|
|
IF valores_reg(indice-1) = 0 THEN -- numero nulo de ciclos (fin de vector)
|
419 |
|
|
fin_cuenta <= '1'; -- desabilita el proceso hasta proximo trigger
|
420 |
|
|
fin <= '1'; -- abre el pulso de fin
|
421 |
|
|
|
422 |
|
|
-- SIGUIENTE VALOR, ciclos del valor actual:
|
423 |
|
|
ELSE
|
424 |
|
|
|
425 |
|
|
-- <><><><><><><><><> formato bus <><><><><><><><><>
|
426 |
|
|
-- <><><><><><><><><><><><><><><><><><><><><><><><><>
|
427 |
|
|
IF WIDTH > 1 THEN
|
428 |
|
|
|
429 |
|
|
-- output del valor actual
|
430 |
|
|
IF valores_reg(indice) < 0 THEN -- valor negativo ('Z')
|
431 |
|
|
vector_out <= (OTHERS=>'Z');
|
432 |
|
|
ELSE -- valor en curso
|
433 |
|
|
vector_out <= CONV_STD_LOGIC_VECTOR(valores_reg(indice),WIDTH);
|
434 |
|
|
END IF;
|
435 |
|
|
|
436 |
|
|
-- ¿paso a siguiente valor?
|
437 |
|
|
IF (num_cycles+1 >= valores_reg(indice-1)) THEN -- siguiente valor
|
438 |
|
|
indice <= indice -2;
|
439 |
|
|
num_cycles <= 0;
|
440 |
|
|
ELSE -- continua con el valor en curso
|
441 |
|
|
num_cycles <= num_cycles +1;
|
442 |
|
|
END IF;
|
443 |
|
|
|
444 |
|
|
-- <><><><><><><><><> formato serie <><><><><><><><>
|
445 |
|
|
-- <><><><><><><><><><><><><><><><><><><><><><><><><>
|
446 |
|
|
ELSE
|
447 |
|
|
|
448 |
|
|
-- output del valor actual
|
449 |
|
|
IF valores_reg(indice) < 0 THEN -- valor negativo ('Z')
|
450 |
|
|
vector_out <= (OTHERS=>'Z');
|
451 |
|
|
ELSE -- bit correspondiente del valor en curso
|
452 |
|
|
auxiliar := CONV_STD_LOGIC_VECTOR(valores_reg(indice), auxiliar'length);
|
453 |
|
|
vector_out <= (OTHERS => auxiliar(current_bit));
|
454 |
|
|
END IF;
|
455 |
|
|
|
456 |
|
|
-- ¿paso a siguiente bit/valor?
|
457 |
|
|
IF (num_cycles+1 >= valores_reg(indice-1)) THEN
|
458 |
|
|
|
459 |
|
|
IF (current_bit = 0) THEN -- siguiente valor
|
460 |
|
|
indice <= indice -2;
|
461 |
|
|
num_cycles <= 0;
|
462 |
|
|
|
463 |
|
|
IF (valores_reg(indice-2) >=0) THEN -- primer bit del siguiente valor
|
464 |
|
|
current_bit <= integer_bits(valores_reg(indice-2)) -1;
|
465 |
|
|
END IF;
|
466 |
|
|
-- (con valores negativos permanece "current_bit" =0)
|
467 |
|
|
|
468 |
|
|
ELSE -- siguiente bit del valor en curso
|
469 |
|
|
current_bit <= current_bit -1;
|
470 |
|
|
num_cycles <= 0;
|
471 |
|
|
END IF;
|
472 |
|
|
ELSE -- continua con el bit actual del valor en curso
|
473 |
|
|
num_cycles <= num_cycles +1;
|
474 |
|
|
END IF;
|
475 |
|
|
|
476 |
|
|
END IF; -- formato bus/serie
|
477 |
|
|
|
478 |
|
|
END IF; -- ultimo/siguiente valor
|
479 |
|
|
|
480 |
|
|
END IF; -- fin_cuenta
|
481 |
|
|
END IF; -- error_aux
|
482 |
|
|
END IF; -- enable
|
483 |
|
|
END IF; -- areset/rising_edge
|
484 |
|
|
END PROCESS;
|
485 |
|
|
|
486 |
|
|
|
487 |
|
|
|
488 |
|
|
-- Proceso de chequeo de formato del vector de entrada.
|
489 |
|
|
-- "error"='1' si el formato es erroneo => desabilita el proceso de
|
490 |
|
|
-- generacion del vector (process "genera_vector")
|
491 |
|
|
--==========================================================================
|
492 |
|
|
chequea_formato:
|
493 |
|
|
--==========================================================================
|
494 |
|
|
PROCESS (clock, areset)
|
495 |
|
|
|
496 |
|
|
BEGIN
|
497 |
|
|
IF (areset='1') THEN
|
498 |
|
|
error_aux <= '0';
|
499 |
|
|
|
500 |
|
|
ELSIF RISING_EDGE(clock) THEN
|
501 |
|
|
IF enable='1' THEN
|
502 |
|
|
IF trigger='1' THEN
|
503 |
|
|
IF check_format(valores, WIDTH) = FALSE THEN
|
504 |
|
|
error_aux <='1';
|
505 |
|
|
ELSE
|
506 |
|
|
error_aux <='0';
|
507 |
|
|
valores_reg <= valores;
|
508 |
|
|
END IF;
|
509 |
|
|
END IF;
|
510 |
|
|
END IF;
|
511 |
|
|
END IF;
|
512 |
|
|
|
513 |
|
|
END PROCESS;
|
514 |
|
|
|
515 |
|
|
error <= error_aux;
|
516 |
|
|
|
517 |
|
|
|
518 |
|
|
|
519 |
|
|
END gen_vectorial_arch;
|