Documente Academic
Documente Profesional
Documente Cultură
INNOVATION
Submitted By :
Anand Ahlawat(0111153108)
Nitin (0121153108)
Theory
A binary code used to represent digits generated from a mechanical sensor that may be prone to error. Used in
telegraphy in the late 1800s, and also known as "reflected binary code," Gray code was patented by Bell Labs
researcher Frank Gray in 1947.
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
Gray Counter
Program Code :
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity gray_counter is
port
(
clk : in std_logic;
reset : in std_logic;
enable : in std_logic;
gray_count : out std_logic_vector(7 downto 0)
);
end entity;
-- Implementation:
-- Almost every non-imaginary bit has a component instance that sets the
-- bit based on the values of the lower-order bits, as described above.
-- The rules have to differ slightly for the most significant bit or else
-- the counter would saturate at it's highest value, 1000...0.
-- q contains all the values of the counter, plus the imaginary bit
-- (values are shifted to make room for the imaginary bit at q(0))
signal q : std_logic_vector (8 downto 0);
begin
for i in 1 to 8 loop
end loop; -- i
end if;
end process;
process(q, no_ones_below)
begin
for j in 1 to 8 loop
no_ones_below(j) <= no_ones_below(j-1) and not q(j-1);
end loop;
end process;
end rtl;