Está en la página 1de 24

Integrantes:

Castañedo Hernández Juan Eduardo


Fajardo Aguirre José Ignacio
Terán León Fernando Rafael

Práctica 3

Unidad de aprendizaje: Dispositivos lógicos programables

Grupo: 2MM15

Profesor: Ing. Julio Cesar Suárez Tapia

Fecha de entrega: 13/09/2019


Problema 1
Para el diseño del sumador /restador de 3 bits, implementamos una serie de if/elsif para cada una
de las condiciones tanto del sumador como del restador, además de dos switches selectores para
que al usuario le fuese posible decidir si deseaba sumar o restar los dos dígitos de 3 bits introducidos.

En dichos condicionales, ya está implícito el complemento a dos para la suma, pues se incluyo un
vector de 4 bits para el resultado, que junto con el vector ACAR, hacen la función de dicho
complemento. Para la resta, lo que se utilizo fue una serie de condicionales para dicho complemento
a 2, pues a diferencia de la suma, este no fue posible incluirlo en los mismos condicionales.

A continuación, se muestra el código realizado en el VHDL Module:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

-- Uncomment the following library declaration if using


-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating


-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity Practica3_DLPS_A is

A : IN STD_LOGIC_VECTOR(2 downto 0);


B : IN STD_LOGIC_VECTOR(2 downto 0);
ACAR: OUT STD_LOGIC_VECTOR(2 downto 0);
RES : OUT STD_LOGIC_VECTOR(2 downto 0);
SUM : OUT STD_LOGIC_VECTOR(3 downto 0);
SEL : IN STD_LOGIC;
COM : OUT STD_LOGIC;
ANODOS : OUT STD_LOGIC_VECTOR(3 downto 0);
CATODOS : OUT STD_LOGIC_VECTOR(7 downto 0);

end Practica3_DLPS_A;

architecture Behavioral of Practica3_DLPS_A is


begin
process(A,B,S)
begin

if(SEL = '1') then


ACAR(0)<='0';
if(A(0)='0' and B(0)='0') THEN
SUM(0)<='0';
ACAR(1)<='0';
elsif ((A(0)='0' and B(0)='1') or (A(0)='1' and B(0)='1')) then
SUM(0)<='1';
ACAR(1)<='0';
elsif (A(0)='1' and B(0)='1') then
SUM(0)<='1';
ACAR(1)<='1';
end if;

if(A(1)='0' and B(1)='0' and ACAR(1)='0') THEN


SUM(1)<='0';
ACAR(2)<='0';
elsif (A(1)='0' and B(1)='0' and ACAR(1)='1') then
SUM(1)<='1';
ACAR(2)<='0';
elsif (((A(1)='1' and B(1)='0') OR (A(1)='0' and B(1)='1')) and ACAR(1)='0') then
SUM(1)<='1';
ACAR(2)<='0';
elsif (((A(1)='1' and B(1)='0') OR (A(1)='0' and B(1)='1')) and ACAR(1)='1') then
SUM(1)<='0';
ACAR(2)<='1';
elsif (A(1)='1' and B(1)='1' and ACAR(1)='0') then
SUM(1)<='0';
ACAR(2)<='1';
elsif (A(1)='1' and B(1)='1' and ACAR(1)='1') then
SUM(1)<='1';
ACAR(2)<='1';
end if;

if(A(2)='0' and B(2)='0' and ACAR(2)='0') THEN


SUM(2)<='0';
SUM(3)<='0';
elsif (A(2)='0' and B(2)='0' and ACAR(2)='1') then
SUM(2)<='1';
SUM(3)<='0';
elsif (((A(2)='1' and B(2)='0') OR (A(2)='0' and B(2)='1')) and ACAR(2)='0') then
SUM(1)<='1';
SUM(2)<='0';
elsif (((A(2)='1' and B(2)='0') OR (A(2)='0' and B(2)='1')) and ACAR(2)='1') then
SUM(2)<='0';
SUM(3)<='1';
elsif (A(2)='1' and B(2)='1' and ACAR(2)='0') then
SUM(2)<='0';
SUM(3)<='1';
elsif (A(2)='1' and B(2)='1' and ACAR(2)='1') then
SUM(2)<='1';
SUM(3)<='1';
end if;
elsif (SEL='0') then
if (A>B) then
if(A(0)='0' and B(0)='0') then
RES(0)<='0';
ACAR(1)<='0';
elsif(A(0)='1' and B(0)='0') then
RES(0)<='1';
ACAR(1)<='0';
elsif(A(0)='0' and B(0)='1') then
RES(0)<='1';
ACAR(1)<='1';
elsif(A(0)='1' and B(0)='1') then
RES(0)<='0';
ACAR(1)<='0';
end if;

if(A(1)='0' and B(1)='0' and ACAR(1)='0') THEN


RES(1)<='0';
ACAR(2)<='0';
elsif (A(1)='0' and B(1)='0' and ACAR(1)='1') then
RES(1)<='0';
ACAR(2)<='1';
elsif (A(1)='1' and B(1)='0' and ACAR(1)='0') then
RES(1)<='1';
ACAR(2)<='0';
elsif (A(1)='1' and B(1)='0' and ACAR(1)='1') then
RES(1)<='0';
ACAR(2)<='0';
elsif (A(1)='0' and B(1)='1' and ACAR(1)='0') then
RES(1)<='1';
ACAR(2)<='1';
elsif (A(1)='0' and B(1)='1' and ACAR(1)='1') then
RES(1)<='0';
ACAR(2)<='1';
elsif (A(1)='1' and B(1)='1' and ACAR(1)='0') then
RES(1)<='0';
ACAR(2)<='0';
elsif (A(1)='1' and B(1)='1' and ACAR(1)='1') then
RES(1)<='1';
ACAR(2)<='1';
end if;

if(A(2)='0' and B(2)='0' and ACAR(2)='0') THEN


RES(2)<='0';
elsif (A(2)='0' and B(2)='0' and ACAR(2)='1') then
RES(2)<='0';

elsif (A(2)='1' and B(2)='0' and ACAR(2)='0') then


RES(2)<='1';

elsif (A(2)='1' and B(2)='0' and ACAR(2)='1') then


RES(2)<='0';

elsif (A(2)='0' and B(2)='1' and ACAR(2)='0') then


RES(2)<='1';

elsif (A(2)='0' and B(2)='1' and ACAR(2)='1') then


RES(2)<='0';

elsif (A(2)='1' and B(2)='1' and ACAR(2)='0') then


RES(2)<='0';

end if;

elsif(A<B) then
-----------COMPLEMENTO A 2 PARA LA RESTA---------------------------------------
if A(0)='0' and A(1)='1' and A(2)='1' then
A(0)='0';
A(1)='1';
A(2)='0';
elsif A(0)='0' and A(1)='0' and A(2)='1' then
A(0)='0';
A(1)='0';
A(2)='1';
elsif A(0)='0' and A(1)='1' and A(2)='0' then
A(0)='0';
A(1)='1';
A(2)='1';
elsif A(0)='1' and A(1)='1' and A(2)='1' then
A(0)='1';
A(1)='0';
A(2)='0';
elsif A(0)='1' and A(1)='1' and A(2)='0' then
A(0)='1';
A(1)='0';
A(2)='1';
elsif A(0)='1' and A(1)='0' and A(2)='1' then
A(0)='1';
A(1)='1';
A(2)='0';
end if;
ACAR(0)<='0';
if(A(0)='0' and B(0)='0') THEN
SUM(0)<='0';
ACAR(1)<='0';
elsif ((A(0)='0' and B(0)='1') or (A(0)='1' and B(0)='1')) then
SUM(0)<='1';
ACAR(1)<='0';
elsif (A(0)='1' and B(0)='1') then
SUM(0)<='1';
ACAR(1)<='1';
end if;

if(A(1)='0' and B(1)='0' and ACAR(1)='0') THEN


SUM(1)<='0';
ACAR(2)<='0';
elsif (A(1)='0' and B(1)='0' and ACAR(1)='1') then
SUM(1)<='1';
ACAR(2)<='0';
elsif (((A(1)='1' and B(1)='0') OR (A(1)='0' and B(1)='1')) and ACAR(1)='0')
then
SUM(1)<='1';
ACAR(2)<='0';
elsif (((A(1)='1' and B(1)='0') OR (A(1)='0' and B(1)='1')) and ACAR(1)='1')
then
SUM(1)<='0';
ACAR(2)<='1';
elsif (A(1)='1' and B(1)='1' and ACAR(1)='0') then
SUM(1)<='0';
ACAR(2)<='1';
elsif (A(1)='1' and B(1)='1' and ACAR(1)='1') then
SUM(1)<='1';
ACAR(2)<='1';
end if;

if(A(2)='0' and B(2)='0' and ACAR(2)='0') THEN


SUM(2)<='0';
SUM(3)<='0';
elsif (A(2)='0' and B(2)='0' and ACAR(2)='1') then
SUM(2)<='1';
SUM(3)<='0';
elsif (((A(2)='1' and B(2)='0') OR (A(2)='0' and B(2)='1')) and ACAR(2)='0')
then
SUM(1)<='1';
SUM(2)<='0';
elsif (((A(2)='1' and B(2)='0') OR (A(2)='0' and B(2)='1')) and ACAR(2)='1')
then
SUM(2)<='0';
SUM(3)<='1';
elsif (A(2)='1' and B(2)='1' and ACAR(2)='0') then
SUM(2)<='0';
SUM(3)<='1';
elsif (A(2)='1' and B(2)='1' and ACAR(2)='1') then
SUM(2)<='1';
SUM(3)<='1';
end if;
end if;
end process;

begin
process (SUM) begin

if SUM="0000" then
ANODOS <= "1110";
CATODOS<=x"C0";
elsif SUM="0001" then
ANODOS <= "1110";
CATODOS<=x"F9";
elsif SUM="0010" then
ANODOS <= "1110";
CATODOS<=x"A4";
elsif SUM="0011" then
ANODOS <= "1110";
CATODOS<=x"B0";
elsif SUM="0100" then
ANODOS <= "1110";
CATODOS<=x"99";
elsif SUM="0101" then
ANODOS <= "1110";
CATODOS<=x"92";
elsif SUM="0110" then
ANODOS <= "1110";
CATODOS<=x"82";
elsif SUM="0111" then
ANODOS <= "1110";
CATODOS<=x"F8";
elsif SUM="1000" then
ANODOS <= "1110";
CATODOS<=x"80";
elsif SUM="1001" then
ANODOS <= "1110";
CATODOS<=x"98";
elsif SUM="1010" then
ANODOS <= "1110";
CATODOS<=x"88";
elsif SUM="1011" then
ANODOS <= "1110";
CATODOS<=x"83";
elsif SUM="1100" then
ANODOS <= "1110";
CATODOS<=x"C6";
elsif SUM="1101" then
ANODOS <= "1110";
CATODOS<=x"A1";
elsif SUM="1110" then
ANODOS <= "1110";
CATODOS<=x"86";
elsif SUM"1111" then
ANODOS <= "1110";
CATODOS<=x"8E";
end if;

if RES="000" then
ANODOS <= "1101";
CATODOS<=x"C0";
elsif SUM="001" then
ANODOS <= "1101";
CATODOS<=x"F9";
elsif SUM="010" then
ANODOS <= "1101";
CATODOS<=x"A4";
elsif SUM="011" then
ANODOS <= "1101";
CATODOS<=x"B0";
elsif SUM="100" then
ANODOS <= "1101";
CATODOS<=x"99";
elsif SUM="101" then
ANODOS <= "1101";
CATODOS<=x"92";
elsif SUM="110" then
ANODOS <= "1101";
CATODOS<=x"82";
elsif SUM="111" then
ANODOS <= "1101";
CATODOS<=x"F8";

end if;
end process;
end Behavioral;
Y para nuestro Código de implementación, tenemos las siguientes líneas:

net "CATODOS(0)" loc = C17;


net "CATODOS(1)" loc = H14;
net "CATODOS(2)" loc = J17;
net "CATODOS(3)" loc = G14;
net "CATODOS(4)" loc = D16;
net "CATODOS(5)" loc = D17;
net "CATODOS(6)" loc = F18;
net "CATODOS(7)" loc = L18;

net "SEL" loc =T10;

net "A(0)" loc =T10;


net "A(1)" loc =V9;
net "A(2)" loc =H9;

net "B(0)" loc =N9;


net "B(1)" loc =U8;
net "B(2)" loc =V8;

net "ANODOS(0)" loc =F17;


net "ANODOS(1)" loc =H17;
net "ANODOS(2)" loc =C18;
net "ANODOS(3)" loc =F15;

Problema 2
Para realizar el contador de 0 a 99, fue necesaria la implementación de dos módulos, un contador y
un decodificador, como se muestra en la figura1.

Figura 1 Diagrama de bloques de contador

Con dos botones, un inicio/ pausa y un reset, estos tendrán efecto directo sobre el avance o reinicio
del contador, pues, este se detendrá o iniciará al presionar el botón de inicio y sin importar en que
punto de la cuenta se encuentre, este se detendrá. En el caso del reset, este de igual forma tendrá
efecto sin importar el punto en el que se encuentre el contador.
Posteriormente, la señal ira a un decodificador con barrido de 20hz, el cual prendera, el display 1 o
el display 2, esto, haciendo uso de un divisor de frecuencia, el cual dará pie a encender uno a la vez,
ya que comparten cátodos.
Como recomendación, se debe poner un especial cuidado en el barrido necesario para prender los
display, ya que, de no hacerlo correctamente, no prendera alguno de los dos o en el peor de los casos,
ninguno se encenderá.
A continuación, se anexa el código correspondiente:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity CONTA_0_99 is

PORT( CLK : IN STD_LOGIC; -- RELOJ DE FPGA


100MHZ
INI : IN STD_LOGIC; -
- BIT DE INICIO
RESET : IN STD_LOGIC;
-- BIT DE RESET
DISPLAY : OUT STD_LOGIC_VECTOR(6 DOWNTO 0); -- VECTOR DE 7
BITS QUE CONTROLARÁ LOS DISPLAYS
TRANSISTOR : OUT STD_LOGIC_VECTOR(7 DOWNTO 0) -- VECTOR
DEE 2 BITS QUE CONTROLARÁ EL SWITCHEO DE

-- LOS TRANSISTORES
);

end CONTA_0_99;

architecture Behavioral of CONTA_0_99 is

TYPE MAQUINA IS (UNIDADES,DECENAS); --DECLARACIÓN DE


SIGNAL EDO_P,EDO_F : MAQUINA := UNIDADES; --LA MÁQUINA DE ESTADOS
-- 10_000_000?
CONSTANT CONTA_RETRASO_FIN : INTEGER := 10_000_000;
--CONSTANTE QUE TIENE EL VALOR
PARA UN RETRASO DE 10mS

--QUE SE UTILIZARÁ PARA EL SWITCHEO DE LOS


TRANSISTORES
CONSTANT CONTA_SW_FIN : INTEGER := 200_000;

SIGNAL CONTA_UNIDADES,CONTA_DECENAS : INTEGER RANGE 0 TO 9 := 0;


--CONTADORES DE 0-9 PARA UNIDADES Y DECENAS
SIGNAL CONTA_RETRASO : INTEGER RANGE 0
TO CONTA_RETRASO_FIN := 0; --CONTADOR PARA EL RETRASO DE 10 mS

--E INCREMENTARÁ EL CONTADOR PRINCIPAL


SIGNAL CONTADOR_PRINCIPAL : INTEGER RANGE 0 TO 9 := 0;
--CONTADOR PRINCIPAL QUE
SIGNAL CONTA_SWITCH : INTEGER RANGE 0 TO
CONTA_SW_FIN :=0;

begin
------------PROCESO QUE SE ENCARGA DEL CONTEO---------------------
PROCESS(CLK)
BEGIN
IF RISING_EDGE(CLK) THEN
IF RESET = '1' THEN --CONDICIÓN PARA REINICIAR EL CONTEO
CUANDO RESET = '1'
CONTA_UNIDADES <= 0;
CONTA_DECENAS <= 0;
ELSE
IF INI = '1' THEN --CONDICIÓN PARA QUE INICIE EL CONTEO,
CUANDO INI = '1'
CONTA_RETRASO <= CONTA_RETRASO +1;
IF CONTA_RETRASO = CONTA_RETRASO_FIN THEN
CONTA_RETRASO <= 0;
CONTA_UNIDADES <= CONTA_UNIDADES+1;
IF CONTA_UNIDADES = 9 THEN--------------
CUANDO EL CONTEO DE LAS UNIDADES LLEGE A 9
CONTA_UNIDADES <= 0;---------------
--REINICIA EL CONTADOR DE LAS UNIDADES
CONTA_DECENAS <=
CONTA_DECENAS +1;---E INCREMENTA EN 1 LAS DECENAS
IF CONTA_DECENAS = 9
THEN
CONTA_DECENAS <=
0;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END PROCESS;
--------------------------------------------------------------------

---MAQUINA DE ESTADOS QUE SE ENCARGA DEL SWITCHEO DE LOS


TRANSISTORES-------
-------PARA ACTIVAR Y DESACTIVAR LOS DISPLAY CADA 10 MS---------------------
PROCESS(EDO_P)
BEGIN
CASE EDO_P IS
WHEN UNIDADES =>
EDO_F <= DECENAS;
TRANSISTOR <= "11111110"; --ACTIVAMOS EL DISPLAY DE LAS
UNIDADES
WHEN DECENAS =>
EDO_F <= UNIDADES; --ACTIVAMOS EL DISPLAY DE LAS
DECENAS
TRANSISTOR <= "11111101";
WHEN OTHERS => NULL;
END CASE;
END PROCESS;

--CONTEO PARA UN RETRASO DE 10ms


PROCESS(CLK)
BEGIN
IF RISING_EDGE(CLK) THEN
CONTA_SWITCH <= CONTA_SWITCH +1;
IF CONTA_SWITCH = CONTA_SW_FIN THEN
CONTA_SWITCH <= 0;
EDO_P <= EDO_F;
END IF;
END IF;
END PROCESS;

CONTADOR_PRINCIPAL <= CONTA_UNIDADES WHEN EDO_P = UNIDADES ELSE--


MANDAMOS EL VALOR DE LAS UNIDADES CUANDO EDO_P ESTE EN UNIDADES
CONTA_DECENAS;
--MANDAMOS EL VALOR DE LAS
DECENAS CUANDO EDO_P ESTE EN DECENAS
-----------------------------------------------------------------------------

----CODIFICADOR---

--VECTOR DE SALIDA CONECTADO A LOS DISPLAY DE CÁTODO COMÚN


--EN CASO DE USAR DISPLAYs DE ÁNODO COMÚN SE TIENE QUE NEGAR EL
VECTOR
--POR EJEMPLO: NOT "1111110"

--ABCDEFG
DISPLAY <= "0000001" WHEN CONTADOR_PRINCIPAL = 0 ELSE --0
"1001111" WHEN CONTADOR_PRINCIPAL = 1 ELSE --1
"0010010" WHEN CONTADOR_PRINCIPAL = 2 ELSE --2
"0000110" WHEN CONTADOR_PRINCIPAL = 3 ELSE --3
"1001100" WHEN CONTADOR_PRINCIPAL = 4 ELSE --4
"0100100" WHEN CONTADOR_PRINCIPAL = 5 ELSE --5
"0100000" WHEN CONTADOR_PRINCIPAL = 6 ELSE --6
"0001111" WHEN CONTADOR_PRINCIPAL = 7 ELSE --7
"0000000" WHEN CONTADOR_PRINCIPAL = 8 ELSE --8
"0000100";

end Behavioral;
Problema 3
Para la resolución de este problema, nuestra propuesta primeramente fue diseñar los 5 divisores de
frecuencia, los cuatro primeros controlarían los 4 contadores, y el quinto el selector para el
multiplexor 2 a 4, el cuál controlaría la secuencia de activación de cada uno de los displays. Para los
contadores, lo único que hicimos fue implementar los condicionales para que estos siguiesen la
secuencia automáticamente del 0al 15 en hexadecimal.

A continuación, se muestra el código implementado en VHDL

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

-- Uncomment the following library declaration if using


-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating


-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity practica3_dlp_C is
Port (
clk1: in std_logic;
rst1: in std_logic;
eout1: out std_logic;
clk2: in std_logic;
rst2: in std_logic;
eout2: out std_logic;
clk3: in std_logic;
rst3: in std_logic;
eout3: out std_logic;
clk4: in std_logic;
rst4: in std_logic;
eout4: out std_logic;
clk5: in std_logic;
rst5: in std_logic;
eout5: out std_logic;
cont1 : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
cont2 : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
cont3 : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
cont4 : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
CATODO : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
ANODO : OUT STD_LOGIC_VECTOR(3 DOWNTO 0)
reset1: in std_logic;
salida_contador1 :out std_logic_vector(3 downto 0);
reset2: in std_logic;
salida_contador2 :out std_logic_vector(3 downto 0);
reset3: in std_logic;
salida_contador3 :out std_logic_vector(3 downto 0);
reset4: in std_logic;
salida_contador4 :out std_logic_vector(3 downto 0);
reset5: in std_logic;
salida_contador5 :out std_logic_vector(2 downto 0);
sel : in std_logic_vector (1 downto 0);
salida_dip: out std_logic_vector(7 downto 0);

);
end practica3_dlp_C;

architecture Behavioral of practica3_dlp_C is


signal cd1:integer range 0 to 333332;
signal cs1: std_logic;
signal cd2:integer range 0 to 3333332;
signal cs2: std_logic;
signal cd3:integer range 0 to 249999;
signal cs3: std_logic;
signal cd4:integer range 0 to 999999;
signal cs4: std_logic;
signal cd5:integer range 0 to 62499;
signal cs5: std_logic;
signal contador1: std_logic_vector(3 downto 0);
signal contador2: std_logic_vector(3 downto 0);
signal contador3: std_logic_vector(3 downto 0);
signal contador4: std_logic_vector(3 downto 0);
signal contador5: std_logic_vector(2 downto 0);
signal sal_multiplexor: std_logic_vector(3 downto 0);
--Divisor de frecuencia 1------------------------------------------

begin
div_150Hz: process(rst1,clk1)
begin
if (rst1='1' ) then
--
cs1<='0';
cd1<=0;
elsif rising_edge(clk1) then
if (cd1<=333332) then
cs1<=not cs1;
cd1<=0;
else
cd1<=cd1+1;
end if;
end if;

end process div_150Hz;


eout1 <= cd1;
--Divisor de frecuencia 2------------------------------------------

begin
div_1.5Hz: process(rst2,clk2)
begin
if (rst2='1' ) then
--
cs2<='0';
cd2<=0;
elsif rising_edge(clk2) then
if (cd2<=3333332) then
cs2<=not cs2;
cd2<=0;
else
cd2<=cd2+1;
end if;
end if;

end process div_1.5Hz;


eout2 <= cd2;

--Divisor de frecuencia 3------------------------------------------

begin
div_200Hz: process(rst3,clk3)
begin
if (rst3='1' ) then
--
cs3<='0';
cd3<=0;
elsif rising_edge(clk3) then
if (cd3<=249999) then
cs3<=not cs3;
cd3<=0;
else
cd3<=cd3+1;
end if;
end if;

end process div_200Hz;


eout3 <= cd3;

--Divisor de frecuencia 4------------------------------------------

begin
div_50Hz: process(rst4,clk4)
begin
if (rst4='1' ) then
--
cs4<='0';
cd4<=0;
elsif rising_edge(clk4) then
if (cd4<=999999) then
cs4<=not cs4;
cd4<=0;
else
cd4<=cd4+1;
end if;
end if;

end process div_50Hz;


eout4 <= cd4;

--Divisor de frecuencia 5------------------------------------------

begin
div_800Hz: process(rst5,clk5)
begin
if (rst5='1' ) then
--
cs5<='0';
cd5<=0;
elsif rising_edge(clk5) then
if (cd5<=62499) then
cs5<=not cs5;
cd5<=0;
else
cd5<=cd5+1;
end if;
end if;

end process div_800Hz;


eout5 <= cd5;
begin
process(eout1,reset1,contador1)

--Contador1------------------------------------------
begin
if reset1='1' then
contador1<="0000";
elsif rising_edge(eout1) then
contador1<=contador1+'1';
end if;
end process;
salida_contador1<=contador1;
--Contador2------------------------------------------
begin
process(eout2,reset2,contador2)
begin
if reset2='1' then
contador2<="0000";
elsif rising_edge(eout2) then
contador2<=contador2+'1';
end if;
end process;
salida_contador2<=contador2;

--Contador3------------------------------------------
begin
process(eout3,reset3,contador3)
begin
if reset3='1' then
contador3<="0000";
elsif rising_edge(eout3) then
contador3<=contador3+'1';
end if;
end process;
salida_contador3<=contador3;

--Contador4------------------------------------------
begin
process(eout4,reset4,contador4)
begin
if reset4='1' then
contador4<="0000";
elsif rising_edge(eout4) then
contador4<=contador4+'1';
end if;
end process;
salida_contador4<=contador4;

--Contador5------------------------------------------
begin
process(eout5,reset5,contador5)
begin
if reset5='1' then
contador5<="000";
elsif rising_edge(eout5) then
contador5<=contador5+'1';
end if;
end process;
salida_contador5<=contador5;

--Multiplexor 4 a 1------------------------------------------
begin
process(contador5,sel)
begin
if contador5="000" then
sel<="00";
elsif contador5="001" then
sel<="01";
elsif contador5="011" then
sel<="10";
elsif contador5="111" then
sel<="11";
end if;
end process;

begin
process(contador1,contador2,contador3,contador4,sel)
begin
if sel="00" then
sal_multiplexor<=contador1;
elsif sel="01" then
sal_multiplexor<=contador2;
elsif sel="10" then
sal_multiplexor<=contador3;
elsif sel="11" then
sal_multiplexor<=contador4;
end if;
end process;

--Decodificador a disp. 7 seg.------------------------------------------

begin
process(sal_multiplexor,sel)
begin
if sel="00" then
ANODO <= "1110";
if sal_multiplexor="0000" then
salida_disp<=x"C0";
elsif sal_multiplexor="0001" then
salida_disp<=x"F9";
elsif sal_multiplexor="0010" then
salida_disp<=x"A4";
elsif sal_multiplexor="0011" then
salida_disp<=x"B0";
elsif sal_multiplexor="0100" then
salida_disp<=x"99";
elsif sal_multiplexor="0101" then
salida_disp<=x"92";
elsif sal_multiplexor="0110" then
salida_disp<=x"82";
elsif sal_multiplexor="0111" then
salida_disp<=x"F8";
elsif sal_multiplexor="1000" then
salida_disp<=x"80";
elsif sal_multiplexor="1001" then
salida_disp<=x"98";
elsif sal_multiplexor="1010" then
salida_disp<=x"88";
elsif sal_multiplexor="1011" then
salida_disp<=x"83";
elsif sal_multiplexor="1100" then
salida_disp<=x"C6";
elsif sal_multiplexor="1101" then
salida_disp<=x"A1";
elsif sal_multiplexor="1110" then
salida_disp<=x"86";
elsif sal_multiplexor="1111" then
salida_disp<=x"8E";
end if;

elsif sel="01" then


ANODO <= "1101";
if sal_multiplexor="0000" then
salida_disp<=x"C0";
elsif sal_multiplexor="0001" then
salida_disp<=x"F9";
elsif sal_multiplexor="0010" then
salida_disp<=x"A4";
elsif sal_multiplexor="0011" then
salida_disp<=x"B0";
elsif sal_multiplexor="0100" then
salida_disp<=x"99";
elsif sal_multiplexor="0101" then
salida_disp<=x"92";
elsif sal_multiplexor="0110" then
salida_disp<=x"82";
elsif sal_multiplexor="0111" then
salida_disp<=x"F8";
elsif sal_multiplexor="1000" then
salida_disp<=x"80";
elsif sal_multiplexor="1001" then
salida_disp<=x"98";
elsif sal_multiplexor="1010" then
salida_disp<=x"88";
elsif sal_multiplexor="1011" then
salida_disp<=x"83";
elsif sal_multiplexor="1100" then
salida_disp<=x"C6";
elsif sal_multiplexor="1101" then
salida_disp<=x"A1";
elsif sal_multiplexor="1110" then
salida_disp<=x"86";
elsif sal_multiplexor="1111" then
salida_disp<=x"8E";
end if;

elsif sel="10" then


ANODO <= "1011";
if sal_multiplexor="0000" then
salida_disp<=x"C0";
elsif sal_multiplexor="0001" then
salida_disp<=x"F9";
elsif sal_multiplexor="0010" then
salida_disp<=x"A4";
elsif sal_multiplexor="0011" then
salida_disp<=x"B0";
elsif sal_multiplexor="0100" then
salida_disp<=x"99";
elsif sal_multiplexor="0101" then
salida_disp<=x"92";
elsif sal_multiplexor="0110" then
salida_disp<=x"82";
elsif sal_multiplexor="0111" then
salida_disp<=x"F8";
elsif sal_multiplexor="1000" then
salida_disp<=x"80";
elsif sal_multiplexor="1001" then
salida_disp<=x"98";
elsif sal_multiplexor="1010" then
salida_disp<=x"88";
elsif sal_multiplexor="1011" then
salida_disp<=x"83";
elsif sal_multiplexor="1100" then
salida_disp<=x"C6";
elsif sal_multiplexor="1101" then
salida_disp<=x"A1";
elsif sal_multiplexor="1110" then
salida_disp<=x"86";
elsif sal_multiplexor="1111" then
salida_disp<=x"8E";
end if;

elsif sel="11" then


ANODO <= "0111";
if sal_multiplexor="0000" then
salida_disp<=x"C0";
elsif sal_multiplexor="0001" then
salida_disp<=x"F9";
elsif sal_multiplexor="0010" then
salida_disp<=x"A4";
elsif sal_multiplexor="0011" then
salida_disp<=x"B0";
elsif sal_multiplexor="0100" then
salida_disp<=x"99";
elsif sal_multiplexor="0101" then
salida_disp<=x"92";
elsif sal_multiplexor="0110" then
salida_disp<=x"82";
elsif sal_multiplexor="0111" then
salida_disp<=x"F8";
elsif sal_multiplexor="1000" then
salida_disp<=x"80";
elsif sal_multiplexor="1001" then
salida_disp<=x"98";
elsif sal_multiplexor="1010" then
salida_disp<=x"88";
elsif sal_multiplexor="1011" then
salida_disp<=x"83";
elsif sal_multiplexor="1100" then
salida_disp<=x"C6";
elsif sal_multiplexor="1101" then
salida_disp<=x"A1";
elsif sal_multiplexor="1110" then
salida_disp<=x"86";
elsif sal_multiplexor="1111" then
salida_disp<=x"8E";
end if;
end Behavioral;

Ahora se muestra el código de implementación del programa

net "clk1" loc = B8;


net "clk2" loc = B8;
net "clk3" loc = B8;
net "clk4" loc = B8;
net "clk5" loc = B8;

net "salida_disp(0)" loc = C17;


net "salida_disp(1)" loc = H14;
net "salida_disp(2)" loc = J17;
net "salida_disp(3)" loc = G14;
net "salida_disp(4)" loc = D16;
net "salida_disp(5)" loc = D17;
net "salida_disp(6)" loc = F18;
net "salida_disp(7)" loc = L18;

net "ANODO(0)" loc =F17;


net "ANODO(1)" loc =H17;
net "ANODO(2)" loc =C18;
net "ANODO(3)" loc =F15;

Figura 1 Acción de los cuatro contadores con sus respectivas frecuencias


Conclusiones:
Fajardo Aguirre José Ignacio:
Para el desarrollo de la practica 3, fue necesaria la implementación de estados, ya que, estos nos
permiten tener un control más efectivo con respecto a los procesos que se van llevando acabo para la
resolución de los mismos, en especial en el uso de la sincronización de displays, para su uso
combinado, pues estos requieren de una secuencia para poder encender uno a uno.
Castañedo Hernández Juan Eduardo:
Durante el desarrollo de la práctica, reforcé mi conocimiento sobre contadores, y manejo de
divisores de frecuencia, ya que conforme se avanza en el curso, veo más necesaria la utilización de
los mismos, así como el uso de sistemas secuenciales, ya sea por contadores o por estados.
Terán León Fernando Rafael:
Con el desarrollo de esta práctica, nos fue posible aplicar conceptos visto anteriormente en circuitos
lógicos como lo son el divisor de frecuencia, así como los contadores y los sumadores / restadores,
sin embrago, en esta ocasión los aplicamos de tal manera que tuviésemos una aplicación para un
sistema más elaborado, como bien lo podemos ver en los 4 contadores a diferentes frecuencias, o en
el teclado matricial.

También podría gustarte