adumont / hrm-cpu

Human Resource Machine - CPU Design #HRM
https://twitter.com/i/moments/1017515777610649601
GNU General Public License v3.0
71 stars 8 forks source link

Review what happens when OUTBOX is full #26

Closed adumont closed 5 years ago

adumont commented 5 years ago

When OUTBOX is full, FSM waits (#12). Confirm that when we pop an item out (cpu_out_rd=1):

adumont commented 5 years ago

try using w_full_n instead of o_err as FIFO full flag. (note: w_full_n doesn't seem to be negative logic deespite the _n... It becomes 1 when the FIFO gets full, and 0 again when it gets freed).

adumont commented 5 years ago

Also review https://github.com/ZipCPU/wbuart32/issues/3#issuecomment-474648527 :

you are using the wrong signal to know if the FIFO is full or now. The err signal is set if you actually overflow the FIFO, and then cleared when you reset the FIFO to acknowledge the error--just as you noticed.

To know if the FIFO is actually full, you need to check the bottom bit of the status register, o_status. On a receive FIFO, where RXFIFO == 1'b1, this will be true if anything is within the FIFO that may then be read. For a transmit FIFO, where RXFIFO == 1'b0, this will be true if the FIFO is not full and so something may be written to the FIFO.

Alternatively, bits [11:2] contain the number of items in the FIFO. You can use those as well to check if the FIFO is full. In other words, when ((status & 0xffc) == 0xffc) you also know that the FIFO is full.

adumont commented 5 years ago

df9ecc0072b712f4f27fd8030bb5ccec6e69c4cb seems to fix the problem.