
An 8-bit wide, 32-entry synchronous FIFO with four status flags: full, empty, almost-full and almost-empty.
WR_EN (uio[0]) is high on a rising clock edge and the FIFO is not full, the byte on ui[7:0] is stored.RD_EN (uio[1]) is high on a rising clock edge and the FIFO is not empty, the oldest byte appears on uo[7:0] just after that edge. uo[7:0] holds its value until the next read.| Flag | Pin | High when (count = bytes stored) |
|---|---|---|
FULL |
uio[2] | count = 32 |
EMPTY |
uio[3] | count = 0 |
ALMOST_FULL |
uio[4] | count >= 28 (4 or fewer free slots) |
ALMOST_EMPTY |
uio[5] | count <= 4 |
All four flags come from flip-flops and change on the same clock edge as the write or read that changes the count. ALMOST_FULL stays high while FULL is high, and ALMOST_EMPTY stays high while EMPTY is high.
rst_n passes through a 2-flop synchronizer. Hold it low for at least 3 clock cycles. After reset, EMPTY = 1, ALMOST_EMPTY = 1, FULL = 0, ALMOST_FULL = 0 and uo[7:0] = 0.
Inside, it uses one-hot read and write pointers and a 32-bit thermometer-coded occupancy register (bit k is 1 when more than k bytes are stored). Each flag is one bit of that register, so there is no counter or comparator. The storage is 256 plain flip-flops.
Use the demo board and step the clock manually from the RP2350, so that each write or read happens exactly once. Holding WR_EN high for N clock cycles writes N times.
rst_n low for a few clocks, then release it and give 2 more clocks. EMPTY = 1, ALMOST_EMPTY = 1, FULL = 0, ALMOST_FULL = 0.ui[7:0] to a byte, set WR_EN = 1, give one clock pulse, then set WR_EN = 0. Repeat for more bytes.
EMPTY goes to 0.ALMOST_EMPTY goes to 0.ALMOST_FULL goes to 1.FULL goes to 1.RD_EN = 1, give one clock pulse, then set RD_EN = 0. Read the byte on uo[7:0]. Bytes come out in the order they were written. The flags go back in the reverse order: FULL clears at 31 bytes, ALMOST_FULL at 27, ALMOST_EMPTY sets at 4, and EMPTY sets at 0.None. The demo board's DIP switches / RP2350 can drive the inputs, and the outputs can be read by the RP2350 or on the 7-segment display.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | DIN0 | DOUT0 | WR_EN (in) |
| 1 | DIN1 | DOUT1 | RD_EN (in) |
| 2 | DIN2 | DOUT2 | FULL (out) |
| 3 | DIN3 | DOUT3 | EMPTY (out) |
| 4 | DIN4 | DOUT4 | ALMOST_FULL (out) |
| 5 | DIN5 | DOUT5 | ALMOST_EMPTY (out) |
| 6 | DIN6 | DOUT6 | |
| 7 | DIN7 | DOUT7 |