Prevent extra bit transition at end of data

The initial bit transition would be set even if the queue stalled.
The state machine still takes 16 cycles per bit
The next bit starts on state 1 and 9 instead of 0 and 8 so the timing is the same as before
This commit is contained in:
Tom Messick 2021-04-21 13:42:57 -07:00 committed by Luke Wren
parent 612469d347
commit 4f64f3af80

View File

@ -7,7 +7,7 @@
.program differential_manchester_tx .program differential_manchester_tx
.side_set 1 opt .side_set 1 opt
; Transmit one bit every cycles. In each bit period: ; Transmit one bit every 16 cycles. In each bit period:
; - A '0' is encoded as a transition at the start of the bit period ; - A '0' is encoded as a transition at the start of the bit period
; - A '1' is encoded as a transition at the start *and* in the middle ; - A '1' is encoded as a transition at the start *and* in the middle
; ;
@ -16,19 +16,21 @@
public start: public start:
initial_high: initial_high:
out x, 1 side 1 ; Start of bit period: always assert transition out x, 1 ; Start of bit period: always assert transition
jmp !x high_0 [6] ; Test the data bit we just shifted out of OSR jmp !x high_0 side 1 [6] ; Test the data bit we just shifted out of OSR
high_1: high_1:
jmp initial_high side 0 [7] ; For `1` bits, also transition in the middle nop
jmp initial_high side 0 [6] ; For `1` bits, also transition in the middle
high_0: high_0:
jmp initial_low [7] ; Otherwise, the line is stable in the middle jmp initial_low [7] ; Otherwise, the line is stable in the middle
initial_low: initial_low:
out x, 1 side 0 ; Always shift 1 bit from OSR to X so we can out x, 1 ; Always shift 1 bit from OSR to X so we can
jmp !x low_0 [6] ; branch on it. Autopull refills OSR for us. jmp !x low_0 side 0 [6] ; branch on it. Autopull refills OSR for us.
low_1: low_1:
jmp initial_low side 1 [7] ; If there are two transitions, return to nop
low_0: ; initial_low on the next bit. If just one, jmp initial_low side 1 [6] ; If there are two transitions, return to
low_0:
jmp initial_high [7] ; the initial line state is flipped! jmp initial_high [7] ; the initial line state is flipped!
% c-sdk { % c-sdk {