Anda di halaman 1dari 6

CICLO

UNIVERSIDAD NACIONAL MAYOR VIII


DE SAN MARCOS

FIEE
Diseño Digital
“Problemas Propuestos”

Profesor:
- Ing. Alfredo Granados Ly
Alumno:
- Segovia Pujaico Álvaro Saúl 15190039
Horario:
- Sábado 11 a 2 pm

CIUDAD UNIVERSITARIA 24 DE NOVIEMBRE DEL 2018


Problemas propuestos

1. Multiplicación de dos números de 8 bits por sumas sucesivas:

Diagrama de estados

Inicio=0 Inicio=1 z=1

S0/000000 S1/101010 S2/010100 S3/000001

z=0

lm,dec,ln,la,clr,ena

Código VHDL

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_arith.all;

use ieee.std_logic_unsigned.all;

entity sumas8bits is

port( inicio,reloj: in std_logic;

entrada1, entrada2 : in std_logic_vector(7 downto 0);

salida : out std_logic_vector(15 downto 0));

end sumas8bits;

architecture behavior of sumas8bits is

signal lm,dec,ln,la,clr,ena,z: std_logic;

signal down: std_logic_vector(7 downto 0);

signal B,A : std_logic_vector(15 downto 0);

Type estado is (s0,s1,s2,s3);

signal es,ep:estado;

begin

process(reloj)
begin

if rising_edge(reloj) then

ep<=es;

if lm='1' and ln='1' and clr='1' then

down<=entrada1;

B <= "00000000" & entrada2;

A <= (others => '0');

elsif dec= '1' and la= '1' then

down <= down - 1;

A <= A + B;

end if;

end if;

end process;

z <= '1' when down=1 else '0';

salida <= A when ena='1' else (others =>'Z');

process(ep)

begin

es<=ep;

case ep is when s0 => lm <='0';dec <='0';ln <='0';la <='0';clr <='0';ena <='0';

if inicio='1' then es <= s1; else es <= s0;

end if;

when s1 => lm <='1';dec <='0';ln <='1';la <='0';clr <='1';ena <='0';

es <= s2;

when s2 => lm <='0';dec <='1';ln <='0';la <='1';clr <='0';ena <='0';

if z='1' then es <= s3; else es <= s2;

end if;

when s3 => lm <='0';dec <='0';ln <='0';la <='0';clr <='0';ena <='1';

es <= s3;

end case;

end process;

end behavior;
Simulaciones

2. Multiplicación de dos números de 8 bits por suma y desplazamiento:

Diagrama de estados

Inicio=1 z=1
Inicio=0

S1/1010010 S2/0101100 S3/0000001


S0/0000000

z=0

lm,dec,ln,la,clr,ena

Código VHDL

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity sumadespl is
port( inicio,reloj : in std_logic;
entrada1,entrada2 : in std_logic_vector(7 downto 0);
salida : out std_logic_vector(15 downto 0));
end sumadespl;

architecture behavior of sumadespl is


signal lm,dd,ln,di,la,clr,ena,hab,z: std_logic;
signal B: std_logic_vector(7 downto 0);
signal A,C: std_logic_vector(15 downto 0);
type estado is (s0,s1,s2,s3);
signal es,ep: estado;
begin
process(reloj)
begin
if rising_edge(reloj) then
ep<=es;
if lm='1' and ln='1' and clr='1' then
B <= entrada1;
C <= "00000000" & entrada2;
A <= (others => '0');
elsif dd='1' and di='1' and la='1' then
if hab='1' then
A <= A + C;
end if;
B <= '0' & B(7 downto 1);
C <= C(14 downto 0) & '0';
end if;
end if;
end process;
salida<= A when ena='1' else (others => 'Z');
z<= '1' when B=0 else '0';
hab<= B(0);

process(ep)
begin
es<=ep;
case ep is
when s0 => lm<='0'; dd<='0'; ln<='0'; di<='0'; la<='0'; clr<='0';ena<='0';
if inicio='1' then
es<=s1; else es<=s0; end if;

when s1 => lm<='1'; dd<='0'; ln<='1'; di<='0'; la<='0'; clr<='1'; ena<='0';


es<=s2;

when s2 => lm<='0'; dd<='1'; ln<='0'; di<='1'; la<='1'; clr<='0'; ena<='0';


if z='1' then
es<=s3; else es<=s2; end if;

when s3 => lm<='0'; dd<='0'; ln<='0'; di<='0'; la<='0'; clr<='0'; ena<='1';


es<=s3;

end case;
end process;

end behavior;
Simulaciones

Anda mungkin juga menyukai