# Role of `Gray` Coding in Digital Design

Some implementation in digital design requires Gray encoding where only `one bit` is allowed to transition between two consecutive numbers.

`Logic`: Binary and Gray conversions for 4 bit numbers are below:

Binary from Gray:

bin = gray^gray^gray^gray

bin = gray^gray^gray

bin = gray^gray

bin = gray

Gray from binary:

gray = bin ^ bin

gray = bin ^ bin

gray = bin ^ bin

gray = bin

LTE - 4G Wireless Technology

Digital fundamentals.

Interview Questions.

Example - Clock domain crossing scenarios, FIFO's are required. FIFO's read/write address counters are running from different clocks. In this scenario, we will need to exchange one clock domain counter value with another clock domain. In this scenario multiple bits toggling with binary counters can result in synchronization issues. So we convert binary counters to gray and then synchronize across clock domains.

Decimal to binary to gray codes from 0-100 are discussed below.

Binary to Gray code mapping for 0 to 10

# Decimal = 0 : Binary = 10'b0000000000 : Gray = 10'b0000000000

# Decimal = 1 : Binary = 10'b0000000001 : Gray = 10'b0000000001

# Decimal = 2 : Binary = 10'b0000000010 : Gray = 10'b0000000011

# Decimal = 3 : Binary = 10'b0000000011 : Gray = 10'b0000000010

# Decimal = 4 : Binary = 10'b0000000100 : Gray = 10'b0000000110

# Decimal = 5 : Binary = 10'b0000000101 : Gray = 10'b0000000111

# Decimal = 6 : Binary = 10'b0000000110 : Gray = 10'b0000000101

# Decimal = 7 : Binary = 10'b0000000111 : Gray = 10'b0000000100

# Decimal = 8 : Binary = 10'b0000001000 : Gray = 10'b0000001100

# Decimal = 9 : Binary = 10'b0000001001 : Gray = 10'b0000001101

Decimal = 10 : Binary = 10'b0000001010 : Gray = 10'b0000001111

Tutorials `@fullchipdesign.com`

Verilog Tutorial.

LTE Tutorial.

Memory Tutorial.

Hope you liked! this page. Don't forgot to access relevant `previous and next sections ` with links below.