Search This Blog

Saturday, July 20, 2013

Design of Binary To GRAY Code Converter using IF-ELSE Statements (Behavior Modeling Style).






Design of Binary To GRAY Code Converter using IF-ELSE Statements (Behavior Modeling Style).



Output Waveform :   Binary To GRAY Code Converter




VHDL Code-


-------------------------------------------------------------------------------
--
-- Title       : binary_to_gray
-- Design      : vhdl_upload 1
-- Author      : Naresh Singh Dobal
-- Company     : nsdobal@gmail.com
-- VHDL Tutorials & exercise by Naresh Singh Dobal
-------------------------------------------------------------------------------
--
-- File        : Binary to gray converter using if else.vhd

   

library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity binary_to_gray is
     port(
         din : in STD_LOGIC_VECTOR(3 downto 0);
         dout : out STD_LOGIC_VECTOR(3 downto 0)
         );
end binary_to_gray;


architecture binary_to_gray_arc of binary_to_gray is
begin
   
    btog : process (din) is
    begin
        if (din="0000") then
            dout <= "0000";
        elsif (din="0001") then
            dout <= "0001";
        elsif (din="0010") then
            dout <=    "0011";
        elsif (din="0011") then
            dout <=    "0010";
        elsif (din="0100") then
            dout <=    "0110";
        elsif (din="0101") then
            dout <= "0111";
        elsif (din="0110") then
            dout <=    "0101";
        elsif (din="0111") then
            dout <=    "0100";
        elsif (din="1000") then
            dout <=    "1100";
        elsif (din="1001") then
            dout <=    "1101";
        elsif (din="1010") then
            dout <= "1111";
        elsif (din="1011") then
            dout <=    "1110";
        elsif (din="1100") then
            dout <=    "1010";
        elsif (din="1101") then
            dout <=    "1011";
        elsif (din="1110") then
            dout <=    "1001";
        else
            dout <=    "1000";
        end if;
    end process btog;
   

end binary_to_gray_arc;

1 comment:

  1. please send me link of programmming tutorial its urgent

    ReplyDelete