Está en la página 1de 19

Microelectrnica ITT-Sistemas Electrnicos

EL LENGUAJE VHDL
SNTESIS VHDL
MODELOS VHDL PARA SNTESIS LGICA
Los modelos que es capaz de interpretar un sintetizador deben
atenerse a unas reglas que restringen el estilo de la descripcin
hardware.
La sntesis slo asegura que el circuito obtenido tiene el mismo
comportamiento funcional que la descripcin VHDL realizada.
Para modelar circuitos digitales sncronos es recomendable:
pensar en hardware
evitar bucles combinacionales y relojes condicionados
identificar las partes combinacionales y secuenciales del
circuito
utilizar seales en vez de variables
emplear los tipos std_logic en vez de bit ya que son ms
cercanos al hardware
realizar un reset hardware inicial
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
1
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
LGICA COMBINACIONAL
Asignacin concurrente a seal
La seal destino no debe intervenir en la forma de onda
de ninguna asignacin de ninguna asignacin.
a <= b and c when e=0 else 1;
b
d
a
c
e
a
a <= b and c when a=0 else 1;
a <= b and c when e=0 else a;
b
d
c
D
Q
a
No deben existir lazos combinacionales
e
arquitecture ejemplo of entidad is arquitecture ejemplo of entidad is
signal a, b, c, d : std_logic;
begin
a <= b or c;
c <= d and a;
end ejemplo;
c
b
a
d
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
2
b
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
El operador de concatenacin (&) no infiere lgica y se
utiliza para agrupar seales.
entity concatena is
port (a, b, c : in std logic; p ( , , _ g ;
z : out std_logic_vector
(2 downto 0));
end concatena;
architecture FlujoDatos of concatena is
begin
( ) & (b) & ( )
Asignaciones a seal seleccionada y condicional
Asignacin seleccionada
z <= not (a) & not (b) & not (c);
end FlujoDatos;
sel <= sel1 & sel0;
with sel select
z<= d0 when "00",
d1 when "01" ,
d2 when "10",
d3 when "11",
'X' when others;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
3
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
Asignacin condicional
z<= d0 when (sel="00") else
d1 when (sel="01") else
d2 when (sel="10") else
d ( l " ") ' ' d3 when (sel="11") else 'X';
d3
d2
d1
d0
z
Mejor utilizar asignaciones seleccionadas frente a
sel[1:0]
z
sel[1:0]=10 sel[1:0]=01
sel[1:0]=00
Mejor utilizar asignaciones seleccionadas frente a
condicionales.
Se debe especificar el valor de la seal asignada
para todas las combinaciones de las seales de
entrada.
Los bloques con seal de guarda se pueden usar en
descripcin de buses con control triestado:
signal z : bus; signal z : . bus;
tri : block (en=1)
begin
z<= guarded entrada;
end block tri;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
4
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
Modelado mediante procesos
Todas las seales utilizadas en las formas de onda de las
asignaciones secuenciales de seal o variables deben
incluirse en la lista de sensibilidad del proceso.
process (a, b)
begin
if (a=1 and b=1) then
z<=1;
else else
z<=0
end if;
end process;
Algunas herramientas permiten sustituir la lista de
sensibilidad por la sentencia wait on equivalente.
process
begin
if (a 1 and b 1) then if (a=1 and b=1) then
z<=1;
else
z<=0
end if;
wait on a, b; wait on a, b;
end process;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
5
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
Bajo cualquier condicin de ejecucin del proceso todas
las variables y seales de salida o intermedias deben ser
asignadas.
process (b, c, e) process (b, c, e)
variable d:
begin
if (b=1) then
d:=c;
else
d:=0
variable d:
begin
if (b=1) then
d:=c;
end if;
a<=d or e;
latch
d:= 0
end if;
a<=d or e;
end process;
a<=d or e;
end process;
Conviene evitar los procesos en los que una variable se
utiliza antes de ser asignada.
process (entrada)
variable var: std_ulogic;
process (entrada)
variable var: std_ulogic;
begin
output <= var;
var := entrada;
end process;
begin
var := entrada;
output <= var;
end process;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
6
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
La sentencia case infiere un multiplexor.
process (sel, d0, d1, d2, d3)
begin
case sel is
" " d when "00" => z<= d0;
when "01" => z<= d1;
when "10" => z<= d2;
when "11" => z<= d3;
when others => z<= '0';
end case;
La sentencia if infiere un grupo de multiplexores
end case;
end process;
process (sel d0 d1 d2 d3) process (sel, d0, d1, d2, d3)
begin
if (sel="00") then
z<=d0;
elsif (sel="01") then
z<= d1; d ;
elsif (sel="10") then
z<= d2;
elsif (sel="11") then
z<= d3;
else
z<= '0';
end if;
end process;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
7
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
Cuando se modelan circuitos que realizan funciones
aritmticas es importante utilizar tcnicas de
comparticin de recursos para reducir el rea consumida.
entity sumador is y
port (A,B,C,D : in integer range 0 to 15;
sel : in std_logic;
S : out integer range 0 to 15);
end sumador;
architecture FlujoDatos of sumador is
begin
process (A,B,C,sel)
begin
if (sel='1') then
S<=A+B;
else else
S<= A+C;
end if;
end process;
end FlujoDatos;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
8
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
entity sumador is
port (A,B,C,D : in integer range 0 to 15;
sel : in std_logic;
S : out integer range 0 to 15);
d d end sumador;
architecture FlujoDatos of sumador is
begin
process (A,B,C,sel)
variable aux: integer range 0 to 15;
begin begin
if (sel='1') then
aux:=B;
else
aux:=C;
end if;
S<= A+aux;
end process;
end FlujoDatos;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
9
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
El uso de parntesis puede mejorar la estructura del
hardware generado reduciendo los caminos crticos.
architecture FlujoDatos of sumador is
begin g
process (A,B,C,D)
begin
S<= A+B+C+D;
end process;
end FlujoDatos;
architecture FlujoDatos of sumador is
begin
process (A B C D) process (A,B,C,D)
begin
S<=(A+B)+(C+D);
end process;
end FlujoDatos;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
10
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
LGICA SECUENCIAL
Modelado de latches
Los sintetizadores generan latchs mediante el uso de
expresiones condicionales incompletas expresiones condicionales incompletas.
process (D, enable)
begin
if enable=1 then
Q<= D;
b1: block (enable=1)
begin
Q<= guarded D;
end block;
Latchs indeseados
end if;
end process;
;
Q<= D when (enable=1);
Q<= D when (enable=1) else Q;
process (a,b,c,d)
begin
if (a='1') then
z <= c;
elsif (b='1') then
z<= d;
end if;
end process;
process (a,b,c,d)
begin
process (a,b,c,d)
begin
if (a='1') then
begin
z<=0;
if (a='1') then
z <= c;
elsif (b='1') then
z<= d;
end if;
if (a 1 ) then
z <= c;
elsif (b='1') then
z<= d;
else
z<=0;
end if;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
11
;
end process;
end process;
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
process (sel, a,b,c)
begin
case sel is
when "00" => z<=a;
when "01" => z<=b; when 01 => z<=b;
when "10" => z<=c;
when others => null;
end case;
end process;
process (sel, a,b,c)
begin
z <= 0;
case sel is
process (sel, a,b,c)
begin
case sel is
when "00" => z<=a;
when "00" => z<=a;
when "01" => z<=b;
when "10" => z<=c;
when others => null;
end case;
end process;
when "01" => z<=b;
when "10" => z<=c;
when others =>
z <=0;
end case;
end process;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
12
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
Circuitos secuenciales sncronos
Dos tipos de construcciones:
process (reloj,seales_asncronas)
{declaracin de variables};
begin
if (seales_asncronas_activas) then
{asignaciones_asncronas};
elsif (deteccin_de_flanco) then
{algoritmo_de_funcionamiento_sncrono};
end if;
end process;
process
{declaracin de variables};
begin
wait until (deteccin_de_flanco)
{algoritmo de funcionamiento sncrono}; {algoritmo_de_funcionamiento_sncrono};
.
wait until (deteccin_de_flanco)
{algoritmo_de_funcionamiento_sncrono};
.
end process;
Construcciones de deteccin de flanco:
clkevent and clk=1
not clkstable and clk=1
funciones rising_edge y falling_edge del paquete de
sntesis sntesis
Slo se admite la especificacin de un reloj por proceso
process ()
if (clkaevent and clka=1) then .; end if;
if ( lkb d lkb 1) h d
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
13
if (clkbevent and clkb=1) then .; end
end process;
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
Registros
Con seales de inicializacin asncronas:
process (clk, reset)
begin
process
begin begin
if (reset=1) then
Q<=0;
elsif (clkevent and clk=1) then
Q<=D;
end if;
begin
if (reset=1) then
Q<=0;
else
wait until (clkevent and clk=1);
Q<=D;
Con seales de inicializacin sncronas
;
end process;
Q ;
end if;
end process;
process (clk) process process (clk)
begin
if (clkevent and clk=1) then
if (reset=1) then
Q<=0;
else
process
begin
wait until (clkevent and clk=1);
if (reset=1) then
Q<=0;
else e se
Q<=D;
end if;
end if;
end process;
e se
Q<=D;
end if;
end process;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
14
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
Si se accede a una variable antes de asignarle un nuevo
valor se generan biestables para dicha variable.
process (clk)
variable a, b : std logic; , _ g ;
begin
if (clkevent and clk=1) then
salida <=b;
b := a;
a := entrada;
if end if;
end process;
Con seales de inicializacin sncronas
process (clk)
variable a, b : std_logic;
begin
if (clkevent and clk=1) then
t d a := entrada;
b := a;
salida <=b;
end if;
end process;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
15
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
Modelado de registros mediante bloques con guarda:
block (clkevent and clk=1)
begin g
Q<= guarded 0 when reset=1 else D;
end block;
Modelado de registro de 8 bits con seal de clear Modelado de registro de 8 bits con seal de clear
asncrona.
process (clk, clear)
begin
if (clear=1) then
salida <=00000000;
elsif (clkevent and clk=1) then
salida <=entrada;
end if;
end process;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
16
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
Registro de desplazamiento universal
ENTRADAS SALIDAS
CLR S1 S0 CLK SLI SRI D
3
D
2
D
1
D
0
Q3 Q2 Q1 Q0
L
H
X X
X X
X
L
X X
X X
X X X X
X X X X
L L L L
QA0 QB0 QC0 QD0 H
H
H
H
H
H
H
X X
H H
L H
L H
H L
H L
L L
L

X
X X
X X
X H
X L
H X
L X
X X
X X X X
a b c d
X X X X
X X X X
X X X X
X X X X
X X X X
QA0 QB0 QC0 QD0
a b c d
H QAn QBn QCn
L QAn QBn QCn
QBn QCn QDn H
QBn QCn QDn L
QA0 QB0 QC0 QD0
library ieee; library ieee;
use ieee.std_logic_1164.all;
entity shift_reg is
generic (N: positive :=3);
port (clk, clr, sli, sri: in std_logic;
S0, S1 : in std logic; D : in std logic vector (N-1 downto 0); , _ g ; _ g _ ( );
Q : out std_logic_vector(N-1 downto 0));
end shift_reg;
architecture rtl of shift_reg is
signal aux : std_logic_vector (N-1 downto 0);
signal sel : std_logic_vector (1 downto 0);
begin
Q <= aux; sel <=S1&S0;
process (clk, clr)
begin
if (clr='0') then aux <=(others => '0');
elsif (clk'event and clk='1') then
case sel is
h "00" ll when "00" => null;
when "01" => aux <= sri & aux (N-1 downto 1);
when "10" => aux <= aux(N-2 downto 0)&sli;
when "11" => aux <=D;
when others => null;
end case;
end if;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
17
end if;
end process;
end rtl;
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
Contadores
Se basa en el uso de incrementadores/decrementadores
Ejemplo: contador binario up/down de 4 bits con seal de
reset asncrona carga sncrona y habilitacin de cuenta reset asncrona, carga sncrona y habilitacin de cuenta.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity cont4b is
i (N i i 3) generic (N: positive :=3);
port (clk, rst, enable, cuenta, carga: in std_logic;
dato : in unsigned(3 downto 0);
salida : out unsigned(3 downto 0));
end cont4b;
architecture rtl of cont4b is
signal cnt : unsigned (3 downto 0); signal cnt : unsigned (3 downto 0);
begin
salida <= cnt;
process (clk, rst)
begin
if rst='1' then
cnt <="0000"; cnt 0000 ;
elsif (clk'event and clk='1') then
if (carga ='1') then
cnt <=dato;
else
if (cuenta='1' and enable ='1') then
cnt <= cnt + 1 mod 16;
elsif (cuenta='0' and enable ='1') then
cnt <= cnt - 1 mod 16;
end if;
end if;
end if;
end process;
d l
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
18
end rtl;
Microelectrnica ITT-Sistemas Electrnicos
EL LENGUAJE VHDL
SNTESIS VHDL
Conversor paralelo-serie de N bits
library ieee;
use ieee.std_logic_1164.all;
entity par2serie is entity par2serie is
generic (N: positive :=3);
port (data_in : in std_logic_vector(N-1 downto 0);
clk, data_rdy : in std_logic;
data_out : out std_logic);
end par2serie;
architecture rtl of par2serie is
signal aux : std_logic_vector (N-1 downto 0);
begin
data_out <= aux(N-1);
process (clk)
begin
if(clk'event and clk='1') then
if (d d '1') h d i if (data_rdy ='1') then aux <= data_in;
else aux (N-1 downto 1) <=aux (N-2 downto 0);
end if;
end if;
end process;
end rtl;
METODOLOGAS Y HERRAMIENTAS PARA EL DISEO DE SISTEMAS DIGITALES
19

También podría gustarte