RTL Design #10 · 2026-10-03 · Flow control · Medium · about 15 min

A credit counter that leaks credits

credit_counter is the sender's side of credit-based flow control. The receiver has 4 buffer slots, and credits is how many of them the sender knows to be free.

  • send is send_req whenever credits is not 0. It looks only at the registered count: a credit returned in this cycle can't be spent until the next one.
  • Every cycle with send high spends one credit. Every cycle with credit_ret high gives one back. Both can happen in the same cycle.
  • Reset sets credits to 4. The receiver never returns a credit that wasn't spent, so credits never needs to go above 4.

A burst of beats goes through fine. Under steady traffic the link slows down and finally stops, with the receiver's buffer empty. Fix credit.sv.

Write and run your answer in the browser. The hidden tests check it, and it’s free.