A apresentação está carregando. Por favor, espere

A apresentação está carregando. Por favor, espere

Introdução ao VHDL João M. P. Cardoso.

Apresentações semelhantes


Apresentação em tema: "Introdução ao VHDL João M. P. Cardoso."— Transcrição da apresentação:

1 Introdução ao VHDL João M. P. Cardoso

2 Um Contador de 0 a 7 library IEEE; use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity count is Port ( clk : in std_logic; reset : in std_logic; cnt : out std_logic_vector(2 downto 0)); end count; architecture Behavioral of count is signal cnt1 : std_logic_vector(2 downto 0); begin process(clk, reset) if reset = '1' then cnt1 <= (others => '0'); elsif clk'event AND clk = '1' then cnt1 <= cnt1 + 1; end if; end process; cnt <= cnt1; end Behavioral;

3 Simulação Descrição em VHDL de uma bancada de teste
Instância o componente Define o valor dos sinais Só serve para simulação! Criação de um ficheiro do tipo Test Bench Waveform Permite a atribuição de valores aos sinais utilizando uma interface gráfica

4 Bancada de Teste BEGIN uut: count PORT MAP( clk => clk,
LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.numeric_std.ALL; ENTITY testbench IS END testbench; ARCHITECTURE behavior OF testbench IS COMPONENT count PORT( clk : IN std_logic; reset : IN std_logic; cnt : OUT std_logic_vector(2 downto 0) ); END COMPONENT; SIGNAL clk : std_logic; SIGNAL reset : std_logic; SIGNAL cnt : std_logic_vector(2 downto 0); SIGNAL clock : std_logic := '0'; -- for simulation BEGIN uut: count PORT MAP( clk => clk, reset => reset, cnt => cnt ); clock <= not clock after 10 ns; -- T = 20ns clk <= clock; -- *** Test Bench - User Defined Section *** tb : PROCESS reset <= '1'; wait for 20 ns; reset <= '0'; wait for 200 ns; --wait; -- will wait forever END PROCESS; -- *** End Test Bench - User Defined Section *** END;

5 ModelSim XE II/Starter 5.7c
Janela de ondas do simulador

6 Descodificador de Sete Segmentos
architecture Behavioral of seven_seg is begin process(inp_data) case inp_data is when "0000" => out_data <= " "; when "0001" => out_data <= " "; when "0010" => out_data <= " "; when "0011" => out_data <= " "; when "0100" => out_data <= " "; when "0101" => out_data <= " "; when "0110" => out_data <= " "; when "0111" => out_data <= " "; when "1000" => out_data <= " "; when "1001" => out_data <= " "; when others => out_data <= " "; end case; end process; end Behavioral; library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity seven_seg is Port ( inp_data : in std_logic_vector(3 downto 0); out_data : out std_logic_vector(7 downto 0)); end seven_seg;

7 Exemplo: Máquina de Bebidas
Disponibiliza a lata depois de 150 ou mais escudos terem sido depositados Uma única abertura para moedas (50$00 e 100$00) Não dá troco FSM da máquina de bebidas CEM CINQ Reset Clock Abre Sensor Moedas Mecanismo Libertar Lata

8 Exemplo: Máquina de Bebidas
Tabela e Diagrama de Estados Tabela de estados Simbólica Estado Entrada Próx. Saída Actual CEM CINQ Estado open 0$ $ $ $ – – 50$ $ $ $ – – 100$ $ $ $ – – 150$ – – 150$ 1 0$ Reset 50$ CINQ CEM + CINQ 100$ CEM 150$ [open]

9 Exemplo: Máquina de Bebidas
fsm1: process(current_state, CEM, CINQ) begin case current_state is when zero => s_open <= '0'; if CINQ = '1' then next_state <= cinquenta; else next_state <= zero; end if; when cinquenta => if CINQ = '1' then next_state <= st_cem; elsif CEM = '1' then next_state <= cent_cinq; else next_state <= cinquenta; end if; when st_cem => if CINQ = '1' OR CEM = '1' then next_state <= cent_cinq; else next_state <= st_cem; end if; when cent_cinq => s_open <= '1'; next_state <= zero; when others => end case; end process; end Behavioral; library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity fsm is Port ( clk : in std_logic; reset : in std_logic; CEM : in std_logic; CINQ : in std_logic; s_open : out std_logic); end fsm; architecture Behavioral of fsm is type state_type is (zero, cinquenta, st_cem, cent_cinq); signal current_state, next_state: state_type; begin fsm2: process(reset, clk) if reset = '1' then current_state <= zero; elsif clk'event AND clk='1' then current_state <= next_state; end if; end process;

10 Exemplo: Máquina de Bebidas
Quantos Flip-Flops existem no hardware sintetizado? Modificar as directivas de síntese para utilizar o menor número de FFs possível 4 estados => 2 FFs


Carregar ppt "Introdução ao VHDL João M. P. Cardoso."

Apresentações semelhantes


Anúncios Google