elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


  Mostrar Temas
Páginas: [1]
1  Programación / Programación General / acumulador vhdl en: 24 Noviembre 2016, 20:20 pm
Hola,
Necesito ayuda para un trabajo de la universidad. Lo agradecería mucho puesto que estoy muy pez en el tema.

Necesito implementar un temporizador de 16 bits que se tiene que poder inicializar a un valor cualquiera y después tiene que ir haciendo una cuenta atrás, indicando con una señal el momento en que acaba.  
                    
Concretamente, el temporizador tiene que permitir:

• La carga paralela de un valor num arbitrario (con load a 1).
• Mientras la señal start se mantiene a 1, el temporizador tiene que ir decrementando
su valor (salida timer). La cuenta atrás se para (mantiene el valor de timer)
si la señal start pasa a 0, y continúa al volver a 1.
• Una señal de salida, end_time, que se pondrá a 1 cuando la cuenta del temporizador
llegue al final (a cero).


Lo que he realizado yo es:

library ieee;
   use ieee.std_logic_1164.all;
   use ieee.std_logic_unsigned.all;
ENTITY Timer IS
   PORT(
      clock      : in std_logic;
      load      : in std_logic;
      stard      : in std_logic;
      num      : in std_logic_vector(15 DOWNTO 0);
      timer      : out std_logic_vector(15 DOWNTO 0);
      end_time   : out std_logic);
END Timer;
ARCHITECTURE bhv of Timer is
   signal carga :std_logic_vector (15 DOWNTO 0);
   signal timer_p :std_logic_vector (15 DOWNTO 0);
   signal timer_0 :std_logic_vector (15 DOWNTO 0);
begin
process (clock,load)
begin
   if clock'event and clock='1' then
      if (stard = '1') then
      timer_p <=timer_p-1;
      else
      timer_p<=timer_p;
      timer<=timer_p;
         if (timer_0= "0000000000000000") then
         end_time<='1';
         timer_p <= timer_0;
            if (load='1') then
            timer <= carga;
            end if;
         end if;
      end if;
   end if;
end process;
end bhv;

y ahora estoy con el banco de pruebas para modelsim altera, pero no me aclaro para definir los estímulos.
El banco creado por el test bench es:

LIBRARY ieee;                                              
USE ieee.std_logic_1164.all;                                

ENTITY Timer_vhd_tst IS
END Timer_vhd_tst;
ARCHITECTURE Timer_arch OF Timer_vhd_tst IS
-- constants
constant PERIOD   : time := 20 ns;                                                
-- signals                                                  
SIGNAL clock : STD_LOGIC   := '0';
SIGNAL end_time : STD_LOGIC;
SIGNAL load : STD_LOGIC;
SIGNAL num : STD_LOGIC_VECTOR(15 DOWNTO 0);
SIGNAL stard : STD_LOGIC;
SIGNAL timer : STD_LOGIC_VECTOR(15 DOWNTO 0);
COMPONENT Timer
   PORT (
   clock : IN STD_LOGIC;
   end_time : OUT STD_LOGIC;
   load : IN STD_LOGIC;
   num : IN STD_LOGIC_VECTOR(15 DOWNTO 0);
   stard : IN STD_LOGIC;
   timer : OUT STD_LOGIC_VECTOR(15 DOWNTO 0)
   );
END COMPONENT;
BEGIN
   i1 : Timer
   PORT MAP (
-- list connections between master ports and signals
   clock => clock,
   end_time => end_time,
   load => load,
   num => num,
   stard => stard,
   timer => timer
   );
init : PROCESS                                              
-- variable declarations                                    
BEGIN
                                         
        -- code that executes only once                      
WAIT;                                                      
END PROCESS init;                                          
always : PROCESS                                              
-- optional sensitivity list                                  
-- (        )                                                
-- variable declarations                                      
BEGIN                                                        
        -- code executes for every event on sensitivity list  
WAIT;                                                        
END PROCESS always;                                          
END Timer_arch;

Gracias de antemano.
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines