Download presentation

1
Gray Code Converters Discussion D9.1 Example 16

2
**Gray Code Definition: An ordering of 2n binary numbers such that**

only one bit changes from one entry to the next. Binary coding {0...7}: {000, 001, 010, 011, 100, 101, 110, 111} Gray coding {0...7}: {000, 001, 011, 010, 110, 111, 101, 100} Not unique One method for generating a Gray code sequence: Start with all bits zero and successively flip the right-most bit that produces a new string.

3
**Binary - Gray Code Conversions**

Gray code: G(i), i = n – 1 downto 0 Binary code: B(i), i = n – 1 downto 0 Binary coding {0...7}: {000, 001, 010, 011, 100, 101, 110, 111} Gray coding {0...7}: {000, 001, 011, 010, 110, 111, 101, 100} Convert Binary to Gray: Copy the most significant bit. For each smaller i G(i) = B(i+1) xor B(i) Convert Gray to Binary: Copy the most significant bit. For each smaller i B(i) = B(i+1) xor G(i)

4
**bin2gray.vhd library IEEE; use IEEE.STD_LOGIC_1164.all;**

entity bin2gray is generic(width:positive := 3); port( b : in STD_LOGIC_VECTOR(width-1 downto 0); g : out STD_LOGIC_VECTOR(width-1 downto 0) ); end bin2gray; architecture bin2gray of bin2gray is begin process(b) g(width-1) <= b(width-1); for i in width-2 downto 0 loop g(i) <= b(i+1) xor b(i); end loop; end process;

5
**Binary to Gray Code Conversion**

6
**gray2bin.vhd library IEEE; use IEEE.STD_LOGIC_1164.all;**

entity gray2bin is generic(width:positive := 3); port( g : in STD_LOGIC_VECTOR(width-1 downto 0); b : out STD_LOGIC_VECTOR(width-1 downto 0) ); end gray2bin; architecture gray2bin of gray2bin is begin process(g) variable bv: STD_LOGIC_VECTOR(width-1 downto 0); bv(width-1) := G(width-1); for i in width-2 downto 0 loop bv(i) := bv(i+1) xor g(i); end loop; b <= bv; end process; gray2bin.vhd

7
**Gray Code to Binary Conversion**

Similar presentations

Presentation is loading. Please wait....

OK

Digilent Spartan 3 Board Discussion D3.3

Digilent Spartan 3 Board Discussion D3.3

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on cleanliness and hygiene Ppt on polynomials in maths what is the product Ppt on 2 stroke ic engine cooling Ppt on statistics and probability made Ppt on next generation 2-stroke engine model Ppt on eye os Ppt on means of communication in olden days Ppt on useful and harmful insects Ppt on 14 principles of henri fayol Ppt on needle stick injury health