Professional Documents
Culture Documents
MANUAL DE PRÁCTICAS
PARA LA
PROGRAMACION EN
HDL
CARRERA DE MECATRÓNICA
1
2
OBJETIVOS:
OBJETIVOS;
Desarrollo de la práctica:
2
3
Procedimiento.
Ilustracion 2.
Ilustración 2.
Ilustarcion 3.
3
4
Ilustración 3.
Family: Spartan3E
Device: XC3S11E
Package: TQ144
Speed: -4
Ilustarcion 4.
4
5
Ilustración 4.
Ilustarción 5.
Ilustración 5.
5
6
Ilustración 6, 7.
Ilustración 7.
Ilustración 6.
Ilustracion 8.
Ilustración 8.
6
7
Ilustracion 9.
Ilustración 9.
Ilustración 10.
7
8
Ilustracion 11.
Ilustración 11.
Ilustracion 12.
Ilustración 12.
8
9
Ilustración 13.
Ilustración 14.
Ilustración 15.
Ilustracion 16.
Ilustración 16.
9
10
Ilustracion 17.
Ilustración 17.
Ilustracion 18.
Ilustración 18.
Ilustracion 14.
10
11
Ilustración 14.
Tabla de verdad
Ilustración 17.
Ilustración 15.
11
12
Ilustración 17
Ilustración 16.
11
13
Library ieee;
use ieee.std_logic_1164.all;
entity compuerta_and is
port(
M: in std_logic;
Y: in std_logic;
X: out std_logic
);
end compuerta_and;
Architecture
begin
X<= M and Y;
end compuerta;
Ilustración 1, 2.
TABLA DE VERDAD
Ilustración 3.
Ilustración 1. Ilustración 2.
Ilustración 3.
12
14
Library ieee;
use ieee.std_logic_1164.all;
entity compuerta_or is
port(
A: in std_logic;
B: in std_logic;
C: out std_logic
);
end compuerta_or;
Architecture
begin
C<= A and B;
end compuerta;
Ilustración 1, 2.
TABLA DE VERDAD
Ilustración 1. Ilustración 2.
Ilustración 4.
13
15
Library ieee;
use ieee.std_logic_1164.all;
entity compuerta_nand is
port(
A: in std_logic;
B: in std_logic;
C: out std_logic
);
end compuerta_or;
Architecture
begin
C<= A nand B;
end compuerta;
Ilustración 1, 2.
Ilustración 1. Ilustración 2.
Ilustración 5.
14
16
Library ieee;
use ieee.std_logic_1164.all;
entity compuerta_nor is
port(
A: in std_logic;
B: in std_logic;
C: out std_logic
);
end compuerta_nor;
Architecture
begin
X<= A nand B;
end compuerta;
Ilustración 1, 2.
15
17
Ilustración 1.
AB AB AB AB
00 01 11 10
CD 1 1 1 1 0
00
CD 1 1 X X
01 A C
CD X X X X
11
CD X X X X
10
Ilustración 1.
Library ieee;
use ieee.std_logic_1164.all;
entity mapa_4variables is
port(
A: in std_logic;
B: in std_logic;
C: in std_logic;
D: in std_logic;
W: out std_logic
);
end mapa_4variables;
Architecture
begin
W<= A and C
end mapa_4variables;
16
18
AB AB AB AB
00 01 11 10
CD 1 1 1 1
00
CD 1 1 X X
01
CD X X X X
11
CD X X X X
10
Ilustración 2.
Ilustración 1, 2.
Ejemplo 1.
AB AB
00 01
CD 1 1
00
CD 1 1
01
Ilustración 3.
17
19
Módulo 16.
library IEEE;
use IEEE.std_logic_1164.all;
entity CON4_ASC_DES is
port(
U: in std_logic;
RST: in std_logic;
CLK: in std_logic;
S: out std_logic_vector(3 downto 0)// esto nos indica el
número de variables a utilizar es decir cuatro variables 0,1,2,3//
);
end CON4_ASC_DES;
architecture simple of CON4_ASC_DES is
signal Qp,Qn: std_logic_vector(3 downto 0);//Qn,Qp indican
estados internos en el sistema//
begin
Combinacional: Process(Qp,U)//indica cuales son las variables que se
van a procesas es decir el estado próximo y la entrada que se va ingresar//
begin
Case Qp is
18
20
Qn<="0000";
else
Qn<="0001";
end if;
when"0001"=>if(U='0') then
Qn<="0001";
else
Qn<="0010";
end if;
when"0010"=>if(U='0') then
Qn<="0010";
else
Qn<="0011";
end if;
when"0011"=>if(U='0') then
Qn<="0011";
else
Qn<="0100";
end if;
when"0100"=>if(U='0') then
Qn<="0100";
else
Qn<="0101";
end if;
when"0101"=>if(U='0') then
Qn<="0101";
19
21
else
Qn<="0110";
end if;
when"0110"=>if(U='0') then
Qn<="0110";
else
Qn<="0111";
end if;
when"0111"=>if(U='0') then
Qn<="0111";
else
Qn<="1000";
end if;
when"1000"=>if(U='0') then
Qn<="1000";
else
Qn<="1001";
end if;
when"1001"=>if(U='0') then
Qn<="1001";
else
Qn<="1010";
end if;
when"1010"=>if(U='0') then
Qn<="1010";
else
Qn<="1100";
20
22
end if;
when"1100"=>if(U='0') then
Qn<="1100";
else
Qn<="1101";
end if;
when"1101"=>if(U='0') then
Qn<="1101";
else
Qn<="1110";
end if;
when"1110"=>if(U='0') then
Qn<="1110";
else
Qn<="1111";
end if;
Qp<="0000";
21
23
end if;
end process Secuencial;
end simple;
Ilustración 1
Palabras desconocidas.
IF: Es una condición nos sirve para elegir entre dos opciones
posibles.
22
24
Ejemplo 2
Módulo 8
library IEEE;
use IEEE.std_logic_1164.all;
entity CON8_ASC is
port(
U: in std_logic;
RST: in std_logic;
CLK: in std_logic;
);
end CON8_ASC;
begin
Combinacional: Process(Qp,U)
begin
Case Qp is
when"000"=>if(U='0') then
Qn<="000";
else
Qn<="001";
23
25
end if;
when"001"=>if(U='0') then
Qn<="001";
else
Qn<="010";
end if
when"010"=>if(U='0') then
Qn<="010";
else
Qn<="011";
end if;
when"011"=>if(U='0') then
Qn<="011";
else
Qn<="100";
end if;
when"100"=>if(U='0') then
Qn<="100";
else
Qn<="101";
end if;
when"101"=>if(U='0') then
Qn<="101";
else
Qn<="110";
24
26
end if;
when"110"=>if(U='0') then
Qn<="110";
else
Qn<="111";
end if;
Qn<="000";
end if;
end case;
S<=Qp;
Secuencial: process(RST,CLK)
begin
if(RST='0') then
Qp<="000";
Qp<=Qn;
end if;
end simple;
25
26
Ilustración 2
Ejemplo 3.
Módulo 6
library IEEE;
use IEEE.std_logic_1164.all;
entity CON8_ASC is
port(
U: in std_logic;
RST: in std_logic;
CLK: in std_logic;
);
end CON8_ASC;
begin
Combinacional: Process(Qp,U)
begin
Case Qp is
when"000"=>if(U='0') then
Qn<="000";
else
26
27
Qn<="001";
end if;
when"001"=>if(U='0') then
Qn<="001";
else
Qn<="010";
end if;
when"010"=>if(U='0') then
Qn<="010";
else
Qn<="011";
end if;
when"011"=>if(U='0') then
Qn<="011";
else
Qn<="100";
end if;
when"100"=>if(U='0') then
Qn<="100";
else
Qn< ="101";
end if;
when"101"=>if(U='0') then
Qn<="101";
else
27
28
Qn<="101";
end if;
Qn<="000";
end if;
end case;
S<=Qp;
Secuencial:process(RST,CLK)
begin
if(RST='0') then
Qp<="000";
Qp<=Qn;
end if;
end simple;
Ilustración 3
28
29
library IEEE;
use IEEE.std_logic_1164.all;
entity CON4_ASC_DES is
port(
U: in std_logic;
RST: in std_logic;
CLK: in std_logic;
);
end CON4_ASC_DES;
begin
Combinacional: Process(Qp,U)
begin
Case Qp is
when"0000"=>if(U='0') then
Qn<="0000";
else
Qn<="0001";
end if;
when"0001"=>if(U='0') then
Qn<="0001";
29
30
else
Qn<="0010";
end if;
when"0010"=>if(U='0') then
Qn<="0010";
else
Qn<="0011";
end if;
when"0011"=>if(U='0') then
Qn<="0011";
else
Qn<="0100";
end if;
when"0100"=>if(U='0') then
Qn<="0100";
else
Qn<="0101";
end if;
when"0101"=>if(U='0') then
Qn<="0101";
else
Qn<="0110";
end if;
when"0110"=>if(U='0') then
Qn<="0110";
30
31
else
Qn<="0111";
end if;
when"0111"=>if(U='0') then
Qn<="0111";
else
Qn<="1000";
end if;
when"1000"=>if(U='0') then
Qn<="1000";
else
Qn<="1001";
end if;
Qn<="1001";
case;
Qn<="0000";
Secuencial: process(RST,CLK)
begin
if(RST='0') then
Qp<="0000";
Qp<=Qn;
31
32
end if;
end simple;
Ilustración 4
32