diff options
| author | Julian Blake Kongslie | 2022-05-08 17:20:57 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-05-08 17:20:57 -0700 |
| commit | 1a47b552cca074b47c048c3428c92dfb2e3f23b1 (patch) | |
| tree | 37d07aa6bab97faf2f329d05edf5f0fe21cda085 /hdl | |
| parent | *Proper* serial port for memory downloads. 115200 8O2 RS232 with CRTRTS. (diff) | |
| download | multipdp8-1a47b552cca074b47c048c3428c92dfb2e3f23b1.tar.xz | |
Demand that CTS is asserted for multiple symbol periods before transmit.
Diffstat (limited to 'hdl')
| -rw-r--r-- | hdl/rs232.sv | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/hdl/rs232.sv b/hdl/rs232.sv index ef53f12..2949201 100644 --- a/hdl/rs232.sv +++ b/hdl/rs232.sv | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | module rs232_tx | 3 | module rs232_tx |
| 4 | #( PARITY = 0 | 4 | #( PARITY = 0 |
| 5 | , STOP_BITS = 2 | 5 | , STOP_BITS = 2 |
| 6 | , CTS_BITS = 3 | ||
| 6 | ) | 7 | ) |
| 7 | ( input bit clock | 8 | ( input bit clock |
| 8 | , input bit reset | 9 | , input bit reset |
| @@ -29,6 +30,8 @@ module rs232_tx | |||
| 29 | bit [$clog2($bits(uart_byte_t)):0] data_bits; | 30 | bit [$clog2($bits(uart_byte_t)):0] data_bits; |
| 30 | bit [$clog2(STOP_BITS):0] stop_bits; | 31 | bit [$clog2(STOP_BITS):0] stop_bits; |
| 31 | 32 | ||
| 33 | bit [CTS_BITS-1:0] cts_samples; | ||
| 34 | |||
| 32 | always @(posedge clock, posedge reset) begin | 35 | always @(posedge clock, posedge reset) begin |
| 33 | if (reset) begin | 36 | if (reset) begin |
| 34 | out_ready = 0; | 37 | out_ready = 0; |
| @@ -38,6 +41,7 @@ module rs232_tx | |||
| 38 | state = state.first; | 41 | state = state.first; |
| 39 | data_bits = 0; | 42 | data_bits = 0; |
| 40 | stop_bits = 0; | 43 | stop_bits = 0; |
| 44 | cts_samples = 0; | ||
| 41 | end else begin | 45 | end else begin |
| 42 | if (out_ready && out_valid) begin | 46 | if (out_ready && out_valid) begin |
| 43 | hold_valid = 1; | 47 | hold_valid = 1; |
| @@ -48,11 +52,14 @@ module rs232_tx | |||
| 48 | stop_bits = 0; | 52 | stop_bits = 0; |
| 49 | end | 53 | end |
| 50 | 54 | ||
| 55 | cts_samples = cts_samples << 1; | ||
| 56 | cts_samples[0] = cts; | ||
| 57 | |||
| 51 | if (hold_valid) begin | 58 | if (hold_valid) begin |
| 52 | case (state) | 59 | case (state) |
| 53 | 60 | ||
| 54 | START: begin | 61 | START: begin |
| 55 | if (!cts) begin | 62 | if (cts_samples == 0) begin |
| 56 | tx = 0; | 63 | tx = 0; |
| 57 | state = state.next; | 64 | state = state.next; |
| 58 | end | 65 | end |
