1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00
myhdl/example/manual/bin2gray.py
2016-05-20 11:31:04 +02:00

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