Skip to content

Commit fe7c4df

Browse files
committed
serial: clear shreg for new byte
1 parent f64d8d7 commit fe7c4df

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

nmigen_stdio/serial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def elaborate(self, platform):
8181
with m.State("IDLE"):
8282
with m.If(~self.i):
8383
m.d.sync += [
84+
shreg.eq(Repl(0, len(shreg))),
8485
bits_left.eq(len(shreg) - 1),
8586
timer.eq(self.divisor >> 1)
8687
]
@@ -119,7 +120,7 @@ def elaborate(self, platform):
119120
# (useful for divisor == 0)
120121
with m.If(~self.i):
121122
m.d.sync += [
122-
shreg.eq(Cat(shreg[1:], self.i)),
123+
shreg.eq(Cat(Repl(0, len(shreg)-1), self.i)),
123124
bits_left.eq(len(shreg) - 2),
124125
timer.eq(self.divisor)
125126
]

0 commit comments

Comments
 (0)