public turnaround_cmd: turnaround_bitloop: nop [1] side 0x0 jmp x-- turnaround_bitloop [1] side 0x1 jmp get_next_cmd
public write_cmd: pull public short_write_cmd: write_bitloop: out pins, 1 [1] side 0x2 ; Data is output by host on negedge jmp x-- write_bitloop [1] side 0x3 ; ...and captured by target on posedge ; Fall through to next command .wrap_target public get_next_cmd: pull side 0x0 ; SWCLK initially low, OEn disabled out x, 7 ; Get bit count out pc, 5 ; Go to command routine
read_bitloop: nop ; Additional delay on taken loop branch public read_cmd: in pins, 1 [1] side 0x1 ; Data is captured by host on posedge jmp x-- read_bitloop side 0x0 push jmp get_next_cmd ; Fall through to next command
; JTAG commands. TMS shares the SWD_DO pin (set pin group, base configured per mode ; on the C side), TDI is driven by the out pin group (same base), TDO is sampled by ; the in pin group. Sideset bit 1 = DOE must stay 1, otherwise the external buffer ; goes high-Z and TMS cannot be driven. public jtag_tms_lo_cmd: set pins, 0 side 0x2 ; DOE=1, TCK=0 jmp get_next_cmd
public jtag_tms_hi_cmd: set pins, 1 side 0x2 jmp get_next_cmd
; TMS sequence: after "set", "out pc, 5" loads the entry address of the next beat ; (a 5-bit field in the command word), so one FIFO command chains 1 to 4 beats of ; "TMS + clock" without dispatching a command on every beat. public jtag_tms_seq_lo_cmd: set pins, 0 [1] side 0x2 ; 2 cycles: TMS=0, TCK low out pc, 5 [1] side 0x3 ; 2 cycles: load next entry, TCK high
public jtag_tms_seq_hi_cmd: set pins, 1 [1] side 0x2 out pc, 5 [1] side 0x3
public jtag_rw_cmd: pull ; second FIFO word carries TDI data public jtag_rw_short_cmd: ; TDI inlined in command word [31:12] jtag_rw_bitloop: out pins, 1 [1] side 0x2 ; 2 cycles: TCK low, shift out one TDI bit in pins, 1 side 0x3 ; 1 cycle: TCK high, sample TDO jmp x-- jtag_rw_bitloop side 0x2 ; 1 cycle: TCK low, gives TDO 3 cycles to settle push .wrap