Top Banner
Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones VHDL VHDL – VHDL: VHSIC Hardware Description Language – VHSIC: Very High Speed Integrated Circuits VHDL es un lenguaje de descripción de hardware Es útil para la síntesis y verificación de circuitos digitales
32

Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Sep 26, 2018

Download

Documents

duongtruc
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

VHDL– VHDL: VHSIC Hardware Description

Language– VHSIC: Very High Speed Integrated Circuits

VHDL es un lenguaje de descripción dehardwareEs útil para la síntesis y verificación decircuitos digitales

Page 2: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Historia– El VHDL nace por iniciativa del Departamento

de Defensa de EE.UU. (comienzo de los 80)– En julio de 1983 tres compañías (Texas

Instruments, IBM e Internetics) reciben elencargo de desarrollarlo

– La primera versión se publica en agosto de1985

– En 1986 se convierte en un estándar del IEEE(IEEE 1076-1987)

Page 3: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Historia– Posteriormente, con el estándar IEEE 1164

se le añaden nuevas características– El estándar 1076 debe ser revisado cada

cinco años. Actualmente rige el 1076-1993

Page 4: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Principales ventajas– Estándar público– Independiente de la tecnología– Soporta diferentes metodologías de diseño– Independiente del sistema de diseño– Compatible

Page 5: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Estructura básica de un modelo VHDL– Entidad– Arquitectura– Configuraciones

Page 6: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Un diseño complejo se suele subdividiren bloquesLa declaración de entidad describe laforma de interconectar un bloque conlos demás (entradas, salidas)La declaración de arquitectura describeel comportamiento lógico del bloque

Page 7: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Declaración de entidad– Sentencia que define la especificación

externa de un circuito o subcircuito:• Nombre de la entidad• Puertos de entrada y salida• Modos de los puertos• Tipos de los puertos

– El funcionamiento del circuito no estáincluido en la declaración de entidad

Page 8: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Ejemplo de declaración de entidad

entity latch is port (s,r: in bit; q,nq: out bit);end latch;

Nombre de la entidad

Nombre delos puertos

Modos Tipos

Page 9: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Declaración de entidad– Modo de un puerto:

• In: entradas al sistema; sólo pueden ser leídos• Out: salidas del sistema; sólo se les puede

asignar valor• Inout: señales bidireccionales; se pueden leer y

se les puede asignar valor• Buffer: registro asociado a una salida

Page 10: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Declaración de entidad– El lenguaje predefine un conjunto de tipos

para las señales del sistema– Tipos predefinidos: boolean, bit, bit_vector,

character, string, integer, real, time,positive, natural

– Es ilegal conectar señales que no son delmismo tipo

Page 11: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Declaración de arquitectura– Cada declaración de entidad debe ir

acompañada de, al menos, una declaraciónde arquitectura

– Esta declaración indica el comportamiento ola estructura interna del sistema

– El estándar VHDL permite definir más deuna arquitectura para la misma entidad

Page 12: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

El lenguaje estándar define un conjuntode operadores sobre los tipos de datospredefinidos– Aritméticos (+, -, *, /, mod,...)– Lógicos (and, or, nand, nor, xor, not)– Desplazamiento– Relación (=, /=, <, >, <=, >=)– Signo– Concatenación

Page 13: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Declaración de arquitectura– A cada arquitectura se le asigna un nombre

arbitrario escogido por el usuario– Dentro de una declaración de arquitectura

todas las sentencias son concurrentes (elorden textual no importa ya que seejecutan en paralelo)

– Las dos formas más habituales de declararuna arquitectura son:• Descripción de la estructura• Descripción del comportamiento

Page 14: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Declaración de arquitectura– Ejemplo de descripción estructural

architecture structure of latch is component nor_gate port (a,b: in bit; c: out bit); end component;begin n1: nor_gate port map (r,nq,q); n2: nor_gate port map (s,q,nq);end structure;

S

RQ

Q

Page 15: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

– Asumimos que la puertanor está definida en otraporción de código

– Es necesario que lospuertos de la declaraciónde componente coincidancon los puertos de ladeclaración de entidad

– Un componente tiene queser declarado una sola vezen una arquitectura, ypuede ser empleado variasveces

architecture structure of latch is component nor_gate port (a,b: in bit; c: out bit); end component;begin n1: nor_gate port map (r,nq,q); n2: nor_gate port map (s,q,nq);end structure;

Page 16: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Declaración de arquitectura– Ejemplo de descripción del comportamiento

architecture dataflow of latch is signal qtemp, nqtemp: bit;begin--q y nq son de modo out, luego--no pueden ser leídos--definimos señales temporales q<=qtemp; nq<=nqtemp; qtemp<=r nor nqtemp; nqtemp<=s nor qtemp;end dataflow;

S

RQ

Q

Page 17: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Evaluación de una expresión

qtemp<=r nor nqtemp;

expresión señales operador

Evaluar una expresión consiste en sustituir losvalores de las señales en una expresión ycalcular el resultado al aplicar el operador

Page 18: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Modelo de retardo

qtemp<=r nor nqtemp after 1ns;

retardo

De esta manera se simulan los retardosde propagación de las puertas

Page 19: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Ejemplo: multiplexor 2 a 1entity mux is port (a,b,selec: in bit; salida: out bit);end mux;

architecture structure of mux is component and2 port (e1,e2: in bit; y: out bit); end component;

component or2 port (e1,e2: in bit; y: out bit); end component;

component inv port (e: in bit; y: out bit); end component;

signal ax,bx,nosel: bit;

begin u0: inv port map (e=>selec, y=>nosel); u1: and2 port map (e1=>a, e2=>nosel, y=>ax); u2: and2 port map (e1=>b, e2=>sel, y=>bx); u3: or2 port map (e1=>ax, e2=>bx, y=>salida);end structure;

Page 20: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

La manera más general de describir elcomportamiento de una arquitectura esmediante sentencias tipo procesoUn proceso puede contener órdenessecuenciales, pero todos los procesos seejecutan concurrentemente

Page 21: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Ejemplo de proceso– Nombre del proceso– Lista de sensibilidades– Declaración de variable– Inicialización de la variable– La variable cnt se incrementa

cada vez que se ejecuta elproceso

– Esto ocurre al comienzo de lasimulación y cada vez quecambia la señal x

count: process (x) variable cnt : integer := -1;begin cnt:=cnt+1;end process;

Page 22: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Las acciones descritas en el cuerpo delproceso se ejecutan en orden, de laprimera a la últimaCuando se ejecuta la última acción sedice que el proceso queda suspendidoCuando ocurre un cambio en una señalde la lista de sensibilidades el procesose inicia de nuevo, volviendo a ejecutarlas acciones de la primera a la última

Page 23: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Cada proceso se ejecuta una vez alcomienzo de la simulación paradeterminar el valor inicial de sus salidasAlgunas sentencias sólo puedenaparecer en un proceso porque implicanejecución secuencial: estructural deejecución secuencial

Page 24: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Otras estructuras de ejecución secuencial:– Sentencia de espera: wait– Sentencia condicional: if...then...else– Sentencia de selección: case– Sentencia de bucles: for y while

Page 25: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Ejemplo de sentencia con if:

count: process (x) variable cnt : integer := 0Begin if (x=‘1’ and x’last_value=‘0’) then cnt:=cnt+1; end if;end process;

El atributo ‘last_value de la variable xtoma valor ‘1’ ó ‘0’

Page 26: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Ejemplo de sentencia con for

signal x : bit_vector (7 downto 0);...process (x) variable p : bit;begin p:=‘0’ for i in 7 downto 0 loop p:=p xor x(i); end loop;end process;

Page 27: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Ejemplo: multiplexor 2 a 1entity mux is port (a,b,selec: in bit; salida: out bit);end mux;

architecture comportamental of mux isbegin process(a,b,selec) begin if (selec=‘0’) then salida<=a; else salida<=b; end process;end comportamental;

Page 28: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Declaración de configuración– La configuración es la construcción que

permite seleccionar la arquitectura que sequiere utilizar para una entidad concreta

– La declaración de configuración es opcional

Page 29: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Empaquetamientos y librerías– Los empaquetamientos contienen

declaraciones y definiciones de objetos ausar en diferentes diseños

– Los diseños, una vez compilados, sealmacenan en librerías

Page 30: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Empaquetamientos y librerías– Existen librerías predefinidas:

• STD: contiene los empaquetamientos standard ytextio

• WORK: librería de trabajo del usuario• IEEE: contiene los empaquetamientos

STD_LOGIC_1164 y STD_LOGIC_ARITH

– Estas declaraciones pueden ser importadasy utilizadas por otros diseños utilizando laclaúsula USE

Page 31: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Ejemplo

library IEEE;use IEEE.std_logic_1164.all;

El empaquetamiento std_logic_1164 define tipos de datospara las señales que no contempla el VHDL original: ‘Z’ (altaimpedancia) y ‘-’ (don’t care)

Page 32: Language – VHSIC: Very High Speed Integrated Circuitsfbeltran/vhdl.pdf · VHDL]Ejemplo: multiplexor 2 a 1 entity mux is port (a,b,selec: in bit; salida: out bit); end mux; architecture

Fernando Beltrán Dpto. Ingeniería Electrónica y Comunicaciones

VHDL

Tutoriales de VHDL en red:– http://www.gmvhdl.com/VHDL.html– http://www.vhdl-online.de/~vhdl/tutorial/