File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -182,13 +182,21 @@ def elaborate(self, platform):
182
182
m .d .sync += [
183
183
self .o .eq (0 ), # Issue start bit ASAP
184
184
shreg .start .eq (0 ),
185
- shreg .data .eq (self .data ),
186
185
shreg .parity .eq (_compute_parity_bit (self .data , self ._parity )),
187
186
shreg .stop .eq (1 ),
188
187
bits_left .eq (len (self .shreg )),
189
188
timer .eq (self .divisor )
190
189
]
191
- m .next = "BUSY"
190
+ m .next = "LATCH-DATA"
191
+
192
+ with m .State ("LATCH-DATA" ):
193
+ # Since the data is valid only when ACK is high,
194
+ # only latch the data now such that it is from the first clock since ACK is high
195
+ m .d .sync += [
196
+ shreg .data .eq (self .data ),
197
+ timer .eq (timer - 1 )
198
+ ]
199
+ m .next = "BUSY"
192
200
193
201
with m .State ("BUSY" ):
194
202
with m .If (timer != 0 ):
@@ -216,13 +224,12 @@ def elaborate(self, platform):
216
224
m .d .sync += [
217
225
self .o .eq (0 ), # Issue start bit ASAP
218
226
shreg .start .eq (0 ),
219
- shreg .data .eq (self .data ),
220
227
shreg .parity .eq (_compute_parity_bit (self .data , self ._parity )),
221
228
shreg .stop .eq (1 ),
222
229
bits_left .eq (len (self .shreg )),
223
230
timer .eq (self .divisor )
224
231
]
225
- m .next = "BUSY "
232
+ m .next = "LATCH-DATA "
226
233
# Set back to IDLE if ACK is low
227
234
with m .Else ():
228
235
m .d .sync += self .o .eq (1 )
You can’t perform that action at this time.
0 commit comments