Assignment 1
Assignment 1
From the
functional description given in the datasheet, write a VHDL description for a 74154 4-to16 decoder. Use only STD_LOGIC and STD_LOGIC_VECTOR data types in constructing
your design. Enter the design into the Quartus II software and verify the syntax
correctness by compiling the design. The design should compile without error. Use
suggested style guidelines for your VHDL source code. Turn in both the datasheet and
the VHDL source.
Answer :
library ieee ;
use ieee.std_logic_1164.all;
entity decoder2 is
port (a, b, c,d : in std_logic ;
y : out std_logic_vector (15 downto 0) ) ;
end decoder2 ;
architecture structural of decoder2 is
signal abcd : std_logic_vector (3 downto 0) ;
begin
process(a,b,c,d)
begin
abcd <= a & b & c& d ;
case abcd is
when "0000"=> y<="0000000000000001";
when "0001"=> y<="0000000000000010";
when "0010"=> y<="0000000000000100";
when "0011"=> y<="0000000000001000";
when "0100"=> y<="0000000000010000";
when "0101"=> y<="0000000000100000";
when "0110"=> y<="0000000001000000";
when "0111"=> y<="0000000010000000";
when "1000"=> y<="0000000100000000";
when "1001"=> y<="0000001000000000";
when "1010"=> y<="0000010000000000";
when "1011"=> y<="0000100000000000";
when "1100"=> y<="0001000000000000";
when "1101"=> y<="0010000000000000";
when "1110"=> y<="0100000000000000";
when others=> y<="1000000000000000";
end case;
end process;
end structural ;
2/9
3/9
2. Write a VHDL description for a 4-bit binary-to-gray code converter. Enter the design
into the Quartus II software and verify the syntax correctness by compiling the
design. Use suggested style guidelines for your VHDL source code. The design should
compile without error.
Answer :
library ieee;
use ieee.std_logic_1164.all;
entity decoder10 IS
port(g: in std_logic_vector(3 downto 0);
b: out std_logic_vector(3 downto 0));
end decoder10 ;
architecture structural of decoder10 is
begin
b(3)<=g(3);
b(2)<=g(3)xor g(2);
b(1)<=g(2)xor g(1);
b(0)<=g(1)xor g(0);
end structural;
4/9
3. Write a VHDL description for a 4-bit gray-to-binary code converter. Enter the design
into the Quartus II software and verify the syntax correctness by compiling the
design. Use suggested style guidelines for your VHDL source code. The design should
compile without error.
Answer :
library ieee;
use ieee.std_logic_1164.all;
entity converter is
port(g:in std_logic_vector(3 downto 0);
b:inout std_logic_vector(3 downto 0));
end converter;
architecture structural of converter is
begin
b(3)<=g(3);
b(2)<=b(3)xor g(2);
b(1)<=b(2)xor g(1);
b(0)<=b(1)xor g(0);
end structural ;
5/9
6/9
8/9
9/9