lib.cdc: in AsyncFFSynchronizer(), rename domain= to o_domain=.

This is for consistency with other synchronizers.

Fixes #467.
This commit is contained in:
whitequark 2020-08-26 03:19:13 +00:00
parent 630c0fd99a
commit 0802f943ba
7 changed files with 13 additions and 13 deletions

View file

@ -109,7 +109,7 @@ class AsyncFFSynchronizer(Elaboratable):
Asynchronous input signal, to be synchronized. Asynchronous input signal, to be synchronized.
o : Signal(1), out o : Signal(1), out
Synchronously released output signal. Synchronously released output signal.
domain : str o_domain : str
Name of clock domain to synchronize to. Name of clock domain to synchronize to.
stages : int, >=2 stages : int, >=2
Number of synchronization stages between input and output. The lowest safe number is 2, Number of synchronization stages between input and output. The lowest safe number is 2,
@ -125,13 +125,13 @@ class AsyncFFSynchronizer(Elaboratable):
Define the ``get_async_ff_sync`` platform method to override the implementation of Define the ``get_async_ff_sync`` platform method to override the implementation of
:class:`AsyncFFSynchronizer`, e.g. to instantiate library cells directly. :class:`AsyncFFSynchronizer`, e.g. to instantiate library cells directly.
""" """
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) _check_stages(stages)
self.i = i self.i = i
self.o = o self.o = o
self._domain = domain self._o_domain = o_domain
self._stages = stages self._stages = stages
if async_edge not in ("pos", "neg"): if async_edge not in ("pos", "neg"):
@ -164,7 +164,7 @@ class AsyncFFSynchronizer(Elaboratable):
m.d.comb += ResetSignal("async_ff").eq(~self.i) m.d.comb += ResetSignal("async_ff").eq(~self.i)
m.d.comb += [ m.d.comb += [
ClockSignal("async_ff").eq(ClockSignal(self._domain)), ClockSignal("async_ff").eq(ClockSignal(self._o_domain)),
self.o.eq(flops[-1]) self.o.eq(flops[-1])
] ]
@ -212,7 +212,7 @@ class ResetSynchronizer(Elaboratable):
self._max_input_delay = max_input_delay self._max_input_delay = max_input_delay
def elaborate(self, platform): 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) stages=self._stages, max_input_delay=self._max_input_delay)

View file

@ -413,10 +413,10 @@ class AsyncFIFO(Elaboratable, FIFOInterface):
# full discussion. # full discussion.
w_rst = ResetSignal(domain=self._w_domain, allow_reset_less=True) w_rst = ResetSignal(domain=self._w_domain, allow_reset_less=True)
r_rst = Signal() r_rst = Signal()
# Async-set-sync-release synchronizer avoids CDC hazards # Async-set-sync-release synchronizer avoids CDC hazards
rst_cdc = m.submodules.rst_cdc = \ 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 # Decode Gray code counter synchronized from write domain to overwrite binary
# counter in read domain. # counter in read domain.

View file

@ -66,7 +66,7 @@ class AsyncFFSynchronizerTestCase(FHDLTestCase):
def test_edge_wrong(self): def test_edge_wrong(self):
with self.assertRaisesRegex(ValueError, with self.assertRaisesRegex(ValueError,
r"^AsyncFFSynchronizer async edge must be one of 'pos' or 'neg', not 'xxx'$"): 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): def test_pos_edge(self):
i = Signal() i = Signal()

View file

@ -402,7 +402,7 @@ class IntelPlatform(TemplatedPlatform):
if async_ff_sync._edge == "pos": if async_ff_sync._edge == "pos":
m.submodules += Instance("altera_std_synchronizer", m.submodules += Instance("altera_std_synchronizer",
p_depth=async_ff_sync._stages, 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_reset_n=~async_ff_sync.i,
i_din=Const(1), i_din=Const(1),
o_dout=sync_output, o_dout=sync_output,
@ -410,7 +410,7 @@ class IntelPlatform(TemplatedPlatform):
else: else:
m.submodules += Instance("altera_std_synchronizer", m.submodules += Instance("altera_std_synchronizer",
p_depth=async_ff_sync._stages, 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_reset_n=async_ff_sync.i,
i_din=Const(1), i_din=Const(1),
o_dout=sync_output, o_dout=sync_output,

View file

@ -613,7 +613,7 @@ class Xilinx7SeriesPlatform(TemplatedPlatform):
m.d.comb += ResetSignal("async_ff").eq(~async_ff_sync.i) m.d.comb += ResetSignal("async_ff").eq(~async_ff_sync.i)
m.d.comb += [ 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]) async_ff_sync.o.eq(flops[-1])
] ]

View file

@ -456,7 +456,7 @@ class XilinxSpartan3Or6Platform(TemplatedPlatform):
m.d.comb += ResetSignal("async_ff").eq(~async_ff_sync.i) m.d.comb += ResetSignal("async_ff").eq(~async_ff_sync.i)
m.d.comb += [ 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]) async_ff_sync.o.eq(flops[-1])
] ]

View file

@ -429,7 +429,7 @@ class XilinxUltraScalePlatform(TemplatedPlatform):
m.d.comb += ResetSignal("async_ff").eq(~async_ff_sync.i) m.d.comb += ResetSignal("async_ff").eq(~async_ff_sync.i)
m.d.comb += [ 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]) async_ff_sync.o.eq(flops[-1])
] ]