Home › Practice › RTL Design › Credits: never overflow the receiver
Credits: never overflow the receiver
EasyRTLsequentialarchitecture
A sender pushes messages into a receiver that has only four buffer slots. If the sender talks too fast, messages are lost. How does the sender know when it is safe to send?
Concept first. In credit-based flow control the sender keeps a count of how many free slots the receiver has: the credits. Sending a message uses one credit. When the receiver frees a slot, it sends one credit back. The sender may only send while the count is above 0, so the receiver can never overflow and nothing is dropped. The count starts equal to the size of the receiver's buffer. Think about what happens when a send and a returned credit arrive in the same cycle, and what happens to requests that should not be counted at all (a send with no credits, a returned credit when the count is already full).
What to build.
- Ports:
clk, rst, send, ret; outputscnt[2:0]andcan_send. rstis synchronous, active-high:cntbecomes 4.- A
sendcounts only whencntis not 0. Aretcounts only whencntis not 4. - On a rising edge: if both count,
cntdoes not change; if only a send counts,cntgoes down by 1; if only a return counts, it goes up by 1. can_sendis 1 whencntis not 0 (it followscntdirectly).
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.