Vous êtes sur la page 1sur 17

Escuela Politécnica Nacional

Carrera: Ing. Electrónica Materia: Lab. De Sistemas Digitales


Nombre: Gabriel Guerra, Gabriel Santos Fecha: 20/06/2018
Tema: Preparatorio 8

1. TEMA
FLIP-FLOPS (MULTIVIBRADORES BIESTABLES)
2. OBJETIVOS
2.1. Afianzar los conocimientos en diseño de circuitos secuenciales usando flip-flops.
2.2. Creación de flip-flops mediante VHDL.
3. TRABAJO PREPARATORIO
3.1. Consultar la distribución de pines y la tabla de funcionamiento de los Circuitos
integrados: 7476, 74107, 74109, 74112.
7476:

Flip Flop Dual con preset y clear.

Esta compuerta contiene 2 flip flop de tipo J-K independientes cada uno con J-K, reloj, preset y
borrado individuales. El Integrado cuenta con 16 Pines distribuidos de la siguiente manera:

Su tabla de funcionamiento es la siguiente:


74107:

Flip Flop Dual con clear.

Esta compuerta contiene 2 flip flop de tipo J-K independientes cada uno con J-K, reloj, y
borrado individuales. Este circuito no cuenta con el pin de preset. El Integrado cuenta con 14
Pines distribuidos de la siguiente manera:

Su tabla de funcionamiento es la siguiente:

74109:

Flip Flop Dual con disparo por flanco positivo con preset y clear.

Al igual que los anteriores contiene 2 flip-flops de tipo J-K con flanco positivo.
A nivel bajo en el preset o clear, se definen o borran las salidas sin importar el nivel de las otras
entradas. Tiene 16 Pines distribuidos de la siguiente manera:

Su tabla de funcionamiento es:


74112:

Flip Flop Dual con preset y clear. (CMOS)

Es un integrado que contiene dos flips flops de tipo J-K con la opción de borrado y preset.
Funciona a altas velocidades y bajo consumo de potencia con tecnología CMOS. Tiene alta
inmunidad al ruido, impedancias de salidas simétricas, retrasos balanceados, gran rango de
voltaje. El integrado tiene 16 pines distribuidos de la siguiente manera:

Su tabla de funcionamiento es la
siguiente:

3.2. Diseñar, utilizando solamente compuertas NOR, un flip – flop S – R síncrono


activado con señal de reloj CLK en estado alto y que tenga PRESET y CLEAR.
Las funciones de preset y clear cumplen la siguiente función:
PR CLR Q
0 0 ?
0 1 0
1 0 1
1 1 Q
Cuando ambas entradas de preset y clear valen 1 el flip flop opera normalmente.
Entonces para el diseño se pueden incluir dichas entradas como se muestra en el circuito
a continuación.

Figura 1. FlipFlop con preset y clear.

3.3. Con el circuito integrado 7476, o algún equivalente, diseñar un flip – flop tipo D y
tipo T.
El integrado 7476 es un flip flop de tipo JK que posee la siguiente tabla de función:
J K Q
0 0 Qn
0 1 0
1 0 1
1 1 Qn’

Para el flip flop tipo D se cumple que:


D Q
0 0
1 1
Como se observa, corresponde a los casos en los que J y K son complementarias entre
sí. Entonces con el flip flop J-K se puede hacer la siguiente configuración:

Flip-Flop Tipo D
En el flip flop tipo T, en cambio:
T Q
0 Q
1 Q’
En este caso corresponde a los estados en los que J y K son iguales. Entonces:
Flip-Flop Tipo T

3.4. Con el circuito integrado 7476, o algún equivalente, en configuración de flip – flop
tipo J - K, diseñar un contador asincrónico ascendente según la siguiente tabla. Incluya
el circuito de borrado manual además presentarlo en display. Módulo 25
3.5. Elaborar código en VHDL que permita implementar un flip–flop S–R sincrónico.
Código en VHDL (arquitectura funcional)
library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity FFSRS2 is
port
(
S, R, CLK: IN STD_LOGIC;
Q: OUT STD_LOGIC;
Qc: OUT STD_LOGIC
);
end FFSRS2;

architecture funcional of FFSRS2 is


begin
process (S, R, CLK)
begin
if (CLK = '0' and S = '-' and R = '-') then
null;
elsif (CLK = '1' and S = '0' and R = '0') then
null;
elsif (CLK = '1' and S = '0' and R = '1') then
Q <= '0'; Qc <= '1';
elsif (CLK = '1' and S = '1' and R = '0') then
Q <= '1'; Qc <= '0';
elsif (CLK = '1' and S = '1' and R = '1') then
Q <= 'X'; Qc <= 'X';
else
null;
end if;
end process;
end funcional;

Test Bench:
library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity FFSRS2_tb is
end FFSRS2_tb;

architecture prueba of FFSRS2_tb is


component FFSRS2
port
(
S, R, CLK: IN STD_LOGIC;
Q: OUT STD_LOGIC;
Qc: OUT STD_LOGIC
);
end component;

signal S, R, Q, Qc : STD_LOGIC;
signal clk: STD_LOGIC:= '1';
constant num_ciclos: INTEGER:= 1;

begin
process
begin
for i in 1 to num_ciclos loop
clk <= not clk;
wait for 1 ns;
clk <= not clk;
wait for 4 ns;
end loop;
wait;
end process;

flipflop: FFSRS2
port map
(
S => S,
R => R,
CLK => clk,
Q => Q,
Qc => Qc
);

process
begin

S <= '0';
R <= '0';
wait for 1 ns;

S <= '0';
R <= '0';
wait for 1 ns;

S <= '0';
R <= '1';
wait for 1 ns;

S <= '1';
R <= '0';
wait for 1 ns;

S <= '1';
R <= '1';
wait for 1 ns;

assert false report "Fin de la prueba";


wait;
end process;
end prueba;

Resultado en GTKWave:

Figura 5. Prueba del FlipFlop S-R sincrónico

3.6. Elaborar código en VHDL que permita implementar un flip–flop JK con PRESET
y CLEAR.
Código en VHDL:
library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity FFJK is
port
(
J, K, CLK, PR, CLR: IN STD_LOGIC;
Q: INOUT STD_LOGIC;
Qc: INOUT STD_LOGIC
);
end FFJK;

architecture funcional of FFJK is


begin
process (J, K, CLK, PR, CLR)
begin
if (PR = '1' and CLR = '1') then
Q <= 'X'; Qc <= 'X';
elsif (PR = '0' and CLR = '1') then
Q <= '0'; Qc <= '1';
elsif (PR = '1' and CLR = '0') then
Q <= '1'; Qc <= '0';
elsif (PR = '0' and CLR = '0' and CLK = '0' and J = '-' and K = '-') then
null;
elsif (PR = '0' and CLR = '0' and CLK = '1' and J = '0' and K = '0') then
null;
elsif (PR = '0' and CLR = '0' and CLK = '1' and J = '0' and K = '1') then
Q <= '0'; Qc <= '1';
elsif (PR = '0' and CLR = '0' and CLK = '1' and J = '1' and K = '0') then
Q <= '1'; Qc <= '0';
elsif (PR = '0' and CLR = '0' and CLK = '1' and J = '1' and K = '1') then
Q <= not Q; Qc <= Q;
end if;
end process;
end funcional;

Test Bench:
library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity FFJK_tb is

end FFJK_tb;

architecture prueba of FFJK_tb is


component FFJK
port
(
J, K, CLK, PR, CLR: IN STD_LOGIC;
Q: INOUT STD_LOGIC;
Qc: INOUT STD_LOGIC
);
end component;

signal J, K, PR, CLR, Q, Qc: STD_LOGIC;


signal clk: STD_LOGIC:= '0';
constant num_ciclos: INTEGER:= 8;

begin
process
begin
for i in 1 to num_ciclos loop
clk <= not clk;
wait for 0.5 ns;
clk <= not clk;
wait for 0.5 ns;
end loop;
wait;
end process;

flipflop: FFJK
port map
(
J => J,
K => K,
PR => PR,
CLR => CLR,
CLK => clk,
Q => Q,
Qc => Qc
);

process
begin

PR <= '0';
CLR <= '0';
J <= '0';
K <= '0';
wait for 1 ns;

PR <= '0';
CLR <= '0';
J <= '0';
K <= '1';
wait for 1 ns;
PR <= '0';
CLR <= '0';
J <= '1';
K <= '0';
wait for 1 ns;

PR <= '0';
CLR <= '0';
J <= '1';
K <= '1';
wait for 1 ns;

PR <= '1';
CLR <= '0';
J <= '1';
K <= '1';
wait for 1 ns;

PR <= '0';
CLR <= '1';
J <= '0';
K <= '0';
wait for 1 ns;

PR <= '1';
CLR <= '1';
J <= '1';
K <= '1';
wait for 1 ns;

PR <= '0';
CLR <= '1';
J <= '-';
K <= '-';
wait for 1 ns;
assert false report "Fin de la prueba";
wait;
end process;
end prueba;

Prueba en GTKWave

Figura 6. Prueba del FlipFlop J-K. Cuando preset y clear son 1 se obtiene una señal indeterminada X.

3.7. Elaborar código en VHDL que permita implementar un flip-flop tipo D y T.


A partir del FlipFlop tipo JK mostrado anteriormente:
Código para el FF tipo D:
library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity FFD is
port
(
D, CLK, PR, CLR: IN STD_LOGIC;
Q: INOUT STD_LOGIC;
Qc: INOUT STD_LOGIC
);
end FFD;

architecture estructural of FFD is


component FFJK
port (
J, K, CLK, PR, CLR: IN STD_LOGIC;
Q: INOUT STD_LOGIC;
Qc: INOUT STD_LOGIC
);
end component;
signal Dc: STD_LOGIC;

begin
Dc <= not D;

flipflopd: FFJK
port map (
J => D,
K => Dc,
CLK => CLK,
PR => PR,
CLR => CLR,
Q => Q,
Qc => Qc
);
end estructural;

Código para el FF tipo T:


library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity FFT is
port
(
T, CLK, PR, CLR: IN STD_LOGIC;
Q: INOUT STD_LOGIC;
Qc: INOUT STD_LOGIC
);
end FFT;

architecture estructural of FFT is


component FFJK
port (
J, K, CLK, PR, CLR: IN STD_LOGIC;
Q: INOUT STD_LOGIC;
Qc: INOUT STD_LOGIC
);
end component;

begin

flipflopd: FFJK
port map (
J => T,
K => T,
CLK => CLK,
PR => PR,
CLR => CLR,
Q => Q,
Qc => Qc
);
end estructural;

Test Bench para ambos FlipFlops:


Para los FFs tipo D y T se asignaron las salidas Q1 y Q2 respectivamente.
library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity FFDyT_tb is

end FFDyT_tb;

architecture prueba of FFDyT_tb is


component FFD
port(
D, CLK, PR, CLR: IN STD_LOGIC;
Q: INOUT STD_LOGIC;
Qc: INOUT STD_LOGIC
);
end component;

component FFT
port(
T, CLK, PR, CLR: IN STD_LOGIC;
Q: INOUT STD_LOGIC;
Qc: INOUT STD_LOGIC
);
end component;

signal T, D, PR, CLR, Q1, Qc1, Qc2, Q2: STD_LOGIC;


signal clk: STD_LOGIC:= '0';
constant num_ciclos: INTEGER:= 4;

begin
process
begin
for i in 1 to num_ciclos loop
clk <= not clk;
wait for 0.5 ns;
clk <= not clk;
wait for 0.5 ns;
end loop;
wait;
end process;

flipflop1: FFD
port map
(
D => D,
PR => PR,
CLR => CLR,
CLK => clk,
Q => Q1,
Qc => Qc1
);
flipflop2: FFT
port map
(
T => T,
PR => PR,
CLR => CLR,
CLK => clk,
Q => Q2,
Qc => Qc2
);

process
begin

PR <= '0';
CLR <= '1';

D <= '0';
T <= '0';
wait for 1 ns;

PR <= '0';
CLR <= '0';

D <= '0';
T <= '0';
wait for 1 ns;

D <= '1';
T <= '1';
wait for 1 ns;
assert false report "Fin de la prueba";
wait;
end process;
end prueba;

Resultados en GTKWave:

Figura 7. Prueba de los FlipFlops D y T.

3.8. Realizar el código VHDL necesario para implementar un contador ascendente del
módulo indicado en la siguiente tabla. Módulo 513
Código en VHDL:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;

entity contadorascendente is
port
(
CLK: IN STD_LOGIC;
NUM: OUT UNSIGNED(6 downto 0)
);
end contadorascendente;

architecture funcional of contadorascendente is


constant max: unsigned (6 downto 0):= "1111100";
signal aux: unsigned (6 downto 0):="0000000";
begin
process (CLK)
begin
if (CLK = '1') then
if aux = max then
aux <= "0000000";
else
aux <= aux + 1;
end if;
else
null;
end if;
end process;
NUM <= aux;
end funcional;

Test Bench:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;

entity contadorascendente_tb is

end contadorascendente_tb;

architecture prueba of contadorascendente_tb is


component contadorascendente
port(
CLK: IN STD_LOGIC;
NUM: OUT UNSIGNED(6 downto 0)
);
end component;

signal NUM : UNSIGNED(6 downto 0);


signal clk: STD_LOGIC:= '0';
constant num_ciclos: INTEGER:= 513;

begin

process
begin
for i in 1 to num_ciclos loop
clk <= not clk;
wait for 1 ns;
clk <= not clk;
wait for 1 ns;
end loop;
wait;
end process;

contador: contadorascendente
port map(
CLK => clk,
NUM => NUM
);

end prueba;

Prueba en GTKWave:

Figura 8. Prueba del contador, se muestran los números hasta el 512 y luego regresa a 0.

3.9. Realizar el código VHDL necesario para implementar un contador descendente del
módulo indicado en la siguiente tabla. Módulo 385
Código en VHDL:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;

entity contadordescendente is
port
(
CLK: IN STD_LOGIC;
NUM: OUT UNSIGNED(7 downto 0)
);
end contadordescendente;

architecture funcional of contadordescendente is


signal aux: unsigned (7 downto 0):="11100001";
begin
process (CLK)
begin
if (CLK = '1') then
if aux = "00000000" then
aux <= "11100001";
else
aux <= aux - 1;
end if;
else
null;
end if;
end process;
NUM <= aux;
end funcional;

Test Bench:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;

entity contadordescendente_tb is

end contadordescendente_tb;

architecture prueba of contadordescendente_tb is


component contadordescendente
port(
CLK: IN STD_LOGIC;
NUM: OUT UNSIGNED(7 downto 0)
);
end component;

signal NUM : UNSIGNED(7 downto 0);


signal clk: STD_LOGIC:= '0';
constant num_ciclos: INTEGER:= 384;

begin

process
begin
for i in 1 to num_ciclos loop
clk <= not clk;
wait for 1 ns;
clk <= not clk;
wait for 1 ns;
end loop;
wait;
end process;

contador: contadordescendente
port map(
CLK => clk,
NUM => NUM
);

end prueba;

Resultados en GTKWave:

Figura 9. Prueba del contador empieza el conteo en 384 y desciende.


Figura 10. Una vez que el contador llega a 0 regresa a 384.

Referencias:
[1] TOCCI/WIDMER/MOSS. “Sistemas Digitales. Principios y Aplicaciones”. Prentice
Hall. 10ma. Edición. 2007.
[2] NOVILLO CARLOS A., "Sistemas Digitales" Quito, Escuela Politécnica Nacional,
2010.
[3] MAXIMEZ DAVID, “VHDL El arte de programar sistemas digitales”, Editorial
Continental, 2002.
[4] http://fourier.eng.hmc.edu/e85_old/lectures/digital_logic/node16.html

Vous aimerez peut-être aussi