mirror of
https://github.com/myhdl/myhdl.git
synced 2025-01-24 21:52:56 +08:00
17 lines
230 B
Python
17 lines
230 B
Python
from myhdl import block, always_comb
|
|
|
|
@block
|
|
def bin2gray(B, G):
|
|
""" Gray encoder.
|
|
|
|
B -- binary input
|
|
G -- Gray encoded output
|
|
"""
|
|
|
|
@always_comb
|
|
def logic():
|
|
G.next = (B>>1) ^ B
|
|
|
|
return logic
|
|
|