contador de flancos de subida en vhdl

Hola, tengo un proyecto que no he podido llevar a cabo, debo a el detector de flancos, agregarle un contador, que cuente solo 12 segundos, multiplique los flancos de subida por 5, y el resultado lo muestre en los displays 7 seg.

ya tengo el detector de flancos, tengo la visualizacion dinamica para los displays, lo que me ha costado trabajo es un contador de flancos q solo cuente durante 12 segundos.

Alguien sabe como lo puedo hacer??
 
Hola Oswaldo,
Dependerá de la frecuencia de tu reloj.
Por poner un ejemplo sencillo: si tu reloj tiene una frecuencia de 10 Hz, tendrás 10 flancos de subida cada segundo (esto es, un flanco de subida cada décima de segundo). Por lo tanto, habrán pasado 12 segundos cuando el contador valga 120 (10x12).
Espero que te ayude
Saludos
 
Hola compañero.
Lo que pasa es que tengo que hacer un contador con flancos, pero no sé como empezar, lo último que hicimos en clase fue un contador descendente, pero lo que no sé es si tengo que hacer un programa diferente o agregarle el contador de flancos a mi contador.

Adjunto mi programa.

Código:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;


entity Contador is
    port (
        CLK:         in std_logic;
        RESET:     in std_logic;
        PINICIO:     in std_logic;
        PARADA:     in std_logic;
        LED:         out std_logic_vector(7 downto 0);
        DISPLAY:    out std_logic_vector (7 downto 0);
        SEGMENTO: out std_logic_vector (7 downto 0)
        );    
end Contador;

architecture Behavioral of Contador is
    signal COUNTER:     std_logic_vector(7 downto 0); --CONTADOR LED
    signal COUNTER1:     std_logic_vector(7 downto 0); --CONTADOR UNIDAD
    signal COUNTER2:     std_logic_vector(7 downto 0);--CONTADOR DECENA
    signal COUNTER3:     std_logic_vector(7 downto 0);--CONTADOR CENTENA
    signal COUNTER4:     std_logic_vector(7 downto 0);--CONTADOR DISPLAY
    signal PRESCALER: std_logic_vector(26 downto 0);--original 25
    signal TIEMPOR: std_logic_vector(26 downto 0);--CONTADIR TIEMPO
    signal PNP:            std_logic_vector(7 downto 0);
    signal CLAVADO1:    std_logic_vector(1 downto 0);--PARA CLAVAR
    --signal DWCOUNTER: std_logic_vector(7 downto 0);
begin
    CounterProcess: process(RESET, CLK)
    begin
        if rising_edge (CLK) then
            if RESET = '1' then
                PRESCALER <= (others => '0');
                COUNTER <= (others => '0');
                COUNTER1 <= (others => '0');
                COUNTER2 <= (others => '0');
                COUNTER3 <= (others => '0');
                COUNTER4 <= (others => '0');
            else
                if PRESCALER < "10111110101111000010000000" then --50MHz
                    PRESCALER <= PRESCALER + 5;
                    TIEMPOR <= TIEMPOR + 1;
                    if TIEMPOR < "11000011010100000" then--CONTEO DE 0 A 100K
                        COUNTER4 <=COUNTER1;
                        PNP <= "00001110";
                        else
                        if TIEMPOR < "110000110101000000" then--CONTEO DE 100K A 200K
                        COUNTER4 <=COUNTER2;
                        PNP <= "00001101";
                        
                        else
                        if TIEMPOR < "1001001001111100000" then--CONTEO DE 200K A 300K
                        COUNTER4 <=COUNTER3;
                        PNP <= "00001011";
                        else
                        TIEMPOR <= "000000000000000000000000000";
                        end if;
                        end if;
                    end if; 
                    if PARADA ='1' then
                    CLAVADO1 <= "01";
                    end if;
                    if PINICIO ='1' then
                    CLAVADO1 <= "00";
                    end if;
                else
                    PRESCALER <= (others => '0');
                    if  CLAVADO1 = "00" then
                    COUNTER <= COUNTER - 1;
                    COUNTER1 <= COUNTER1 - 1;
                    if COUNTER1 = "00000000" then
                    COUNTER2<= COUNTER2 - 1;
                    COUNTER1 <= "00001001";
                    end if;
                    
                    if COUNTER2 = "00000000" AND COUNTER1 = "00000000" then
                        COUNTER3 <= COUNTER3 - 1;
                        COUNTER2 <= "00001001";
                    end if;    
                    if    COUNTER3 = "00000000" AND COUNTER1 = "00000000" AND COUNTER2 = "00000000" then
                            COUNTER3 <= "00000001";
                            COUNTER2 <= "00001001";
                            COUNTER1 <= "00000111";
                            COUNTER <= "11000101";
                    end if;    
                    end if;
                    --DWCOUNTER <= 255 - COUNTER;
                    
                end if;
            end if;
        end if;                

end process;
      
         
LED <= COUNTER;
DISPLAY <= PNP;
SEGMENTO <= "11000000" when COUNTER4 = "00000000" else -- 0
                    "11111001" when COUNTER4 = "00000001" else -- 1
                    "10100100" when COUNTER4 = "00000010" else -- 2
                    "10110000" when COUNTER4= "00000011" else -- 3
                    "10011001" when COUNTER4 = "00000100" else -- 4
                    "10010010" when COUNTER4 = "00000101" else -- 5
                    "10000010" when COUNTER4 = "00000110" else -- 6
                    "11111000" when COUNTER4 = "00000111" else -- 7
                    "10000000" when COUNTER4= "00001000" else -- 8
                    "10010000" when COUNTER4 = "00001001" else-- 9
                    "11000000" when COUNTER4 >= "00001010"; --apagado
                                    
end Behavioral;
 
Última edición por un moderador:
Atrás
Arriba