1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00
myhdl/example/manual/bin2gray.py

17 lines
230 B
Python
Raw Normal View History

from myhdl import block, always_comb
2003-02-04 23:02:56 +00:00
@block
def bin2gray(B, G):
2003-02-05 22:07:33 +00:00
""" Gray encoder.
2016-05-20 11:31:04 +02:00
B -- binary input
G -- Gray encoded output
2003-02-05 22:07:33 +00:00
"""
2005-12-09 17:01:07 +00:00
@always_comb
def logic():
G.next = (B>>1) ^ B
2003-06-30 14:24:23 +00:00
return logic
2016-05-20 11:31:04 +02:00