mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
gen/genlib/cdc: add GrayDecoder from misoc
This commit is contained in:
parent
ab5b9389b7
commit
f0202db90f
1 changed files with 14 additions and 0 deletions
|
@ -142,6 +142,20 @@ class GrayCounter(Module):
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class GrayDecoder(Module):
|
||||||
|
def __init__(self, width):
|
||||||
|
self.i = Signal(width)
|
||||||
|
self.o = Signal(width)
|
||||||
|
|
||||||
|
# # #
|
||||||
|
|
||||||
|
o_comb = Signal(width)
|
||||||
|
self.comb += o_comb[-1].eq(self.i[-1])
|
||||||
|
for i in reversed(range(width-1)):
|
||||||
|
self.comb += o_comb[i].eq(o_comb[i+1] ^ self.i[i])
|
||||||
|
self.sync += self.o.eq(o_comb)
|
||||||
|
|
||||||
|
|
||||||
class ElasticBuffer(Module):
|
class ElasticBuffer(Module):
|
||||||
def __init__(self, width, depth, idomain, odomain):
|
def __init__(self, width, depth, idomain, odomain):
|
||||||
self.din = Signal(width)
|
self.din = Signal(width)
|
||||||
|
|
Loading…
Reference in a new issue