Skip to content

Commit fca5931

Browse files
committed
BusSynchronizer: lengthen request path, rather than shortening data path, so that data path benefits from MCP/falsepath constraints from MultiReg.
1 parent f1dea5f commit fca5931

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

nmigen/lib/cdc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,9 @@ def elaborate(self, platform):
229229
ack_o = Signal()
230230
ack_i = Signal()
231231

232+
# Extra flop on i->o to avoid race between data and request
232233
sync_io = m.submodules.sync_io = \
233-
PulseSynchronizer(self.idomain, self.odomain, self.sync_stages)
234+
PulseSynchronizer(self.idomain, self.odomain, self.sync_stages + 1)
234235
sync_oi = m.submodules.sync_oi = \
235236
PulseSynchronizer(self.odomain, self.idomain, self.sync_stages)
236237

@@ -256,7 +257,7 @@ def elaborate(self, platform):
256257
with m.If(ack_i):
257258
m.d[self.idomain] += buf_i.eq(self.i)
258259
sync_data = m.submodules.sync_data = \
259-
MultiReg(buf_i, buf_o, odomain=self.odomain, n=self.sync_stages - 1)
260+
MultiReg(buf_i, buf_o, odomain=self.odomain, n=self.sync_stages)
260261
with m.If(ack_o):
261262
m.d[self.odomain] += self.o.eq(buf_o)
262263

nmigen/test/test_lib_cdc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ def process():
195195
for i in range(10):
196196
testval = i % (2 ** width)
197197
yield bs.i.eq(testval)
198-
# 6-cycle round trip, and if one in progress, must complete first:
199-
for j in range(11):
198+
# 7-cycle round trip, and if one in progress, must complete first:
199+
for j in range(13):
200200
yield Tick()
201201
self.assertEqual((yield bs.o), testval)
202202
sim.add_process(process)

0 commit comments

Comments
 (0)