diff options
| author | Julian Blake Kongslie | 2021-03-24 08:35:07 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2021-03-24 08:50:57 -0700 |
| commit | 5c1df6d27f5dac143efc9ce84689b863dbee45bd (patch) | |
| tree | 9bb9c9bcab00e7d5a5d1b40467d8e5a810f0b706 /jtag_uart.sv | |
| parent | Clean before building. (diff) | |
| download | toycpu-5c1df6d27f5dac143efc9ce84689b863dbee45bd.tar.xz | |
Reorganize repo layout to make it a little easier to work within.
Diffstat (limited to 'jtag_uart.sv')
| -rw-r--r-- | jtag_uart.sv | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/jtag_uart.sv b/jtag_uart.sv deleted file mode 100644 index 5c4857d..0000000 --- a/jtag_uart.sv +++ /dev/null | |||
| @@ -1,84 +0,0 @@ | |||
| 1 | `include "utils.svh" | ||
| 2 | |||
| 3 | module jtag_uart | ||
| 4 | #( INSTANCE = 0 | ||
| 5 | |||
| 6 | , RX_FIFO_BITS = 6 | ||
| 7 | , TX_FIFO_BITS = 6 | ||
| 8 | ) | ||
| 9 | ( input bit clk | ||
| 10 | , input bit reset | ||
| 11 | |||
| 12 | , input bit rx_ready `define rx_ready `past(rx_ready) | ||
| 13 | , output bit rx_valid | ||
| 14 | , output bit [7:0] rx_data | ||
| 15 | |||
| 16 | , output bit tx_ready | ||
| 17 | , input bit tx_valid `define tx_valid `past(tx_valid) | ||
| 18 | , input bit [7:0] tx_data `define tx_data `past(tx_data) | ||
| 19 | ); | ||
| 20 | |||
| 21 | `ifdef SYNTHESIS | ||
| 22 | |||
| 23 | alt_jtag_atlantic | ||
| 24 | #( .INSTANCE_ID(INSTANCE) | ||
| 25 | , .LOG2_RXFIFO_DEPTH(RX_FIFO_BITS) | ||
| 26 | , .LOG2_TXFIFO_DEPTH(TX_FIFO_BITS) | ||
| 27 | , .SLD_AUTO_INSTANCE_INDEX("NO") | ||
| 28 | ) real_jtag | ||
| 29 | ( .clk(clk) | ||
| 30 | , .rst_n(!reset) | ||
| 31 | , .r_dat(tx_data) | ||
| 32 | , .r_val(tx_valid) | ||
| 33 | , .r_ena(tx_ready) | ||
| 34 | , .t_dat(rx_data) | ||
| 35 | , .t_dav(rx_ready) | ||
| 36 | , .t_ena(rx_valid) | ||
| 37 | ); | ||
| 38 | |||
| 39 | `else | ||
| 40 | |||
| 41 | bit [7:0] sim_rx_rom [0:(1<<16)-1]; | ||
| 42 | initial $readmemh("jtag_uart.hex", sim_rx_rom); | ||
| 43 | |||
| 44 | bit [15:0] sim_rx_addr; | ||
| 45 | |||
| 46 | bit tx_b_valid; | ||
| 47 | bit [7:0] tx_b_data; | ||
| 48 | |||
| 49 | always_ff @(posedge clk) begin | ||
| 50 | if (reset) begin | ||
| 51 | rx_valid = 0; | ||
| 52 | tx_ready = 0; | ||
| 53 | sim_rx_addr = 0; | ||
| 54 | tx_b_valid = 0; | ||
| 55 | end else begin | ||
| 56 | automatic bit [7:0] sim_rx_data = sim_rx_rom[sim_rx_addr]; | ||
| 57 | |||
| 58 | // RX logic | ||
| 59 | if (`rx_ready) rx_valid = 0; | ||
| 60 | if (!rx_valid && (sim_rx_data != 0)) begin | ||
| 61 | `ifdef JTAG_UART_LOCAL_ECHO | ||
| 62 | $write("%s", sim_rx_data); | ||
| 63 | `endif | ||
| 64 | rx_valid = 1; | ||
| 65 | rx_data = sim_rx_data; | ||
| 66 | sim_rx_addr = sim_rx_addr + 1; | ||
| 67 | end | ||
| 68 | |||
| 69 | // TX logic | ||
| 70 | if (tx_ready && `tx_valid) begin | ||
| 71 | tx_b_valid = 1; | ||
| 72 | tx_b_data = `tx_data; | ||
| 73 | end | ||
| 74 | if (tx_b_valid) begin | ||
| 75 | $write("%s", tx_b_data); | ||
| 76 | tx_b_valid = 0; | ||
| 77 | end | ||
| 78 | tx_ready = !tx_b_valid; | ||
| 79 | end | ||
| 80 | end | ||
| 81 | |||
| 82 | `endif | ||
| 83 | |||
| 84 | endmodule | ||
