Академический Документы
Профессиональный Документы
Культура Документы
15
entity comp8bit is
Port(a:in STD_LOGIC_VECTOR(7 DOWNTO 0);
b:in STD_LOGIC_VECTOR(7 DOWNTO 0);
agtb: out STD_LOGIC;
bgta: out STD_LOGIC;
aequalb: out STD_LOGIC);
end comp8bit;
begin
aequalb<='1'when(a=b) else '0';
agtb<='1'when(a>b) else '0';
bgta<='1'when(a<b) else '0';
end Behavioral;
entity decoder3to8 is
Port(a:in STD_LOGIC_VECTOR(2 DOWNTO 0);
y:out STD_LOGIC_VECTOR(7 DOWNTO 0));
end decoder3to8;
begin
process(a)
begin
case a is
when "000" =>y<="00000001";
when "001" =>y<="00000010";
when "010" =>y<="00000100";
when "011" =>y<="00001000";
when "100" =>y<="00010000";
when "101" =>y<="00100000";
when "110" =>y<="01000000";
when others =>y<="10000000";
end case;
end process;
end Behavioral;
Output of 3 to 8 decoder:
iii) VHDL Program for 4:1 mux:
Using CASE/WHEN Using WITH/SELECT Using WHEN/ELSE
library IEEE; library IEEE; library IEEE;
use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity mux is entity mux is use
port(s:in std_logic_vector(1 port(a,b,c,d: in std_logic; IEEE.STD_LOGIC_UNSIGNED.ALL;
downto 0); s:in std_logic_vector(1
a,b,c,d:in std_logic; downto 0); entity mux4to1 is
z:out std_logic); z:out std_logic); port(s:in std_logic_vector(1
end mux; downto 0);
a,b,c,d:in std_logic;
architecture Behavioral of mux end mux; z:out std_logic);
is end mux4to1;
architecture Behavioral of mux
begin is architecture Behavioral of
process(a,b,c,d,s) mux4to1 is
begin begin
case(s) is begin
when "00"=> z <=a; WITH S SELECT z<=a when s="00"else
when "01"=> z <=b;
when "10"=> z <=c; z<=a when "00", b when s="01"else
when others=> z <=d; b when "01",
end case; c when "10", c when s="10"else
end process; d when "11";
end Behavioral; d when s="11";
end Behavioral;
end Behavioral;
entity alu is
port(a,b,z: in std_logic_vector(3 downto 0);
y: out std_logic_vector(3 downto 0));
end alu;