Skip to content

Commit d973f00

Browse files
committed
serial: fix styling
1 parent 8e91edc commit d973f00

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

nmigen_stdio/serial.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,13 @@ def __init__(self, *, divisor, divisor_bits=None, data_bits=8, parity="none", pi
5959
self.r_rdy = Signal()
6060

6161
self.i = Signal(reset=1)
62-
6362
self._pins = pins
6463

6564
self.timer = Signal.like(self.divisor)
6665
self.shreg = Record(_wire_layout(len(self.data), self._parity))
6766
self.bits_left = Signal(range(len(self.shreg) + 1))
6867
self.done = Signal()
6968

70-
7169
def elaborate(self, platform):
7270
m = Module()
7371

@@ -161,19 +159,17 @@ def __init__(self, *, divisor, divisor_bits=None, data_bits=8, parity="none", pi
161159
self.w_done = Signal()
162160

163161
self.o = Signal(reset=1)
164-
165162
self._pins = pins
166-
163+
167164
self.timer = Signal.like(self.divisor)
168165
self.shreg = Record(_wire_layout(len(self.data), self._parity))
169166
self.bits_left = Signal(range(len(self.shreg) + 1))
170167

171-
172168
def elaborate(self, platform):
173169
m = Module()
174170

175171
timer = self.timer
176-
shreg = self.shreg
172+
shreg = self.shreg
177173
bits_left = self.bits_left
178174

179175
if self._pins is not None:

nmigen_stdio/test/test_serial.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ def test_err_frame(self):
8282

8383
def test_err_overflow(self):
8484
self.dut = AsyncSerialRX(divisor=7)
85+
8586
def process():
8687
self.assertFalse((yield self.dut.rdy))
8788
yield from self.tx_bits([0, 0,0,0,0,0,0,0,0, 1])
8889
yield from self.tx_period()
8990
self.assertFalse((yield self.dut.rdy))
9091
self.assertTrue((yield self.dut.err.overflow))
92+
9193
simulation_test(self.dut, process)
9294

9395

@@ -104,7 +106,7 @@ def process():
104106
yield self.dut.ack.eq(0)
105107
for _ in range(10):
106108
yield from self.tx_period()
107-
yield from self.tx_period() # Check 1 more period
109+
yield from self.tx_period() # Check 1 more period
108110
simulation_test(self.dut, process)
109111

110112
def test_8n1(self):
@@ -225,15 +227,15 @@ def elaborate(self, platform):
225227
Assert(rx_fsm.ongoing("DONE")),
226228
Assert(tx_fsm.ongoing("DONE"))
227229
]
228-
## RX r_rdy
230+
# RX r_rdy
229231
with m.If(Past(rx.busy, 2) & ~Stable(rx.busy, 1)):
230232
m.d.comb += Assert(rx.r_rdy)
231233
with m.If(Stable(rx.r_rdy) & rx.r_rdy):
232-
m.d.comb += Assert(Stable(rx.data) &
234+
m.d.comb += Assert(Stable(rx.data) &
233235
Stable(rx.err.overflow) &
234236
Stable(rx.err.frame) &
235237
Stable(rx.err.parity))
236-
## TX w_done
238+
# TX w_done
237239
with m.If(Past(tx.busy) & ~Stable(tx.busy)):
238240
m.d.comb += Assert(tx.w_done)
239241

@@ -243,7 +245,9 @@ def elaborate(self, platform):
243245
class AsyncSerialLoopbackTestCase(FHDLTestCase):
244246
def check_formal(self, *, divisor, data_bits, parity):
245247
depth = (divisor+1) * (data_bits+(3 if parity!="none" else 2) + 2)
246-
self.assertFormal(AsyncSerialLoopbackSpec(divisor=divisor, data_bits=data_bits, parity=parity),
248+
self.assertFormal(AsyncSerialLoopbackSpec(divisor=divisor,
249+
data_bits=data_bits,
250+
parity=parity),
247251
mode="bmc", depth=depth)
248252

249253
def test_all_div7(self):
@@ -290,18 +294,20 @@ def elaborate(self, platform):
290294
ResetSignal("sync").eq(0),
291295
ResetSignal("txclk").eq(0)
292296
]
293-
297+
294298
# Assumptions for TX
295299
fv_tx_bitstream_val = AnyConst(len_bitstream)
296300
# Assume the bitstream doesn't have 1-bit delay
297301
m.d.comb += Assume(fv_tx_bitstream_val[0] != 1)
298302
fv_tx_bitstream = Signal(len_bitstream+1)
299-
fv_tx_extra_bit = AnyConst(1) # A const bit representing the extra bit after the bitstream
300-
fv_tx_overflow = AnyConst(1) # A const flag to determine if the rx_fifo is always full
303+
fv_tx_extra_bit = AnyConst(1) # A const bit representing
304+
# the extra bit after the bitstream
305+
fv_tx_overflow = AnyConst(1) # A const flag to determine if
306+
# the rx_fifo is always full
301307
fv_tx_bitno = Signal(range(len(fv_tx_bitstream)+1))
302308
fv_tx_timer = Signal.like(rx.divisor)
303309
fv_rx_data = Signal(self.data_bits)
304-
#
310+
#
305311
fv_txfifo_num_bits = Signal(range(len(fv_tx_bitstream)+2))
306312
with m.FSM(domain="txclk") as txfifo_fsm:
307313
with m.State("WRITE-PREP"):
@@ -322,7 +328,7 @@ def elaborate(self, platform):
322328
m.d.txclk += txbit_fifo.w_en.eq(0)
323329
m.next = "DONE"
324330
txfifo_fsm.state.name = "fv_txfifo_fsm_state"
325-
#
331+
#
326332
fv_tx_extra_done = Signal()
327333
with m.FSM(domain="txclk") as tx_fsm:
328334
with m.State("TX-PREP"):
@@ -394,11 +400,11 @@ def elaborate(self, platform):
394400
# Assertions
395401
with m.If(Past(rx_fsm.state) == rx_fsm.encoding["CHECK"]):
396402
m.d.comb += Assert(rx_fsm.ongoing("DONE") | rx_fsm.ongoing("ERROR"))
397-
## RX r_rdy
403+
# RX r_rdy
398404
with m.If(Past(rx.busy, 2) & ~Stable(rx.busy, 1)):
399405
m.d.comb += Assert(rx.r_rdy)
400406
with m.If(Stable(rx.r_rdy) & rx.r_rdy):
401-
m.d.comb += Assert(Stable(rx.data) &
407+
m.d.comb += Assert(Stable(rx.data) &
402408
Stable(rx.err.overflow) &
403409
Stable(rx.err.frame) &
404410
Stable(rx.err.parity))
@@ -454,7 +460,9 @@ def elaborate(self, platform):
454460
class AsyncSerialBitstreamTestCase(FHDLTestCase):
455461
def check_formal(self, *, divisor, data_bits, parity):
456462
depth = (divisor+1) * (data_bits+(3 if parity!="none" else 2) + 2)
457-
self.assertFormal(AsyncSerialBitstreamSpec(divisor=divisor, data_bits=data_bits, parity=parity),
463+
self.assertFormal(AsyncSerialBitstreamSpec(divisor=divisor,
464+
data_bits=data_bits,
465+
parity=parity),
458466
mode="bmc", depth=depth)
459467

460468
def test_all_div7(self):

0 commit comments

Comments
 (0)