Professional Documents
Culture Documents
Registro de Corrimiento de 4 Bits: Códigos Utilizados
Registro de Corrimiento de 4 Bits: Códigos Utilizados
Registro de Corrimiento de 4 Bits: Códigos Utilizados
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity reg_corri_4b is
Port ( clk,load,en : in STD_LOGIC;
p_in : in STD_LOGIC_VECTOR (3 downto 0);
s_out : out STD_LOGIC);
end reg_corri_4b;
begin
process(clk)
begin
if rising_edge(clk)
then if load ='1'
then registro <= p_in;
s_out<='0';
elsif en='1'
then registro <= registro(2 downto 0) & '0';
s_out<= registro(3);
end if;
end if;
end process;
end Behavioral;
Corrimiento de 12 bits
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity reg_12b is
Port ( clk,en,clr : in STD_LOGIC;
dato_in : in STD_LOGIC_VECTOR (11 downto 0);
dato_out : out STD_LOGIC_VECTOR (11 downto 0));
end reg_12b;
begin
process(clk)
begin
if rising_edge(clk)
then if clr='1'
then dato_out <=(others =>'0');
elsif en ='1'
then dato_out <= dato_in;
end if;
end if;
end process;
end Behavioral;
Multiplexor
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity mux is
Port ( a,b : in STD_LOGIC_VECTOR (11 downto 0);
sel : in STD_LOGIC;
z : out STD_LOGIC_VECTOR (11 downto 0));
end mux;
begin
end Behavioral;
Sumador
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
entity sumador is
Port ( a : in STD_LOGIC_VECTOR (11 downto 0);
b : in STD_LOGIC_VECTOR (7 downto 0);
z : out STD_LOGIC_VECTOR (11 downto 0));
end sumador;
begin
z<= a + ("0000"&b);
end Behavioral;
Registro de 8 bits
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity reg_8b is
Port ( clk,en: in STD_LOGIC;
dato_in : in STD_LOGIC_VECTOR (7 downto 0);
dato_out : out STD_LOGIC_VECTOR (7 downto 0));
end reg_8b;
begin
process(clk)
begin
if rising_edge(clk)
then if en ='1'
then dato_out <= dato_in;
end if;
end if;
end process;
end Behavioral;
Contador
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
entity contador is
Port ( clk,load,en : in STD_LOGIC;
fin_cnt : out STD_LOGIC);
end contador;
end Behavioral;
Máquina de estado
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity M_Estado is
Port ( clk, reset, start, fin : in STD_LOGIC;
alfa,beta,gama : out STD_LOGIC);
end M_Estado;
begin
next_blk: process(start,fin,actual)
begin
case actual is
when espera => if start = '0'
then
proximo<= espera;
else
proximo<= inicia;
end if;
when inicia => proximo <= desplaza;
when desplaza => proximo <= carga;
when carga => proximo <= decide;
when decide => if fin = '0'
then
proximo <= desplaza;
else
proximo <= espera;
end if;
end case;
end process next_blk;
output_blk: process(actual)
begin
alfa<='0';beta<='0';gama<='0';
case actual is
when espera => null;
when inicia => alfa <='1';
when desplaza => beta <= '1';
when carga => gama <= '1';
when decide => null;
end case;
end process output_blk;
seq_blk: process(clk)
begin
if rising_edge(clk)
then if reset ='1'
then actual <= espera;
else actual <= proximo;
end if;
end if;
end process seq_blk;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity mux2_1 is
Port ( a,b : in STD_LOGIC_VECTOR (3 downto 0);
sel : in STD_LOGIC;
z : out STD_LOGIC_VECTOR (3 downto 0));
end mux2_1;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
entity negativo1 is
Port ( dato : in STD_LOGIC_VECTOR (3 downto 0);
z : out STD_LOGIC_VECTOR (3 downto 0));
end negativo1;
end Behavioral;