jbush001 / NyuziProcessor

GPGPU microprocessor architecture
Apache License 2.0
1.99k stars 351 forks source link

Support hardware flow control in UART #150

Open jbush001 opened 6 years ago

jbush001 commented 6 years ago

RTS/CTS are not connected. This doesn't seem to have been a problem so far, since most USB->Serial converts have a large buffer and USB is faster than serial. On the host->device direction, the software download cases read data in a tight loop, so it's not really possible to overrun the FIFO. However, there may be other test cases where this would become a problem.

Alternatively, it might be easier to pull in a proper UART implementation from somewhere else (which may b made easier by #38).

This is an FPGA test harness improvement and is not part of Nyuzi proper.

jbush001 commented 6 years ago

RTS(RTR) is active low. This is fairly easy to implement, but would require a bit more work to test in simulation:

  1. In uart.sv, when reading STATUS_REG, tx_ready is used to indicate the sender can transmit. This should be && !rts
  2. The CTS output should be connected to rx_fifo_full.
travisg commented 6 years ago

Also remember that bug that a particular vendor had where it would stop transmitting in the middle of the character if the receiver dropped CTS in the middle of it? IIRC the spec says that you sample the CTS of the other side before starting the character, but then commit to sending it.

jbush001 commented 6 years ago

Haha... yes, I remember that all too well. :) This proposal actually doesn't control transmission, it just sets the status bit to indicate it's not ready. If software ignored that, it could start transmission anyway. But once it has started transmitting a character, it always finishes before checking for the next (controlled by the shift_count variable):

https://github.com/jbush001/NyuziProcessor/blob/beb8c7f6233da1a38da1b5c47fb6fbc6e13f6207/hardware/fpga/common/uart_transmit.sv#L39-L74

I'm not especially proud of this implementation; it's pretty quick and dirty. However, I've seen the RTL for some production chips and it's even worse. :)