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.
sendissend_reqwhenevercreditsis 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
sendhigh spends one credit. Every cycle withcredit_rethigh gives one back. Both can happen in the same cycle. - Reset sets
creditsto 4. The receiver never returns a credit that wasn't spent, socreditsnever 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.