Académique Documents
Professionnel Documents
Culture Documents
Ingeniera Mecatrnica
Proyecto final
"Programacin en VHDL"
Baeza Martnez, Jess Daniel
Nava Fausto, Luis Felipe
Resumen - En el presente texto se expone el desarrollo de una serie de prcticas en lenguaje de VHDL
diseadas para introducir a los alumnos de la materia de Electrnica Digital al conocimiento y manejo de
herramientas de programacin de sistemas digitales programables, con el objetivo de propiciar el correcto
desarrollo de las cualidades acadmico-laborales de los ingenieros en formacin.
Palabras Clave Mquina de estados, programacin de eventos, temporizacin.
w <= a xor b;
I. MTODOS
end Behavioral;
Prctica #1. Agrupamiento y comportamiento de
compuertas lgicas.
El programa consista en listar cada una de las
compuertas solicitadas y emplear adecuadamente los
comandos de arquitectura para que la tarjera
ejecutara las operaciones bsicas de forma correcta
en virtud de sus entradas.
Cdigo de solucin:
Cdigo de solucin:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Declaracin de entidades
entity OPERACIONALES is
Port ( a,b : in STD_LOGIC;
r,s,t,u,v,w : out STD_LOGIC);
end OPERACIONALES;
--Descripcin de la arquitectura de la entidad.
v <= a and b;
u <= h or i;
t <= not g;
s <= c nand d;
r <= e nor f;
w <= j xor k;
end Behavioral;
B
0
1
1
0
Verde
Amarillo
1
0
0
1
0
0
0
0
Tabla. 1. Secuencia #1
Rojo
0
0
1
1
A
0
0
1
1
B
0
1
1
0
Verde
Amarillo
0
0
0
0
1
0
0
1
Tabla. 2. Secuencia #2
Rojo
1
1
0
0
2 =
1 =
2 =
1 =
1 =
2 =
Tabla 3. Solucin a la reduccin de ecuaciones
por mapas de Karnaugh
Cdigo:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--Declaracin de la secuencia como entidad,
declarando las entradas a y b de la tabla de verdad y
las variables v, a y r como salidas.
entity Secuencia is
Port ( a,b : in STD_LOGIC;
v1,a1,r1,v2,a2,r2 : out STD_LOGIC);
end Secuencia;
a
b
c
d
e
f
g
G
1
0
1
1
1
1
1
O
1
1
1
1
1
1
0
L
0
0
0
1
1
1
0
I
0
0
0
0
1
1
0
N
1
1
1
0
1
1
0
C
1
0
0
1
1
1
0
E
1
0
0
1
1
1
1
S
1
0
1
1
0
1
1
I
0
0
0
0
1
1
0
T
1
0
0
0
1
1
0
C
1
0
0
1
1
1
0
E
1
0
0
1
1
1
1
L
0
0
0
1
1
1
0
A
1
1
1
0
1
1
1
Y
0
1
1
1
0
1
1
A
1
1
1
0
1
1
1
Tabla 5. Tabla para mostrar la secuencia de leds
que necesita cada una de las letras para reflejarse en
el display de siete segmentos.
Cdigo:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--Definicin en la entidad del display de 7
segmentos.
entity Display is
Port ( Q0,Q1,Q2,Q3 : in STD_LOGIC;
l,m,n,a,b,c,d,e,f,g : out STD_LOGIC);
end Display;
--Desarrollo de las ecuaciones individuales para cada
uno de los leds que conforman el display de 7
segmentos.
architecture Behavioral of Display is
begin
a<= not (((not Q0) and (not Q1) and (not Q2) and
(not Q3)) or ((not Q0) and (not Q1) and (not Q2) and
(Q3)) or ((not Q0) and (Q1) and (not Q2) and (not
Q3)) or ((not Q0) and (Q1) and (not Q2) and (Q3))
or ((not Q0) and (Q1) and (Q2) and (not Q3)) or ((not
Q0) and (Q1) and (Q2) and (Q3)) or ((Q0) and (not
Q1) and (not Q2) and (Q3)) or ((Q0) and (not Q1)
and (Q2) and (not Q3)) or ((Q0) and (not Q1) and
(Q2) and (Q3)) or ((Q0) and (Q1) and (not Q2) and
(Q3)) or ((Q0) and (Q1) and (Q2) and (Q3)));
b<= not (((not Q0) and (not Q1) and (not Q2) and
(Q3)) or ((not Q0) and (Q1) and (not Q2) and (not
Q3)) or ((Q0) and (Q1) and (not Q2) and (Q3)) or
((Q0) and (Q1) and (Q2) and (not Q3)) or ((Q0) and
(Q1) and (Q2) and (Q3)));
c<= not (((not Q0) and (not Q1) and (not Q2) and
(not Q3)) or ((not Q0) and (not Q1) and (not Q2) and
(Q3)) or ((not Q0) and (Q1) and (not Q2) and (not
Q3)) or ((not Q0) and (Q1) and (Q2) and (Q3)) or
((Q0) and (Q1) and (not Q2) and (Q3)) or ((Q0) and
(Q1) and (Q2) and (not Q3)) or ((Q0) and (Q1) and
(Q2) and (Q3)));
d<= not (((not Q0) and (not Q1) and (not Q2) and
(not Q3)) or ((not Q0) and (not Q1) and (not Q2) and
(Q3)) or ((not Q0) and (not Q1) and (Q2) and (not
Q3)) or ((not Q0) and (Q1) and (not Q2) and (Q3))
or ((not Q0) and (Q1) and (Q2) and (not Q3)) or ((not
Q0) and (Q1) and (Q2) and (Q3)) or ((Q0) and (not
Q1) and (Q2) and (not Q3)) or ((Q0) and (not Q1)
and (Q2) and (Q3)) or ((Q0) and (Q1) and (not Q2)
and (not Q3)) or ((Q0) and (Q1) and (Q2) and (not
Q3)));
e<= not (((not Q0) and (not Q1) and (not Q2) and
(not Q3)) or ((not Q0) and (not Q1) and (not Q2) and
(Q3)) or ((not Q0) and (not Q1) and (Q2) and (not
Q3)) or ((not Q0) and (not Q1) and (Q2) and (Q3))
or ((not Q0) and (Q1) and (not Q2) and (not Q3)) or
((not Q0) and (Q1) and (not Q2) and (Q3)) or ((not
Q0) and (Q1) and (Q2) and (not Q3)) or ((Q0) and
(not Q1) and (not Q2) and (not Q3)) or ((Q0) and (not
Q1) and (not Q2) and (Q3)) or ((Q0) and (not Q1)
and (Q2) and (not Q3)) or ((Q0) and (not Q1) and
(Q2) and (Q3)) or ((Q0) and (Q1) and (not Q2) and
(not Q3)) or ((Q0) and (Q1) and (not Q2) and (Q3))
or ((Q0) and (Q1) and (Q2) and (Q3)));
f<= '0';
g<= not (((not Q0) and (not Q1) and (not Q2) and
(not Q3)) or ((not Q0) and (Q1) and (Q2) and (not
Q3)) or ((not Q0) and (Q1) and (Q2) and (Q3)) or
((Q0) and (not Q1) and (Q2) and (Q3)) or ((Q0) and
(Q1) and (not Q2) and (Q3)) or ((Q0) and (Q1) and
(Q2) and (not Q3)) or ((Q0) and (Q1) and (Q2) and
(Q3)));
Ingeniera Mecatrnica; Electrnica Digital A; Diciembre 8, 2016
l<= '1';
m<= '1';
n<= '1';
end Behavioral;
Cdigo:
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
Cdigo:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--Declaracin del decodificador en la entidad a
travs del uso de vectores
entity Prctica5_b is
Port ( x : in STD_LOGIC_VECTOR (3
downto 0);
z : out STD_LOGIC_VECTOR (3 downto
0);
d : out STD_LOGIC_VECTOR (6 downto
0));
end Prctica5_b;
architecture Behavioral of Prctica5_b is
begin
z<="0111";
--Desarrollo de la secuencia de casos
process(x)
begin
case x is
when "0000" => d <= "0000001";
when "0001" => d <= "1001111";
when "0010" => d <= "0010010";
when "0011" => d <= "0000110";
when "0100" => d <= "1001100";
when "0101" => d <= "0100100";
when "0110" => d <= "0100000";
when "0111" => d <= "0001111";
when "1000" => d <= "0000000";
when others => d <= "0000100";
end case;
end process;
end Behavioral;
Prctica #6. Multiplexor.
Como el multiplexor es un dispositivo que recibe
varias lneas de entradas, y otorga una sola salida, se
expresa su comportamiento como un switch
multiple, y ese comportamiento, a travs de nuestras
entradas definidas por las letras a-g, lo intentamos
replicar.
Cdigo:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Multiplexor is
Port ( a,b,c,d,e,f,g,h : in STD_LOGIC;
sel : in STD_LOGIC_VECTOR(2 downto
0);
sal : out STD_LOGIC);
end Multiplexor;
--Descripcin de la arquitectura de operacin del
multiplexor mediante una estructura de casos.
architecture Behavioral of Multiplexor is
begin
process(sel, a, b, c, d, e, f, g, h)
begin
case sel is
when "000"=>sal<=a;
when "001"=>sal<=b;
when "010"=>sal<=c;
when "011"=>sal<=d;
when "100"=>sal<=e;
when "101"=>sal<=f;
when "110"=>sal<=g;
when others =>sal<=h;
end case;
Prctica #7. Demultiplexor.
Partiendo del hecho que un demultiplexor
convierte una seal serial de datos en su entrada en
una seal de datos paralelos a su salida, es que se
dise este programa.
Configuramos primeramente una entrada a la cual
llamamos Y, y la definimos como un vector de magnitud
7 para representar el bus de datos seriales que menciona
el problema.
Posteriormente, se establecieron dos variables de
salida, las cuales fueron llamadas X1 y X2. Dentro de la
seccin de arquitectura del problema, definimos un if con
el cual asignabamos los valores de cambio de acuerdo al
estado seleccionado, es decir, si la seleccin asignada era
0, X1 conservara el valor del bus de datos, mientras que
X2 recibira un valor de 0 para cada elemento en su
vector; o bien, si la seleccin era denotada por un 1, el
vector de salida X1 se mantendra en cero para cada uno
de sus valores individuales, mientras que el vector X2
asumira el valor del vector Y de entrada.
Cdigo
entity Sumador_restador is
library IEEE;
Port ( a,b : in STD_LOGIC_VECTOR (2
use IEEE.STD_LOGIC_1164.ALL;
downto 0);
use IEEE.STD_LOGIC_UNSIGNED.ALL;
se : in STD_LOGIC;
use IEEE.STD_LOGIC_ARITH.ALL;
r : out STD_LOGIC_VECTOR (6 downto
0);
entity Jkf is
z : out STD_LOGIC_VECTOR (3 downto
Port ( clk,j,k,pre,clr : in STD_LOGIC;
0));
q,qn : out STD_LOGIC);
end Sumador_restador;
Ingeniera Mecatrnica; Electrnica Digital A; Diciembre 8, 2016
end Jkf;
when
others
else
when others => q<='1'; qn<='1';
cnt <= 0;
pulso <= not pulso;
end
case;
end if;
end if;
end if;
end process;
end Behavioral
if pre='1' then
q<='1';
qn <= '0';
Cdigo:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity Contador_0_25 is
Port ( boton,rst,clk : in STD_LOGIC;
seg : out STD_LOGIC_VECTOR (6
downto 0);
an: out STD_LOGIC_VECTOR (3 downto
0));
end Contador_0_25;
not
if mux<9999 then
mux<=mux+1;
else mux<=0; t<=not t;
end if;
pulso;
end if;
if j='1' then u<=0; d<=0;
end if;
case t is
when '0' => sum <=u; an<="1110";
when others => sum<=d; an <="1101";
end case;
case sum is
when 0 => seg <= "0000001";
when 1 => seg <= "1001111";
when 2 => seg <= "0010010";
when 3 => seg <= "0000110";
when 4 => seg <= "1001100";
when 5 => seg <= "0100100";
when 6 => seg <= "0100000";
when 7 => seg <= "0001111";
when 8 => seg <= "0000000";
when others => seg <= "0001100";
end case;
end if;
II. RESULTADOS
.
Reporte
Prcticas VHDL
if pulso='1' then
ant<=boton;
if boton='1' and ant='0' then i<='1';
else i<='0';
end if;
end if;
if pulso1='1' then
ant2<=rst;
if rst='1' and ant2='0' then j<='1';
else j<='0';
end if;
end if;
if i='1' then u<=u+1;
end if;
if u>9 then
d<=d+1;
u<=0;
end if;
III. CONCLUSIONES
En la actualidad, el nivel de desarrollo de los
sistemas lgico-programables permite la elaboracin
de sistemas funcionales en espacios reducidos dentro
del campo industrial, militar y de consumo,
permitiendo as el acceso a un nmero casi infinito
de procesos que faciliten las tareas cotidianas, o
permitan a los usuarios de estos sistemas la
implementacin de procesos de gran escala a costos
relativamente bajos en comparacin con programas
y dispositivos ASCI, que son desarrollados para
cumplir con tareas especficas.
Gracias a este amplio avance tecnolgico, es
necesario el crecimiento formativo de un ingeniero
en el mbito de los sistemas digitales, ya que las
competencias actuales laborales exigen altos
rendimientos y bajo uso de recursos.