Está en la página 1de 113

Instituto Tecnológico de Celaya

Maestría en Ciencias en Ing. Electrónica

Electrónica Digital Avanzada

Celaya Gto. Agosto 2016


Objetivo General:

Utilizar la metodología de diseño de sistemas


digitales mediante lógica programable para
desarrollar aplicaciones de mediana complejidad
Programa:

I Fundamentos de VHDL

Introducción
Objetos en VHDL
Estructura de un diseño en VHDL
Descripción comportamental
Descripción estructural
Diseños genéricos
Diseños de prueba
Programa:

II Diseño Digital con VHDL

Bloques combinacionales
Bloques secuenciales
Máquinas de estados
Memorias ROM y RAM
Sistema digital
● Evaluación:

○ Dos exámenes (40%)


○ Doce prácticas (30%)
○ Un proyecto (30%)
I Fundamentos de VHDL:
Diseño de circuitos integrados digitales (1960’s), ejemplo:
Diagrama esquemático
I Fundamentos de VHDL:
Surgimiento de Automatización en el Diseño Electrónico (EDA)
Inicios de los 70’s
Representación textual
I Fundamentos de VHDL:
Ejemplo:
Vector de prueba
Surgimiento de Automatización en el Diseño Electrónico (EDA) ,
simulación:
I Fundamentos de VHDL:
Surgimiento de Automatización en el Diseño Electrónico (EDA) :

• Surgen Herramientas de implementación (Layout) (inicios 1970s).

• Lugar de colocación de compuertas lógicas y rutas de conexión a


nivel silicio.

• Compañías como Calma, Computer Vision y Applicon adquisión de


esquemático via escaneo de diagramas esquemáticos a mano.

• EDA = CAD+CAE

• CAD=Computer-Aided Design, (Layout tools).

• CAE= Computer-Aided Engineering, (Simulation tools).


Surgimiento de Automatización en el Diseño Electrónico (EDA) ,
I Fundamentos de VHDL:
implementación:
I Fundamentos de VHDL:
Aparición de Circuitos integrados programables:

• Circuitos Integrados con arreglos de compuertas programables en


campo (FPGA=Field Programmable Gate Array) en 1984.

• Utilización de herramientas existentes para ASICs.

• Diferencia en la fase de implementación.

• Un FPGA contiene ya una estructura implementada de fábrica


(bloques lógicos programables CLBs).

• Un CLB formado por cierto número de LUTs y registros.


I Fundamentos de VHDL:
Aparición de Circuitos integrados programables:

• Necesarios pasos adicionales: de mapeo (mapping),


empaquetamiento (packing) y emplazamiento/ruteo
(Place-and-Route).

• Proceso de Mapping: Asociación de funciones a nivel compuerta con


funciones a nivel LUT en el FPGA.

• Proceso de packing: Los LUT y registros se empacan en los CLBs.

• Proceso place-and-route: Se determina el emplazamiento óptimo de


CLBs en el FPGA.
I Fundamentos de VHDL:
Estructura básica de los FPGAs
I Fundamentos de VHDL:
Estructura básica FPGAs
I Fundamentos de VHDL:
Estructura básica de los FPGAs
I Fundamentos de VHDL:
I Fundamentos de VHDL:
I Fundamentos de VHDL:
Diagrama de flujo diseño en un FPGA
I Fundamentos de VHDL:
Al Incrementar número de compuertas:

• Esquemáticos con 50 o más páginas.

• Dificultad de visualizar a un nivel mayor de abstracción.

• Dificultad en almacenar y reutilizar partes del diseño.

• Muy susceptible a aparición de errores cuando un bloque se utiliza


como copia y pega repetidamente.

Solución: Diseño Jerárquico (Hierarchy)


I Fundamentos de VHDL:
Ejemplo de diagrama Jerárquico
I Fundamentos de VHDL:
Dos bloques básicos
I Fundamentos de VHDL:
Nivel jerárquico superior
I Fundamentos de VHDL:
Desventajas del diseño basado en diagramas esquemático:

1. Tiempo excesivo de terminación de circuito Integrado.

2. Muy susceptible a errores.

3. Muy costoso.

4. Casi imposible representación y diseño de esquemáticos complejos


(actualmente millones de compuertas).

Solución:
Al final de los 1980s los diseñadores de herramientas EDA proponen
herramientas de diseño y flujo basadas en Lenguajes de descripción de
Hardware (HDL).
I Fundamentos de VHDL:
HDL: introduce niveles jerárquicos para permitir abstracción

• Diseño comportamental (Behavioral)

– Los componentes se describen al definir la relación funcional entre sus


entradas y sus salidas.

• Diseño estructural

– Los componentes se describen en términos de la interconexión de


componentes más primitivos.
I Fundamentos de VHDL:

HDL Jerarquía

• Ejemplo:

• Descripción behavioral:

“Circuito que detecta dos o más 1’s consecutivos o dos o más 0’s
consecutivos en su entrada serie”
I Fundamentos de VHDL:
Diseño behavioral
Entity consecutivos is
Port (clk, x: in std_logic; z: out std_logic);
End consecutivos;

Architecture beh of consecutivos is


Begin
process(clk)
variable previo: std_logic;
begin
if clk’event and clk=‘1’
then if previo = x
then z<=‘1’;
else z<=‘0’;
end if;
previo := x;
end if;
end process;
End beh;
I Fundamentos de VHDL:

Diseño estructural
I Fundamentos de VHDL:
Niveles de abstracción:
Los HDLs son capaces de representar diferentes niveles de abtracción:

Algorítmico: Comportamiento mediante Loops and Process.


Ejemplo: Y = (DATA-A + DATA-B)* DATA - C
Behavioral:
Flujo de datos: varios subniveles:
Nivel Booleano.- Ejemplo MUX 2:1:
Y = (SELECT & DATA) | (!SELECT & DATAB)

Register Transfer Level (RTL).- Conjunto de registros con lógica


combinacional
Ejemplo:
when CLOCK rises
if CONTROL == “1”
then REGA = REGB & REBC;
else REGA = REGB | REGD;
end if;
end when;
I Fundamentos de VHDL:
Niveles de abstracción:
• Estructural: Menor nivel, más usado en HDLs iniciales, comprende los subniveles:
Nivel Interruptores.- Descripción mediante listados de transistores interruptores.
Nivel compuertas.- Uso de compuertas lógicas primitivas.
I Fundamentos de VHDL:
Diagrama de flujo inicial basado en HDL (para FPGAs):
I Fundamentos de VHDL:
Ambiente de captura actual:
I Fundamentos de VHDL:

Problema con surgimiento de HDLs:

• Cada fabricante de herramientas EDA proponía su propio lenguaje HDL.

• Surgen problemas de no compatibilidad en diseños.

• Necesidad de contar con un HDL estándar en la industria.


I Fundamentos de VHDL:
Lenguajes de Descripción de Hardware:

• Verilog HDL.

• VHDL

• Diseño multi HDL.

• UDL/I (Japan)

• Superlog/System Verilog

• SystemC

• Handle C
I Fundamentos de VHDL:
I Fundamentos de VHDL:
Lenguaje VHDL
Evolución de VHDL

• Surge programa Very High Speed Integrated Circuit (VHSIC) en U.S. DoD (1980).

• Proyecto VHSIC HDL propuesto para estandarizar la representación de IC (1981).

• Contrato de desarrollo VHDL asignado a: Intermetrics, IBM y Texas Instruments


(1983).

• Primera versión de VHDL lanzada en 1985.

• El DoD dona todos los derechos de VHDL a IEEE (1986).

• Después de algunas modificaciones se lanza estándar oficial IEEE 1076 (1987).

• En el periodo 1988-1992 usuarios proponen cambios menores y en 1993


incorporados al estándar VHDL.
I Fundamentos de VHDL:
Lenguaje VHDL
• Delimitadores simples: &‘()*+,-./:;<=>|

Elementos Léxicos: • Delimitadores compuestos: => ** := /= >= <= <>

• Comentarios por línea: --

• Inicio con una letra y seguido por un número de digitos o


letras.
Identificadores:
• Se permite el carácter _ (no más de uno seguidos y
no como último carácter).

• No hay distinción entre mayúsculas y minúsculas.

• El carácter espacio no se permite (es un separador).


I Fundamentos de VHDL:
Lenguaje VHDL
• Carry_OUT
Identificadores
válidos: • Dim_Sum

• Count7SUB_2_goX

• 7AB
Identificadores
no válidos: • A@B

• SUM_

• PI__A
I Fundamentos de VHDL:
Lenguaje VHDL
Palabras reservadas

abs disconnect is out sli


access downto label package sra
after else library port srl
alias elsif linkage postponed subtype
all end literal procedure then
and entity loop process to
architecture exit map pure transport
array file mod range type
assert for nand record unaffected
attribute function new register units
begin generate next reject until
block generic nor return use
body group not rol variable
buffer guarded null ror wait
bus if of select when
case impure on severity while
component in open signal with
configuration inertial or shared xnor
constant inout others sla xor
I Fundamentos de VHDL:
Lenguaje VHDL
• Abstract
Integer: 21, 0, 1E2, 3e4, 123_000

Real: 11.0, 0.0, 0.468, 3.141_592_6

Real with exponent: 1.23E-11, 1.0E+4, 3.024E+23

Based: 2#1111_1100#, 16#fc#, 016#0FC#, 7#510#


Literales 16#F.E#E+1=2#1.1111_110#E7=254.0
• Character
‘A’ ‘a’ ‘%’ ‘’’ ‘ ’

• String
“Setup time violation” “” “ ” “A”

• Bit string
X”F_FF” (Hex), O”7777” (Octal), b”1111_1111_1111” (Bin)
Longitud = 12 bits.
I Fundamentos de VHDL:
Lenguaje VHDL
Tipos de Datos:
Scalar :

Bit : valores posibles ( 1 , 0 )


TYPE bit IS (‘0’ , ‘1’);

Boolean : valores posibles ( false, true)


TYPE boolean IS ( false, true);

Severity_level : valores posibles (note, warning, error, failure)


TYPE severity_level IS (note, warning, error, failure);
I Fundamentos de VHDL:
Lenguaje VHDL
Tipos de Datos:
Scalar :

Character : valores posibles caracteres definidos.


TYPE character IS (
nul, soh, stx, etx, eot, enq, ack, bel, bs, ht, lf, vt, ff, cr, so, si, dle,
dc1, dc2,dc3, dc4, nak, syn, etb, can, em, sub, esc, fsp, gsp, rsp, usp,

' ', '!', '"', '#', '$', '%', '&', ''', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', ':',';', '<', '=', '>', '?',

'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O','P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e','f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
del, ………………);
I Fundamentos de VHDL:
Lenguaje VHDL
Tipos de Datos:
Scalar :

Std_logic : valores posibles ( 1, 0, Z, X, ….).

TYPE std_logic IS ( 'U', -- Uninitialized


'X', -- Forcing unknown
'0', -- Forcing 0
'1', -- Forsing 1
'Z', -- High impedance
'W', -- Weak unknown
'L', -- Weak 0
'H', -- Weak 1
'-'); -- Don't care
Tabla de resolución

U X 0 1 Z W L H -
U U U U U U U U U U
X U X X X X X X X X
0 U X 0 X 0 0 0 0 X
1 U X X 1 1 1 1 1 X
Z U X 0 1 Z W L H X
W U X 0 1 W W W W X
L U X 0 1 L W L W X
H U X 0 1 H W W H X
- U X X X X X X X X
I Fundamentos de VHDL:
Lenguaje VHDL
Tipos de Datos:
Array types :

Bit : Componentes de tipo Bit


TYPE bit_vector IS ARRAY (NATURAL RANGE <>) OF bit;

Std_logic : Componentes tipo std_logic


TYPE std_logic_vector IS ARRAY ( NATURAL RANGE <>) OF std_logic;

String : Componentes tipo character


TYPE string IS ARRAY (POSITIVE RANGE <>) OF character;
I Fundamentos de VHDL:
Lenguaje VHDL
Tipos de Datos:
Physical types :
Time : Unidades de tiempo.
TYPE time IS RANGE -9223372036854775807 to +9223372036854775807
units
fs; -- femtosecond
ps = 1000 fs; -- picosecond
ns = 1000 ps; -- nanosecond
us = 1000 ns; -- microsecond
ms = 1000 us; -- millisecond
sec = 1000 ms; -- second
min = 60 sec; -- minute
hr = 60 min; -- hour;
end units;
I Fundamentos de VHDL:
Lenguaje VHDL
Tipos de Datos:
Numeric types :
Integer : Valores posibles de enteros.
TYPE integer IS RANGE -2_147_483_647 TO 2_147_483_647;

Real : Valores posibles de reales


TYPE real IS RANGE -0.1797693134862e309 TO +0.1797693134862e309;

Numeric subtypes :
Natural : Valores enteros 0 hasta integer’High.
SUBTYPE natural IS INTEGER RANGE 0 TO integer’HIGH;

Positive : Valores enteros 1 hasta integer’High.


SUBTYPE positive IS INTEGER RANGE 1 TO integer’HIGH;
I Fundamentos de VHDL:
Lenguaje VHDL
Tipos de Datos:
Record types :
Varios tipos : Valores posibles de cada tipo.
TYPE nombre IS
RECORD
identificador : indicación tipo;
:
identificador : indicación tipo;
END RECORD;
EJEMPLO:
type Mi_Modulo is
record
RISE_TIME : time;
FALL_TIME: time;
SIZE : integer range 0 to 200;
DATA : bit_vector (15 downto 0);
end record;
I Fundamentos de VHDL:
Lenguaje VHDL
Tipos Datos de usuario:
type MY_WORD is array (15 downto 0) of std_logic;
type YOUR_WORD is array (0 to 15) of std_logic;

type MY_MATRIX3X2 is array (1 to 3, 1 to 2) of natural;


type YOUR_MATRIX4X2 is array (1 to 4, 1 to 2) of integer;
type STD_LOGIC_2D is array (std_ulogic, std_ulogic) of std_logic;

type MATRIX is array (integer range <>) of integer;


type VECTOR_INT is array (natural range <>) of integer;
type VECTOR2 is array (natural range <>, natural range <>) of std_logic;
I Fundamentos de VHDL:
Lenguaje VHDL
Conversiones Tipos Datos
Conversiones disponibles en std_logic_1164 package

Conversion Function
std_ulogic to bit to_bit(expression)
std_logic_vector to bit_vector to_bitvector(expression)

std_ulogic_vector to bit_vector to_bitvector(expression)

bit to std_ulogic To_StdULogic(expression)


bit_vector to std_logic_vector To_StdLogicVector(expression)

bit_vector to std_ulogic_vector To_StdUlogicVector(expression)

std_ulogic to std_logic_vector To_StdLogicVector(expression)

std_logic to std_ulogic_vector To_StdUlogicVector(expression)


I Fundamentos de VHDL:
Lenguaje VHDL
Packages:
package STANDARD is

type BOOLEAN is (FALSE, TRUE);


type BIT is ('0', '1');
type CHARACTER is
( NUL, SOH, STX, ETX, EOT, ENQ, ACK, BEL, BS, HT, LF, VT, FF, CR, SO, SI, DLE,
DC1, DC2, DC3, DC4, NAK, SYN, ETB, CAN, EM, SUB, ESC, FSP, GSP, RSP, USP, ' ',
'!', '"', '#', '$', '%', '&', ''', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
'<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', ….
:
);
type SEVERITY_LEVEL is (NOTE, WARNING, ERROR, FAILURE);
type INTEGER is range -2147483647 to 2147483647;
type REAL is range $-. to $+.;
type TIME: type TIME is range $- to $+ units
fs; ps = 1000 fs; ns = 1000 ps; us = 1000 ns; ms = 1000 us;sec = 1000 ms;
min = 60 sec;hr = 60 min; end units; …etc…..;
:
:
end STANDARD;
I Fundamentos de VHDL:
Lenguaje VHDL
IEEE Packages:
std_logic_1164: standard datatypes
std_logic_arith: funciones arithmeticas de conversion y comparación
para datos tipo signed, unsigned, integer,std_ulogic,
std_logic y std_logic_vector.
std_logic_unsigned: unsigned data.
std_logic_misc: types, subtypes, constants y functiones
compelmetarias a std_logic_1164 package
Disponibles con:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
:
I Fundamentos de VHDL:
Lenguaje VHDL
Packages de usuario:
package my_types is
type small_int is range 0 to 1024;
type my_word_length is range 31 downto 0;
subtype data_word is my_word_length is range 7 downto 0;
type cmos_level is range 0.0 to 3.3;
type conductance is range 0 to 2E-9
units
mho;
mmho = 1E-3 mho;
umho = 1E-6 mho;
nmho = 1E-9 mho;
pmho = 1E-12 mho;
end units conductance;
end package my_types;
I Fundamentos de VHDL:
Lenguaje VHDL
Declaración Objetos:
Constantes : valor no modificable

Constant period : time := 8 ns ;


Constant pi : real :=3.14159;
Constant data : signed ( 0 to 7 ) :=“10000000”;
Constant data : unsigned ( 0 to 7 ) :=“10000000”;
Variables : valor con posibilidad de modificarse

Variable clock: bit := ‘0’;


Variable counter : integer range 0 to 15;
Variable address : std_logic_vector ( 3 downto 0 );
clock := ‘1’ ;
counter := counter + 1;
counter := 7;
address := “1100”;
address := “ZZZZ”;
I Fundamentos de VHDL:
Lenguaje VHDL
Declaración Objetos:
Señales : Puertos e interconexiones

Signal enable : std_logic := ‘0’;


Signal mux_out : std_logic_vector ( 3 downto 0);
Signal ALU_out : signed ( 3 downto 0 );
Signal OUT1: resolved: std_ulogic;
Signal OUT1: std_logic;
Signal A, B : Mi_Modulo;

enable <= ‘1’ after 10 ns , ‘Z’ after 25 ns ;


mux_out <= “XX11”;
ALU_out <= “1100”;
A.RISE_TIME<=5ns;
A.SIZE <= 120:
B<=A;
I Fundamentos de VHDL:
Lenguaje VHDL
Atributos predefinidos a señales:
Attribute Function

signal_name’event returns the Boolean value True if an event on the signal occurred, otherwise gives
a False
signal_name’active returns the Boolean value True there has been a transaction (assignment) on the
signal, otherwise gives a False
signal_name’transaction returns a signal of the type “bit” that toggles (0 to 1 or 1 to 0) every time there is a
transaction on the signal.
signal_name’last_event returns the time interval since the last event on the signal
signal_name’last_active returns the time interval since the last transaction on the signal
signal_name’last_value gives the value of the signal before the last event occurred on the signal

signal_name’delayed(T) gives a signal that is the delayed version (by time T) of the original one. [T is
optional, default T=0]
signal_name’stable(T) returns a Boolean value, True, if no event has occurred on the signal during the
interval T, otherwise returns a False. [T is optional, default T=0]

signal_name’quiet(T) returns a Boolean value, True, if no transaction has occurred on the signal during
the interval T, otherwise returns a False. [T is optional, default T=0]
I Fundamentos de VHDL:
Lenguaje VHDL
Ejemplos
If (CLOCK’event and CLOCK=‘1’) then …

Transición positiva de señal de reloj.

If (CLOCK’event and CLOCK=‘0’) then …

Transición negativa de señal de reloj.

CLOCK’last_event

Tiempo transcurrido desde ultima transición (edge).


I Fundamentos de VHDL:
Lenguaje VHDL
Atributos predefinidos a escalares:
Attribute Value

scalar_type’left returns the first or leftmost value of scalar-type in its


defined range
scalar_type’right returns the last or rightmost value of scalar-type in
its defined range
scalar_type’low returns the lowest value of scalar-type in its defined
range
scalar_type’high returns the greatest value of scalar-type in its
defined range
scalar_type’ascending True if T is an ascending range, otherwise False

scalar_type’value(s) returns the value in T that is represented by s (s


stands for string value).
I Fundamentos de VHDL:
Lenguaje VHDL
Ejemplos
type conductance is range 1E-6 to 1E3
units mho;
end units conductance;
type my_index is range 3 to 15;
type my_levels is (low, high, dontcare, highZ);

conductance’right returns: 1E3


conductance’high 1E3
conductance’low 1E-6
my_index’left 3
my_index’value(5) “5”
my_levels’left low
my_levels’low low
my_levels’high highZ
my_levels’value(dontcare) “dontcare”
I Fundamentos de VHDL:
Lenguaje VHDL
Atributos predefinidos a matrices:

Attribute Returns
MATRIX‘left(N) left-most element index
MATRIX’right(N) right-most index
MATRIX’high(N) upper bound
MATRIX’low(N) lower bound
MATRIX’length(N) the number of elements
MATRIX’range(N) range
MATRIX’reverse_range(N) reverse range
MATRIX’ascending(N) a Boolean value TRUE if index is
an ascending range, otherwise
FALSE
I Fundamentos de VHDL:
Lenguaje VHDL
Ejemplos
type MYARR8x4 is array (8 downto 1, 0 to 3) of boolean;
type MYARR1 is array (-2 to 4) of integer;

MYARR1’left returns: -2
MYARR1’right 4
MYARR1’high 4
MYARR1’reverse_range 4 downto to -2

MYARR8x4’left(1) 8
MYARR8x4’left(2) 0
MYARR8x4’right(2) 3
MYARR8x4’high(1) 8
MYARR8x4’low(1) 1
MYARR8x4’ascending(1) False
I Fundamentos de VHDL:
Lenguaje VHDL
Operadores disponibles:
Clase
1. Logical and or nand nor xor xnor
2. Relational = /= < <= > >=
3. Shift sll srl sla sra rol ror
4. Addition + = &
5. Unary + -
6. Multiplying * / mod rem
7. Miscellaneous ** abs not

Logical : Operaciones bit a bit sobre datos bit, boolean,


std_logic y std_ulogic. Resultados en datos del mismo tipo.
I Fundamentos de VHDL:
Lenguaje VHDL
Operadores Relacionales:

Operator Description Operand Types Result Type


= Equality any type Boolean
/= Inequality any type Boolean
< Smaller than Scalar or discrete Boolean
array types
<= Smaller than or scalar or discrete Boolean
equal array types
> Greater than scalar or discrete Boolean
array types
>= Greater than or scalar or discrete Boolean
equal array types
I Fundamentos de VHDL:
Lenguaje VHDL
Ejemplos
variable STS : Boolean;
constant A : integer :=24;
constant B_COUNT : integer :=32;
constant C : integer :=14;

STS <= (A < B_COUNT) ; -- “TRUE”


STS <= ((A >= B_COUNT) or (A > C)); -- “TRUE”
STS <= (std_logic (‘1’, ‘0’, ‘1’) < std_logic(‘0’, ‘1’,’1’));--“FALSE”

type new_std_logic is (‘0’, ‘1’, ‘Z’, ‘-‘);


variable A1: new_std_logic :=’1’;
variable A2: new_std_logic :=’Z’;

STS <= (A1 < A2); “TRUE” porque ‘1’ esta a la izq. de ‘Z’.
I Fundamentos de VHDL:
Lenguaje VHDL
Operadores Desplazamiento:
Operator Description Operand Type Result Type

sll Shift left logical (fill right Left: Any one-dimensional Same as left
vacated bits with the 0) array type with elements of type
type bit or Boolean; Right:
integer
srl Shift right logical (fill left same as above Same as left
vacated bits with 0) type
sla Shift left arithmetic (fill right same as above Same as left
vacated bits with rightmost type
bit)
sra Shift right arithmetic (fill left same as above Same as left
vacated bits with leftmost bit) type

rol Rotate left (circular) same as above Same as left


type
ror Rotate right (circular) same as above Same as left
type
I Fundamentos de VHDL:
Lenguaje VHDL
Ejemplos

variable NUM1 :bit_vector := “10010110”;

NUM1 srl 2; -- resultando “00100101”


NUM1 srl -2; -- resultando “10010110”

variable A :bit_vector := “101001”;

A sll 2 --“100100”
A srl 2 --“001010”
A sla 2 --“100111”
A sra 2 --“111010”
A rol 2 --“100110”
A ror 2 --“011010”
I Fundamentos de VHDL:
Lenguaje VHDL

Operadores Unarios:

Operator Description Left Operand Right Operand Result Type


Type Type
+ Addition Numeric type Same as left Same type
operand
- Subtraction Numeric type Same as left Same type
operand
& Concatenation Array or Same as left Same array type
element type operand
Solo indican signo de datos tipo numérico.
I Fundamentos de VHDL:
Lenguaje VHDL

Ejemplos

signal MYBUS :std_logic_vector (15 downto 0);


signal STATUS :std_logic_vector (2 downto 0);
signal RW, CS1, CS2 :std_logic;
signal MDATA :std_logic_vector ( 0 to 9);

MYBUS <= STATUS & RW & CS1 & SC2 & MDATA;
MYARRAY (15 downto 0) <= “1111_1111” & MDATA (2 to 9);
NEWWORD <= “VHDL” & “93”;
I Fundamentos de VHDL:
Lenguaje VHDL
Operadores Multiplicadores:
Description Left Operand Right Operand Result Type
Operator Type Type
Any integer or Same type Same type
* Multiplication floating point
Any physical Integer or real Same as left
type type
Any integer or Any physical Same as right
real type type
/ Division Any integer or Any integer or Same type
floating point floating point
Any physical Any integer or Same as left
type real t ype
Any physical Same type Integer
type
mod Modulus Any integer type Same type
rem Remainder Any integer type Same type
I Fundamentos de VHDL:
Lenguaje VHDL
Ejemplos

A rem B = A-(A/B)*B
A mod B = A-B*N, (N = entero)

11 rem 4 resulta 3
(-11) rem 4 -3
9 mod 4 1
7 mod (-4) –1 (7 – 4*2 = -1).
I Fundamentos de VHDL:
Lenguaje VHDL
Operadores Varios:
Operator Description Left Right Result Type
Operand Operand
Type Type
** Exponentiation Integer Integer type Same as
type left
Floating Integer type Same as
point left
abs Absolute value Any numeric type Same type

not Logical negation Any bit or Boolean type Same type


I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una descripción
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una descripción

Bibliotecas: recursos , funciones y operaciones.

Entidad: Definición de puertos ( entradas y salidas ).

Arquitectura: procesos , interacciones y señales internas.


I Fundamentos de VHDL:
Lenguaje VHDL

Declaración de una entidad

entity NAME_OF_ENTITY is [ generic generic_declarations);]


port (signal_names: mode type;
signal_names: mode type;
:
signal_names: mode type);
end [NAME_OF_ENTITY] ;
I Fundamentos de VHDL:
Lenguaje VHDL
Declaración de una entidad

entity BUZZER is

port (DOOR, IGNITION, SBELT: in std_logic; WARNING: out std_logic);

end BUZZER;
I Fundamentos de VHDL:
Lenguaje VHDL
Declaración de una entidad
Multiplexor 4 a 1:

entity mux4_to_1 is
port (I0, I1, I2, I3: in std_logic_vector(7 downto 0);
Out1: out std_logic_vector(7 downto 0));
end mux4_to_1;

Flip Flop D:

entity dff_sr is
port (D,CLK,S,R: in std_logic; Q,Qnot: out std_logic-);
end dff_sr;
I Fundamentos de VHDL:
Lenguaje VHDL
Modos de señales
in Señal entrada

out Señal salida

buffer Señal de salida que puede ser leida por la misma entidad.

inout Señal de bidireccional


Generic Opcional y usado para constantes locales en la entidad.
generic (
constant_name: type [:=value] ;
constant_name: type [:=value] ;
:
constant_name: type [:=value] );
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
architecture architecture_name of NAME_OF_ENTITY is
-- Declarations
-- components declarations
-- signal declarations
-- constant declarations
-- function declarations
-- procedure declarations
-- type declarations
:
begin
-- Statements
:
end architecture_name;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
1) Funcional :
• Describe el comportamiento del sistema visto desde fuera.
(Behavioral)
• Describe el comportamiento del sistema mediante señales internas.
(Data Flow)
2) Estructural :
Describe el sistema como un mapa de componentes.
(Structural)
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
1) Modelo funcional (Behavioral)
• Definición explicita de la relación entre la entrada y la salida sin
información de la implementación.

• Se realiza mediante “Procesos”.

• Todos los procesos se ejecutan concurrentemente.

• Cada proceso se realiza secuencialmente.

• El proceso se activa mediante una lista sensitiva de parámetros.

• Generalmente no incluye información de tiempos de retrasos.


I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional
(uso if-else)
Ejemplo 1: Comparador de dos datos de dos bits.

si a=b entonces c=1, de lo contrario c=0


I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
library ieee;
use ieee.std_logic_1164.all;

entity comp is
port (a,b: in bit_vector(1 downto 0);
Modelo funcionalc: out bit);
end comp;
(uso de if-else)
arquitecture funtional of comp is
begin
compara: process (a,b)
begin
if a = b then
c <= ‘1’;
else
c <= ‘0’;
end if;
end process compara;
end functional;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional
(uso if-else)
Ejemplo 2: Compuerta OR.
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional
library ieee; (uso de if-else)
use ieee.std_logic_1164.all;

entity com_or is
port (a,b: in std_logic;
f1: out std_logic);
end com_or;

arquitecture funtional of com_or is


begin
process (a,b) begin
if (a = ‘0’ and b = ‘0’) then
f1 <= ‘0’;
else
f1 <= ‘1’;
end if;
end process;
end functional;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional
(uso de case-when)
Ejemplo 5: Utilizar el modelo de descripción funcional para
representar un multiplexor de 4 a 1.
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura Modelo funcional
(case-when)

library ieee;
use ieee.std_logic_1164.all;

entity MUX_4_1 is
port (SEL : in std_logic_vector(2 downto 1);
A, B, C, D : in std_logic
Z : out std_logic);
end MUX_4_1;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura Modelo funcional
(case-when)
arquitecture functional of MUX_4_1 is
begin
PR_MUX: process (SEL, A, B, C, D)
begin
case SEL is
when “00” => Z <= A;
when “01” => Z <= B;
when “10” => Z <= C;
when “11” => Z <= D;
when others => Z <= ‘X’;
end case;
end process PR_MUX;
end functional;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional con flujo de datos
(Diseño concurrente)

Ejemplo 1: Circuito sumador de 4 bits mediante asignación de


señales concurrentes.
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional con flujo de
library ieee;
use ieee.std_logic_1164.all;
datos (Diseño concurrente)
use ieee.std_logic_unsigned.all;

entity ADD4 is
port (
A: in std_logic_vector (3 downto 0);
B: in std_logic_vector (3 downto 0);
CIN: in std_logic;
SUM: out std_logic_vector (3 downto 0);
COUT: out std_logic;
);
end ADD4;

arquitecture flujoDatos of ADD4 is


signal SUMINT: std_logic_vector(4 downto 0);
begin
SUMINT <= (‘0’ & A) + (‘0’ & B) + (‘0000’ & CINT);
COUT <= SUMINT(4);
SUM <= SUMINT(3 downto 0);
end flujoDatos;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional flujo de datos (when-else)

Ejemplo 2: Comparador de dos datos de dos bits mediante


when-else.
si a=b entonces c=1, de lo contrario c=0
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional de flujo de datos
library ieee; (when-else)
use ieee.std_logic_1164.all;

entity comp is
port (a,b: in bit_vector(1 downto 0);
c: out bit);
end comp;

arquitecture f_datos of comp is


begin
c <= ‘1’ when ( a = b ) else ‘0’;
end f_datos;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura

Modelo funcional de flujo de datos


(when-else)
Ejemplo 3: Compuerta AND mediante when-else.
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional flujo de datos
(when-else)
library ieee;
use ieee.std_logic_1164.all;

entity com_and is
port (a,b: in std_logic;
f1: out std_logic);
end com_and;

arquitecture f_datos of com_and is


begin
f <= ‘1’ when ( a = ‘1’ and b = ‘1’ ) else ‘0’;
end f_datos;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional flujo de datos (ec. boolenas)

Ejemplo 4: Comparador de dos datos de dos bits mediante


ecuaciones booleanas.
si a=b entonces c=1 de lo contrario c=0
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional flujo de datos (ec. boolenas)
library ieee;
use ieee.std_logic_1164.all;

entity comp is
port (a,b: in bit_vector(1 downto 0);
c: out bit);
end comp;

arquitecture booleana of comp is


begin
c <= (a(1) xnor b(1) and a(0) xnor b(0) );
end booleana;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional flujo de datos (ec. boolenas)

Ejemplo 5: Describir mediante ecuaciones booleanas el siguiente


circuito:
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional flujo de datos (ec. boolenas)
library ieee;
use ieee.std_logic_1164.all;

entity ejemplo is
port (a,b,c,d: in std_logic;
f: out std_logic);
end ejemplo;

arquitecture booleana of ejemplo is


begin
f <= (a or b) xnor (c and b );
end booleana;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional flujo de datos (ec. boolenas)
Ejemplo 6: Describir mediante ecuaciones booleanas el siguiente
circuito utilizado para activar una señal de advertencia en un
automovil.
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo de flujo de datos
entity BUZZER is

port (DOOR, IGNITION, SBELT: in std_logic;


WARNING: out std_logic);

end BUZZER;
architecture f_datos of BUZZER is
begin

WARNING <= (not DOOR and IGNITION) or (not SBELT and IGNITION);

end f_datos;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional flujo de datos
(señales seleccionadas, witn-select-when )

Ejemplo 7: Circuito sumador completo mediante señales


seleccionadas.
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional flujo de datos
(señales seleccionadas, witn-select-when )
library ieee;
use ieee.std_logic_1164.all;

entity Full_Add is
port (
A, B, C : in std_logic;
SUM, COUT : out std_logic );
end Full_Add;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo funcional flujo de datos
(señales seleccionadas, witn-select-when )
arquitecture flujoDatos of Full_Add is
signal INS: std_logic_vector(2 downto 0);
begin
INS(2) <= A;
INS(1) <= B;
INS(0) <= C;
with INS select
(sum, cout) <= std_logic_vector’ (“00”) when “000”,
(sum, cout) <= std_logic_vector’ (“10”) when “001”,
(sum, cout) <= std_logic_vector’ (“10”) when “010”,
(sum, cout) <= std_logic_vector’ (“01”) when “011”,
(sum, cout) <= std_logic_vector’ (“10”) when “100”,
(sum, cout) <= std_logic_vector’ (“01”) when “101”,
(sum, cout) <= std_logic_vector’ (“01”) when “110”,
(sum, cout) <= std_logic_vector’ (“11”) when “111”,
(sum, cout) <= std_logic_vector’ (“11”) when others;
end flujoDatos;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
2) Modelo estructural
• Se basa en modelos lógicos establecidos (sumadores, contadores,
compuertas,..etc

• Los modelos están disponibles mediante paquetes en las librerias


utilizadas o el usuario puede tener sus propios modelos.

• Dichos modelos son componentes de la estructura.

• La descripción se basa en establecer que componentes hay en el


diseño y como estan interconectados, comparable a un diagráma
esquemático.

• El conectado se debe realizar mediante señales internas.


I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
2) Modelo estructural
Formato:

architecture architecture_name of NAME_OF_ENTITY is


-- Declarations
component declarations
signal declarations
begin
-- Statements
component instantiation and connections
:
end architecture_name;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
2) Modelo estructural
Declaración de componentes.

component component_name [is]


[port (port_signal_names: mode type;
port_signal_names: mode type;
:
port_signal_names: mode type);]
end component [component_name];
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
2) Modelo estructural
component OR2
port (in1, in2: in std_logic; out1: out std_logic);
end component;

component PROC
port (CLK, RST, RW, STP: in std_logic;
ADDRBUS: out std_logic_vector (31 downto 0);
DATA: inout integer range 0 to 1024);
end component;

component FULLADDER
port (a, b, c: in std_logic; sum, carry: out std_logic);
end component;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
2) Modelo estructural
• Instanciación y conexión de componentes.

instance_name : component name


port map (port1=>signal1, port2=> signal2,… port3=>signaln);

instance_name : component name


port map (signal1, signal2,…signaln);
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo estructural
Ejemplo 1: Comparador de dos datos de dos bits utilizando el
modelo estructural.
si a=b entonces c=1, de lo contrario c=0
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo estructural
library ieee;
use ieee.std_logic_1164.all;
use work.compuerta.all;

entity comp is
port (a,b: in bit_vector(1 downto 0);
c: out bit);
end comp;

arquitecture estructural of comp is


signal x: bit_vector (0 to 1);
begin
U0: xnor2 port map (a(0), b(0), x(0) );
U1: xnor2 port map (a(1), b(1), x(1) );
U2: xnor2 port map (x(0), x(1), c );
end estructural;
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
Modelo estructural
Ejemplo 2: Describir mediante el modelo estructural el siguiente
circuito:
I Fundamentos de VHDL:
Lenguaje VHDL
Estructura de una Arquitectura
library ieee; Modelo estructural
use ieee.std_logic_1164.all;
use work.compuerta.all;

entity comp is
port ( A, B, C : in std_logic;
F: out std_logic);
end comp;

arquitecture estructural of comp is


signal x: bit_vector (0 to 2);
begin
U0: and2 port map (B, C, x(0) );
U1: and2 port map (C, A, x(1) );
U2: and2 port map (A, B, x(2) );
U3: or3 port map (x(0), x(1), x(2), F );
end estructural;
I Fundamentos de VHDL:
Lenguaje VHDL

Estructura de una Arquitectura


Modelo estructural
Ejemplo 3: AÑADIR OTRO EJEMPLO QUE INCLUYA DECLARACIÓN
DE COMPONENTES Y PONERLO COMO EJEMPLO 1

También podría gustarte