Sunday, April 7, 2013

2X4 DECODER VHDL

This code is just an example for more detailed understanding of VHDL concepts I would recommend these two books :

1) A VHDL PRIMER by J. Bhasker - A VHDL PRIMER from flipkart.com
A VHDL PRIMER from amazon.com
A VHDL PRIMER from amazon.in

2)VHDL:PROGRAMMING BY EXAMPLES by PERRY - VHDL:PROGRAMMING BY EXAMPLES by PERRY from flipkart.com
VHDL:PROGRAMMING BY EXAMPLES by PERRY from amazon.com
VHDL:PROGRAMMING BY EXAMPLES by PERRY from amazon.in


CODE : 2X4 DECODER

----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date:    21:18:08 10/31/2006
-- Design Name:
-- Module Name:    2X4dec_code - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity dec2X4_code is
    Port ( i : in  STD_LOGIC_VECTOR (1 downto 0);
           e : in  STD_LOGIC;
           o : out  STD_LOGIC_VECTOR (3 downto 0));
end dec2X4_code;


architecture Behavioral of dec2X4_code is
begin
            process(i,e)
            begin
                        if(e='1') then
                                    o(0) <= not(i(0)) and not(i(1));
                                    o(1) <= (i(0)) and not(i(1));
                                    o(2) <= not(i(0)) and i(1);
                                    o(3) <= i(0) and i(1);
                        else
                                    o <= "ZZZZ";
                        end if;
            end process;
end Behavioral;

No comments:

Post a Comment