Professional Documents
Culture Documents
Introduccin.
Introduccin.
VHDL es un lenguaje creado para describir, analizar y evaluar circuitos digitales. (Es como un esquemtico, pero en texto)
Introduccin.
PROCESO DE DISEO CON PLDS Y VHDL
Introduccin.
Definir los requerimientos de Diseo. Describir el diseo en VHDL. Compilar el cdigo fuente. Simular el cdigo fuente (funcional) Sintetizar, optimizar, y generar el place and route or fit del diseo Simular el modelo del diseo post layout (temporal). Programar el dispositivo.
Mdulos en VHDL.
Encabezado
Entidad Arquitectura
Encabezado.
-
Entidades.
Entity: Representa el circuito digital como una caja negra, es decir describe sus entradas y salidas. Tiene un nombre y puertos. Un puerto es como una patita de un circuito integrado y tiene las siguientes partes: Nombre: Para identificar el pin. Modo: Direccin del puerto, in, out inout, buffer. Tipo de dato: std_logic, bit, boolean, integer
Entidades.
MODOS : Modo in : Se refiere a las seales de entrada a la entidad. Modo out : Indica las seales de salida de la entidad. Modo inout : Puerto en modo bidireccional, permite la lectura dentro y fuera de la entidad. Modo buffer : Permite lectura dentro de la entidad y se comporta como una salida.
BIT_VECTOR INTEGER
Entidades.
Ejemplo :
A
B
-- Ejemplo 1: Compuerta and de dos entradas. Entity And2 is port ( A,B : in std_logic; -- Entradas. C : out std_logic ); end And2;
Entidades.
Ejemplo :
4
Decodificador BCD S 7
-- Ejemplo 2: Decodificador de BCD a 7 segmentos. entity Decodificador is port ( BCD : in std_logic_vector(3 downto 0); -- Entrada. S : out std_logic_vector(6 downto 0) -- Salida. ); end Decodificador;
Introduccin. Sintaxis
VHDL no es sensible a minsculas y maysculas Ejemplo: RESET, reset, Reset, reseT es lo mismo. El primer carcter de un identificador debe ser una letra (No puede ser un nmero o guin bajo). _reloj 2_read seal_#2 clear__2 Dos guiones seguidos no son vlidos. No son validos los caracteres diferentes a las letras, nmeros y guin bajo.
Los comentarios Pueden ser colocados en cualquier lugar, se inician con doble guin (--) Ejemplo: -- Este es un comentario
Introduccin. Sintaxis
; , :
Se usa al final de una declaracin. Se usa para separar una lista de objetos. En la definicin de tipos.
Arquitectura.
Describe el contenido o funcionamiento de una entidad. La entity y la arquitectura siempre vienen por pares. La entity describe el circuito por fuera, la arquitectura describe el circuito por dentro. Hay 3 estilos de arquitectura: Funcional. Flujo de datos. Estructural.
Arquitectura. Funcional
En este tipo de descripcin se considera la relacin que existe entre las entradas y salidas del circuito sin importar como este organizado su interior.
ARCHITECTURE comportamental OF mux IS BEGIN PROCESS ( a, b, select ) IF ( select = 0 ) THEN salida <= a; ELSE salida <= b; END IF; END PROCESS; END comportamental;
-- Este proceso describe el comportamiento del decodificador. ElDecodificador : process(BCD) begin case BCD is when "0000" => S <= "0111111"; when "0001" => S <= "0000110"; when "0010" => S <= "1011011"; when "0011" => S <= "1100111"; when "0100" => S <= "1100110"; when "0101" => S <= "1101101"; when "0110" => S <= "1111101"; when "0111" => S <= "1000111"; when "1000" => S <= "1111111"; when "1001" => S <= "1101111"; when others => S <= "XXXXXXX"; end case; end process ElDecodificador; end Comportamiento;
-- Ejemplo , Arquitectura tipo flujo de datos A. architecture Flujo_A of Decodificador is begin S <= "0111111" when (BCD = "0000") else "0000110" when (BCD = "0001") else "1011011" when (BCD = "0010") else "1100111" when (BCD = "0011") else "1100110" when (BCD = "0100") else "1101101" when (BCD = "0101") else "1111101" when (BCD = "0110") else "1000111" when (BCD = "0111") else "1111111" when (BCD = "1000") else "1101111" when (BCD = "1001") else "XXXXXXX"; end Flujo_A;
-- Ejemplo -- Arquitectura tipo flujo de datos B architecture Flujo_B of Decodificador is Begin S(0) <= ( (not BCD(3)) and BCD(1) ( (not BCD(3)) and BCD(2) and BCD(0) ( (not BCD(2)) and (not BCD(1)) and (not BCD(0)) ( BCD(3) and (not BCD(2)) and (not BCD(1)) S(1) <= ( (not BCD(3)) and (not BCD(2)) ( (not BCD(3)) and (not BCD(1)) and (not BCD(0)) ( (not BCD(3)) and BCD(1) and BCD(0) ( BCD(3) and (not BCD(2)) and (not BCD(1)) ) or ) or ) or ); ) or ) or ) or );
S(2) <= ( (not BCD(3)) and BCD(2) ) or ( (not BCD(3)) and BCD(0) ) or ( (not BCD(2)) and (not BCD(1)) and (not BCD(0)) ) or ( BCD(3) and (not BCD(2)) and (not BCD(1)) ); S(3) <= ( (not BCD(3)) and BCD(1) and (not BCD(0)) ) or ( (not BCD(3)) and (not BCD(2)) and BCD(1) ) or ( (not BCD(2)) and (not BCD(1)) and (not BCD(0)) ) or ( BCD(3) and (not BCD(2)) and (not BCD(1)) ) or ( (not BCD(3)) and BCD(2) and (not BCD(1)) and BCD(0) );
S(4) <= ( (not BCD(3)) and BCD(1) and (not BCD(0)) ) or ( (not BCD(2)) and (not BCD(1)) and (not BCD(0)) );
S(5) <= ( (not BCD(3)) and BCD(2) and (not BCD(1)) ( (not BCD(3)) and (not BCD(1)) and (not BCD(0)) ( (not BCD(3)) and BCD(2) and (not BCD(0)) ( BCD(3) and (not BCD(2)) and (not BCD(1)) S(6) <= ( (not BCD(3)) and BCD(1) and (not BCD(0)) ( (not BCD(3)) and (not BCD(2)) and BCD(1) ( (not BCD(3)) and BCD(2) and (not BCD(1)) ( BCD(3) and (not BCD(2)) and (not BCD(1)) end Flujo_B;
) or ) or ) or ); ) or ) or ) or );
Arquitectura. Estructural
Basa su comportamiento en modelos lgicos establecidos (compuertas, Sumadores, contadores, etc. ). El usuario puede disear estas estructuras y guardarlas para su uso posterior.
library ieee ; use ieee.std_logic_1164.all; entity total is port ( clk: in std_logic; salida: inout std_logic_vector(3 downto 0) ); end total; architecture arq_total of total is component parte_1 Estructura total Port ( clk: in std_logic; salida: inout std_logic_vector(3 downto 0) ); end component;
begin
u1: parte_1 port map ( clk => clk , salida => salida ); -- asignacion de pines ( mapeo )
end arq_total;
AND2
INPUT VCC
OR2 OUTPUT
C1
C2
NOT
INPUT VCC
C3
AND2
INPUT VCC
C1
entity c1 is Port (
a_and, b_and: in std_logic ; s_and: out std_logic
Componente 1 ( C1 )
library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity c2 is Port ( a_or, b_or: in std_logic ; s_or: out std_logic
Componente 2 ( C2 )
);
end c2;
architecture arqc2 of c2 is begin s_or <= a_or or b_or; end arqc2;
Componente 2 ( C2 )
); end c3;
end arqc3;
end total;
architecture arqtotal of total is
Total
signal uno: std_logic; signal dos: std_logic; signal tres: std_logic; component c1 Port ( a_and,b_and: in std_logic; s_and: out std_logic ); end component;
component c2 Port ( a_or,b_or: in std_logic; s_or: out std_logic ); end component; component c3 Port (
Total ( continuacion)
end component;
begin --- Inicia Mapeo --- Etiqueta Componente PORT MAP ( PINCOMP => PINTOTAL); u1: c1 port map(a_and => a, b_and => dos , s_and => uno); u2: c3 port map(a_not => b, s_not => dos ); u3: c1 port map(a_and => b, b_and => c, s_and => tres); u4: c2 port map(a_or => uno, b_or => tres, s_or => s); end arqtotal;
Trabajo en clase. a) Disear un sumador de 4 bits + 4 bits utilizando descripcin estructural. ( las unidades del diseo sern sumador y sumador completo.
Lgica Secuencial
Se pueden describir circuitos secuenciales ( contadores, registros, etc) en VHDL, todos ellos controlados mediante una seal de reloj. Este tipo de comportamiento se modela en VHDL mediante un PROCESS
library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity FFTD is Port ( D: in std_logic; clk: in std_logic; Q: out std_logic );
end FFTD;
architecture arq of FFTD is begin process ( clk) begin if ( clk'event and clk='1') then Q<=D; end if; end process; end arq;
Lgica Secuencial
La expresin entre parntesis despus de la palabra PROCESS se denomina lista de sensibilidad y el proceso se ejecuta siempre que cualquiera de las seales incluidas en dicha lista cambie de valor. Si un FF tiene una entrada de borrado asincrona activa en nivel bajo, el codigo es el siguiente: library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity FFTDCLR is Port ( D: in std_logic; clk: in std_logic; clr: in std_logic; Q: out std_logic ); end FFTDCLR; architecture arq of FFTDCLR is begin process (clk,clr) begin if clr='0' then Q<='0'; elsif ( clk'event and clk='1') then Q<=D; end if; end process; end arq;
end cont_4;
architecture arq of cont_4 is begin process (clk) begin if ( clk'event and clk='1') then q<= q+1; end if; end process; end arq;
Maquinas de Estados.
Las mquinas de estado son circuitos secuenciales que se encuentran constituidos por una etapa combinacional y una etapa de memoria, relacionadas de tal forma que conforman un sistema secuencial para algn propsito especial.
Moore
Mealy
Maquinas de Estados.
Para modelar una maquina de estados es necesario separar la parte combinatoria de la secuencial.