o_domain=.
This is for consistency with other synchronizers.
Fixes #467.
Asynchronous input signal, to be synchronized.
o : Signal(1), out
Synchronously released output signal.
- domain : str
+ o_domain : str
Name of clock domain to synchronize to.
stages : int, >=2
Number of synchronization stages between input and output. The lowest safe number is 2,
async_edge : str
The edge of the input signal which causes the output to be set. Must be one of "pos" or "neg".
"""
- def __init__(self, i, o, *, domain="sync", stages=2, async_edge="pos", max_input_delay=None):
+ def __init__(self, i, o, *, o_domain="sync", stages=2, async_edge="pos", max_input_delay=None):
_check_stages(stages)
self.i = i
self.o = o
- self._domain = domain
+ self._o_domain = o_domain
self._stages = stages
if async_edge not in ("pos", "neg"):
m.d.comb += ResetSignal("async_ff").eq(~self.i)
m.d.comb += [
- ClockSignal("async_ff").eq(ClockSignal(self._domain)),
+ ClockSignal("async_ff").eq(ClockSignal(self._o_domain)),
self.o.eq(flops[-1])
]
self._max_input_delay = max_input_delay
def elaborate(self, platform):
- return AsyncFFSynchronizer(self.arst, ResetSignal(self._domain), domain=self._domain,
+ return AsyncFFSynchronizer(self.arst, ResetSignal(self._domain), o_domain=self._domain,
stages=self._stages, max_input_delay=self._max_input_delay)
# full discussion.
w_rst = ResetSignal(domain=self._w_domain, allow_reset_less=True)
r_rst = Signal()
-
+
# Async-set-sync-release synchronizer avoids CDC hazards
rst_cdc = m.submodules.rst_cdc = \
- AsyncFFSynchronizer(w_rst, r_rst, domain=self._r_domain)
+ AsyncFFSynchronizer(w_rst, r_rst, o_domain=self._r_domain)
# Decode Gray code counter synchronized from write domain to overwrite binary
# counter in read domain.
def test_edge_wrong(self):
with self.assertRaisesRegex(ValueError,
r"^AsyncFFSynchronizer async edge must be one of 'pos' or 'neg', not 'xxx'$"):
- AsyncFFSynchronizer(Signal(), Signal(), domain="sync", async_edge="xxx")
+ AsyncFFSynchronizer(Signal(), Signal(), o_domain="sync", async_edge="xxx")
def test_pos_edge(self):
i = Signal()
if async_ff_sync._edge == "pos":
m.submodules += Instance("altera_std_synchronizer",
p_depth=async_ff_sync._stages,
- i_clk=ClockSignal(async_ff_sync._domain),
+ i_clk=ClockSignal(async_ff_sync._o_domain),
i_reset_n=~async_ff_sync.i,
i_din=Const(1),
o_dout=sync_output,
else:
m.submodules += Instance("altera_std_synchronizer",
p_depth=async_ff_sync._stages,
- i_clk=ClockSignal(async_ff_sync._domain),
+ i_clk=ClockSignal(async_ff_sync._o_domain),
i_reset_n=async_ff_sync.i,
i_din=Const(1),
o_dout=sync_output,
m.d.comb += ResetSignal("async_ff").eq(~async_ff_sync.i)
m.d.comb += [
- ClockSignal("async_ff").eq(ClockSignal(async_ff_sync._domain)),
+ ClockSignal("async_ff").eq(ClockSignal(async_ff_sync._o_domain)),
async_ff_sync.o.eq(flops[-1])
]
m.d.comb += ResetSignal("async_ff").eq(~async_ff_sync.i)
m.d.comb += [
- ClockSignal("async_ff").eq(ClockSignal(async_ff_sync._domain)),
+ ClockSignal("async_ff").eq(ClockSignal(async_ff_sync._o_domain)),
async_ff_sync.o.eq(flops[-1])
]
m.d.comb += ResetSignal("async_ff").eq(~async_ff_sync.i)
m.d.comb += [
- ClockSignal("async_ff").eq(ClockSignal(async_ff_sync._domain)),
+ ClockSignal("async_ff").eq(ClockSignal(async_ff_sync._o_domain)),
async_ff_sync.o.eq(flops[-1])
]