forked from M-Labs/artiq
1
0
Fork 0

wrpll: improve DDMTD deglitcher

This commit is contained in:
Sebastien Bourdeauducq 2019-12-30 16:56:06 +08:00
parent dfad27125e
commit 9e15ff7e6a
1 changed files with 19 additions and 15 deletions

View File

@ -44,19 +44,23 @@ class DDMTDSamplerGTP(Module):
] ]
class DDMTDEdgeDetector(Module): class DDMTDDeglitcherFirstEdge(Module):
def __init__(self, input_signal): def __init__(self, input_signal, blind_period=128):
self.rising = Signal() self.detect = Signal()
self.tag_correction = 0
history = Signal(4) rising = Signal()
deglitched = Signal() input_signal_r = Signal()
self.sync.helper += history.eq(Cat(history[1:], input_signal))
self.comb += deglitched.eq(input_signal | history[0] | history[1] | history[2] | history[3])
deglitched_r = Signal()
self.sync.helper += [ self.sync.helper += [
deglitched_r.eq(deglitched), input_signal_r.eq(input_signal),
self.rising.eq(deglitched & ~deglitched_r) rising.eq(input_signal & ~input_signal_r)
]
blind_counter = Signal(max=blind_period)
self.sync.helper += [
If(blind_counter != 0, blind_counter.eq(blind_counter - 1)),
If(rising, blind_counter.eq(blind_period - 1)),
self.detect.eq(rising & (blind_counter == 0))
] ]
@ -71,14 +75,14 @@ class DDMTD(Module, AutoCSR):
# # # # # #
ed = DDMTDEdgeDetector(input_signal) deglitcher = DDMTDDeglitcherFirstEdge(input_signal)
self.submodules += ed self.submodules += deglitcher
self.sync.helper += [ self.sync.helper += [
self.h_tag_update.eq(0), self.h_tag_update.eq(0),
If(ed.rising, If(deglitcher.detect,
self.h_tag_update.eq(1), self.h_tag_update.eq(1),
self.h_tag.eq(counter) self.h_tag.eq(counter + deglitcher.tag_correction)
) )
] ]