Baixe o app para aproveitar ainda mais
Prévia do material em texto
Sistemas Digitais Prof. Dr. Dilmar Malheiros Meira Curso de Engenharia de Controle e Automação Descrição de Circuitos Seqüenciais com VHDL Sistemas Digitais Prof. Dilmar M. Meira 2 Linguagens de Descrição de Hardware (Hardware Description Languages – HDL) VHDL – VHSIC(*) HDL Verilog AHDL – Altera HDL (*) Very High Speed Integrated Circuit Sistemas Digitais Prof. Dilmar M. Meira 3 Estrutura de uma descrição (“código”) em VHDL LIBRARY – Lista de todas as bibliotecas a serem usadas em um projeto. Uma biblioteca é um conjunto de códigos VHDL comumente utilizados na descrição de circuitos. ENTITY – Especifica os pinos de entrada ou de saída do circuito. ARCHITECTURE – Descreve a estrutura e/ou o comportamento do circuito. Sistemas Digitais Prof. Dilmar M. Meira 4 LIBRARY nome_da_biblioteca; USE nome_da_biblioteca.nome_do_package.parte_do_package; Packages mais comuns ieee.std_logic_1164 (da biblioteca ieee) standard (da biblioteca std) Work (da biblioteca work). Sistemas Digitais Prof. Dilmar M. Meira 5 Exemplo de declaração de biblioteca LIBRARY ieee; -- Biblioteca ieee. USE ieee.std_logic_1164.all; -- Dois sinais de “menos “ em -- seqüência indicam um comentário. As bibliotecas std e work não precisam ser explicitamente declaradas. Sistemas Digitais Prof. Dilmar M. Meira 6 Sistemas Digitais Prof. Dilmar M. Meira 7 ARCHITECTURE exemplo OF nand_gate IS BEGIN x <= a NAND b; END exemplo; Sistemas Digitais I Prof. Dilmar M. Meira 8 -- Latch D (Mark Zwolinski -- Digital System Design With VHDL) library IEEE; use IEEE.std_logic_1164.all; entity D_latch is port (D, Enable : in std_logic; Q : out std_logic ); end entity D_latch; architecture behavioural of D_latch is begin p0: process (D, Enable) is begin if (Enable = '1') then Q <= D; end if; end process p0; end architecture behavioural; Sistemas Digitais I Prof. Dilmar M. Meira 9 -- Flip-flop D com reset assíncrono e -- habilitação de clock library IEEE; use IEEE.std_logic_1164.all; entity D_ff is port (D, CE, Resetn, Clock : in std_logic; Q : out std_logic ); end entity D_ff; architecture behavioural of D_ff is begin process (Clock, Resetn, CE) is begin if Resetn='0' then Q <= '0'; else if Clock'Event and Clock='1' then if CE = '1' then Q <= D; end if; end if; end if; end process; end architecture behavioural; Sistemas Digitais I Prof. Dilmar M. Meira 10 -- Registrador D de 4 bits library IEEE; use IEEE.std_logic_1164.all; entity D_ff is port (D : in std_logic_vector (3 downto 0); Clock : in std_logic; Q : out std_logic_vector (3 downto 0) ); end entity D_ff; architecture behavioural of D_ff is begin process (Clock) is begin if Clock'Event and Clock='1' then Q <= D; end if; end process; end architecture behavioural; Sistemas Digitais I Prof. Dilmar M. Meira 11 -- Contador decádico -- Peter J. Ashenden. Digital Design: -- An Embedded Systems Approach Using VHDL library ieee; use ieee.std_logic_1164.all, ieee.numeric_std.all; entity decade_counter is port (clk : in std_logic; q : out unsigned (3 downto 0) ); end entity decade_counter; architecture rtl of decade_counter is signal count_value : unsigned(3 downto 0); begin count : process (clk) is begin if rising_edge(clk) then if count_value = 9 then count_value <= "0000"; else count_value <= count_value + 1; end if; end if; end process count; q <= count_value; end architecture rtl; Sistemas Digitais I Prof. Dilmar M. Meira 12 library ieee; use ieee.std_logic_1164.all; ------------------------------------------------------------------------------------------------------------------- entity Reg_desloc is port (R: in std_logic_vector(7 downto 0); -- Entrada de dados paralela clock : in std_logic; L : in std_logic; -- Comando para entrada de dados paralela w : in std_logic; -- Entrada de dados serial Q : buffer std_logic_vector(7 downto 0)); end entity Reg_desloc; ------------------------------------------------------------------------------------------------------------------- architecture comportamento of Reg_desloc is begin process begin wait until clock'event and clock='1'; if L='0' then Q <= R; else Q(0) <= Q(1); Q(1) <= Q(2); Q(2) <= Q(3); Q(3) <= Q(4); Q(4) <= Q(5); Q(5) <= Q(6); Q(6) <= Q(7); Q(7) <= w; end if; end process; end comportamento; R[7..0] clock L w Q[7..0] Reg_desloc inst Sistemas Digitais I Prof. Dilmar M. Meira 13 Exemplo: Projete um contador síncrono que conte na seguinte seqüência: 001, 011, 101, 111, 010, 110, 001, … (1, 3, 5, 7, 2, 6, 1, … ) 010 011 101 110 001 111 000 100 Sistemas Digitais I Prof. Dilmar M. Meira 14 -- Contador síncrono que conta na sequência 1,3,5,7,2,6,1,... ENTITY cont_mod_6 IS PORT (Clock : IN BIT; Q : OUT INTEGER RANGE 0 TO 7); END cont_mod_6; ARCHITECTURE comportamento OF cont_mod_6 IS BEGIN conta: PROCESS (Clock) VARIABLE temp: INTEGER RANGE 0 TO 7; BEGIN IF (Clock'EVENT AND Clock = '1') THEN IF (temp=0) THEN temp := 1; ELSIF (temp=1) THEN temp := 3; ELSIF (temp=2) THEN temp := 6; ELSIF (temp=3) THEN temp := 5; ELSIF (temp=4) THEN temp := 5; ELSIF (temp=5) THEN temp := 7; ELSIF (temp=6) THEN temp := 1; ELSE temp := 2; END IF; END IF; Q <= temp; END PROCESS conta; END comportamento; Sistemas Digitais Prof. Dr. Dilmar M. Meira 15 Bibliografia Volnei A. Pedroni. Circuit Design with VHDL: MIT,2004. Roberto d’Amore. VHDL: Descrição e Síntese de Circuitos Digitais: LTC, 2005. Peter J. Ashenden. The designer’s guide to VHDL, second edition: Morgan Kaufman, 2002. James O. Hamblen et al. Rapid Prototyping of Digital Systems: Quartus II Edition: Springer, 2005 Stephen Brown & Zvonko Vranesic. Digital Logic Design with VHDL, second edition. McGraw-Hill, 2007.
Compartilhar