Documente Academic
Documente Profesional
Documente Cultură
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity cong1bit is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
ci : in STD_LOGIC;
s : out STD_LOGIC;
co : out STD_LOGIC);
end cong1bit;
begin
s<=(a xor b) xor ci;
co<=(a and b) or ((a xor b) and ci);
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity cong3bit is
Port ( a : in STD_LOGIC_VECTOR (2 downto 0);
b : in STD_LOGIC_VECTOR (2 downto 0);
ci : in STD_LOGIC;
s : inout STD_LOGIC_VECTOR (2 downto 0);
co : inout STD_LOGIC;
led : out std_logic_vector (6 downto 0));
end cong3bit;
entity chuoibit is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
d : in STD_LOGIC;
q : out STD_LOGIC);
end chuoibit;
process(pr,d)
begin
case pr is
when st0=>
q<='0';
if(d='1') then
nx<=st1;
else
nx<=st0;
end if;
when st1=>
q<='0';
if(d='1') then
nx<=st2;
else
nx<=st0;
end if;
when st2=>
q<='0';
if(d='1') then
nx<=st3;
else
nx<=st0;
end if;
when st3=>
q<='1';
if(d='1') then
nx<=st3;
else
nx<=st0;
end if;
end case;
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity dem10tien is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
y : out STD_LOGIC_VECTOR (3 downto 0);
led : out STD_LOGIC_VECTOR (6 downto 0));
end dem10tien;
begin
process(clk,rst)
variable dem: integer range 0 to 10;
begin
if(rst='1') then
dem:=0;
elsif(clk' event and clk='1') then
dem:=dem+1;
if(dem=10) then
dem:=0;
end if;
end if;
case dem is
when 0 => led <= "1000000";
when 1 => led <= "1111001";
when 2 => led <= "0100100";
when 3 => led <= "0110000";
when 4 => led <= "0011001";
when 5 => led <= "0010010";
when 6 => led <= "0000010";
when 7 => led <= "1111000";
when 8 => led <= "0000000";
when 9 => led <= "0010000";
when others => null;
end case;
case dem is
when 0 => y <= "0000";
when 1 => y <= "0001";
when 2 => y <= "0010";
when 3 => y <= "0011";
when 4 => y <= "0100";
when 5 => y <= "0101";
when 6 => y <= "0110";
when 7 => y <= "0111";
when 8 => y <= "1000";
when 9 => y <= "1001";
when others => null;
end case;
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity de4 is
Port ( a : in STD_LOGIC_VECTOR (2 downto 0);
b : in STD_LOGIC_VECTOR (2 downto 0);
y : out STD_LOGIC_VECTOR (3 downto 0);
dk : in STD_LOGIC_VECTOR (2 downto 0));
end de4;
begin
process(a,b,dk)
begin
if dk="001" then
y <= ('0' & a) + ('0' & b);
elsif dk="010" then
y <= ('0' & a) + 1;
elsif dk="100" then
y <= ('0' & b) + 1;
end if;
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity de4 is
Port ( a : in STD_LOGIC_VECTOR (2 downto 0);
b : in STD_LOGIC_VECTOR (2 downto 0);
dk : in STD_LOGIC_VECTOR (2 downto 0);
y : out STD_LOGIC_VECTOR (3 downto 0);
led : out STD_LOGIC_VECTOR (6 downto 0));
end de4;
process(x)
begin
case x is
when "0000" => led <="1000000";
when "0001" => led <="1111001";
when "0010" => led <="0100100";
when "0011" => led <="0110000";
when "0100" => led <="0011001";
when "0101" => led <="0010010";
when "0110" => led <="0000010";
when "0111" => led <="1111000";
when "1000" => led <="0000000";
when "1001" => led <="0001000";
when others => null;
end case;
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity de5 is
Port ( a : in STD_LOGIC_VECTOR (1 downto 0);
b : in STD_LOGIC_VECTOR (1 downto 0);
ci : in STD_LOGIC;
s : out STD_LOGIC_VECTOR (1 downto 0);
co : out STD_LOGIC);
end de5;
process(a,b,tg)
begin
s(1) <= a(1) xor b(1) xor tg;
co <= (a(1) and b(1)) or (tg and (a(1) xor b(1)));
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity DE6 is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
d : in STD_LOGIC;
y : out STD_LOGIC);
end DE6;
process(pr,d)
begin
case pr is
when st0 =>
y <='1';
if d='0' then
nx <= st1;
else
nx <= st0;
end if;
when st1 =>
y <='1';
if d='0' then
nx <= st2;
else
nx <= st0;
end if;
when st2 =>
y <='1';
if d='0' then
nx <= st3;
else
nx <= st0;
end if;
when st3 =>
y <='0';
if d='0' then
nx <= st3;
else
nx <= st0;
end if;
end case;
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity de7 is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
y : out STD_LOGIC_VECTOR (3 downto 0));
end de7;
begin
process(clk,rst)
variable dem : integer range 9 downto 0 :=9;
begin
if rst='1' then
dem :=9;
elsif rising_edge(clk) then
if dem=0 then
dem :=9;
else
dem := dem -1;
end if;
end if;
y <= conv_std_logic_vector(dem, 4);
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity de8 is
Port ( a : in STD_LOGIC_VECTOR (2 downto 0);
b : in STD_LOGIC_VECTOR (2 downto 0);
y : out STD_LOGIC_VECTOR (3 downto 0);
dk : in STD_LOGIC_VECTOR (2 downto 0));
end de8;
architecture Behavioral of de8 is
begin
process(a,b,dk)
begin
if dk="001" then
y <= ('0' & a) + ('0' & b);
elsif dk="010" then
y <= ('0' & a) + 2;
elsif dk="100" then
y <= ('0' & b) + 2;
end if;
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity de9 is
Port ( a : in STD_LOGIC_VECTOR (1 downto 0);
b : in STD_LOGIC_VECTOR (1 downto 0);
ci : in STD_LOGIC;
co : inout STD_LOGIC;
led7 : out STD_LOGIC_VECTOR (7 downto 0);
s : inout STD_LOGIC_VECTOR (1 downto 0));
end de9;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity de11 is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
y : out STD_LOGIC_VECTOR (3 downto 0));
end de11;
process(pr)
begin
case pr is
when st0 =>
y <= "0000";
nx <= st1;
when st1 =>
y <= "0001";
nx <= st2;
when st2 =>
y <= "0010";
nx <= st3;
when st3 =>
y <= "0011";
nx <= st4;
when st4 =>
y <= "0100";
nx <= st5;
when st5 =>
y <= "0101";
nx <= st6;
when st6 =>
y <= "0110";
nx <= st7;
when st7 =>
y <= "0111";
nx <= st8;
when st8 =>
y <= "1000";
nx <= st9;
when st9 =>
y <= "1001";
nx <= st0;
end case;
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
use IEEE.STD_LOGIC_arith.ALL;
entity de12 is
Port ( a : in STD_LOGIC_VECTOR (2 downto 0);
b : in STD_LOGIC_VECTOR (2 downto 0);
dk : in STD_LOGIC_VECTOR (3 downto 0);
y : out STD_LOGIC_VECTOR (3 downto 0);
led : out STD_LOGIC_VECTOR (6 downto 0));
end de12;
process(x)
begin
case x is
when "0000" => led <="1000000";
when "0001" => led <="1111001";
when "0010" => led <="0100100";
when "0011" => led <="0110000";
when "0100" => led <="0011001";
when "0101" => led <="0010010";
when "0110" => led <="0000010";
when "0111" => led <="1111000";
when "1000" => led <="0000000";
when "1001" => led <="0001000";
when others => null;
end case;
end process;
end Behavioral;