Binary To Gray Converter VHDL Code Using Structural Modeling

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

ONLINE PLATFORM FOR PROGRAMMING AND RESEARCH (OP2R)

BINARY TO GRAY CODE CONVERSION


VHDL CODE USING STRUCTURAL MODELING

Library declaration
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--------------------------------------------------------entity B_G is
Port ( bin: in std_logic_vector (1 downto 0 );
gray: out std_logic_vector (3 downto 0);
end B_G;

Std_logic_1164. package for std_logic (predefined data type).

Entity declaration.
bin :- input port bits.(code that will be
converted in to its equivalent gray
representation.)
gray: - output port bits. (Converted code)

---------------------------------------------------------architecture Behavioral_BG of B_G is


---------------------------------------------component xor_1 is
Port ( o,p : in STD_LOGIC;
q : out STD_LOGIC);
end component;
---------------------------------------------------------begin
l1: xor_1 port map (bin(3), 0, gray(3));
l2: xor_1 port map (bin(3), bin(2),gray(2));
l3: xor_1 port map (bin(2), bin(1),gray(1));
l4: xor_1 port map (bin(1), bin(0),gray(0));
---------------------------------------------------------end Behavioral_BG;

RTL VIEW:-

INFOOP2R.WIX.COM/OP2R

OUT PUT WAVEFORMS

Component declarative part of


architecture.
Component xor_1 is declared which is
acting as an EX-OR gate.

Statement part of architecture.


Declared components (in
statement part) ports are mapped
to perform the circuit operation.

You might also like