diff options
author | Tim Newsome <tim@sifive.com> | 2017-02-06 19:17:23 -0800 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2017-02-06 19:17:23 -0800 |
commit | 4695be7cea868b34082787d5728c35577d0c05d1 (patch) | |
tree | b9d730b3955e924e0b198ccc6c7d5014d06817f9 /riscv/jtag_dtm.cc | |
parent | 9be157042081e894e6c12dc96449cf865469bcfe (diff) | |
download | spike-4695be7cea868b34082787d5728c35577d0c05d1.zip spike-4695be7cea868b34082787d5728c35577d0c05d1.tar.gz spike-4695be7cea868b34082787d5728c35577d0c05d1.tar.bz2 |
Refactor remote bitbang code.
Diffstat (limited to 'riscv/jtag_dtm.cc')
-rw-r--r-- | riscv/jtag_dtm.cc | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/riscv/jtag_dtm.cc b/riscv/jtag_dtm.cc new file mode 100644 index 0000000..c099e33 --- /dev/null +++ b/riscv/jtag_dtm.cc @@ -0,0 +1,81 @@ +#include <stdio.h> + +#include "jtag_dtm.h" + +#if 1 +# define D(x) x +#else +# define D(x) +#endif + +void jtag_dtm_t::set_pins(bool tck, bool tms, bool tdi) { + if (!_tck && tck) { + // Positive clock edge. + + switch (state) { + case SHIFT_DR: + dr >>= 1; + dr |= (uint64_t) _tdi << (dr_length-1); + break; + case SHIFT_IR: + ir >>= 1; + ir |= _tdi << (ir_length-1); + break; + default: + break; + } + state = next[state][_tms]; + switch (state) { + case TEST_LOGIC_RESET: + ir = idcode_ir; + break; + case CAPTURE_DR: + capture_dr(); + break; + case SHIFT_DR: + _tdo = dr & 1; + break; + case UPDATE_DR: + update_dr(); + break; + case CAPTURE_IR: + break; + case SHIFT_IR: + _tdo = ir & 1; + break; + case UPDATE_IR: + break; + default: + break; + } + } + + _tck = tck; + _tms = tms; + _tdi = tdi; + + D(fprintf(stderr, "state=%2d tck=%d tms=%d tdi=%d tdo=%d ir=0x%x dr=0x%lx\n", + state, _tck, _tms, _tdi, _tdo, ir, dr)); +} + +void jtag_dtm_t::capture_dr() +{ + switch (ir) { + case idcode_ir: + dr = 0xdeadbeef; + dr_length = 32; + break; + case dtmcontrol_ir: + dr = dtmcontrol; + dr_length = 32; + default: + D(fprintf(stderr, "Unsupported IR: 0x%x\n", ir)); + break; + } + D(fprintf(stderr, "Capture DR; IR=0x%x, DR=0x%lx (%d bits)\n", + ir, dr, dr_length)); +} + +void jtag_dtm_t::update_dr() +{ +} |