P10.14.1 Stop the Credit Leak

MediumFixIcarus · browser samples / server checksReview the topic

A link runs for a while, then the transmitter stops for good. Fix its credit counter so that lost updates no longer leak credits.

Hardware context: The digital blocks of a serializer/deserializer: line encoder and decoder, scrambler, CRC and error-correcting code. Keep the line balanced and busy, and detect or correct the errors a fast serial link makes.

This is a Fix problem. The transmitter in the editor keeps a credit count and adds one for every credit update. After a while it stops sending and never starts again.

The receiver has 8 slots and frees one every 4 cycles. Each update it sends carries a running limit: 8 plus every packet it has freed so far. The field is 8 bits wide, so the limit wraps at 256.

About 2 updates in 100 are lost on the way. Repair the four functions so the transmitter never overflows the receiver and never stalls while it may send.

The fixture runs a second copy of the link with the same lost updates. A transmitter that obeys the running limit drives it. Yours must send exactly as many packets.

Signals in the Timeline

SignalWidthRole
test_number8input of each check
Full specification
Signatures (keep them)
function automatic void tx_reset();
function automatic void tx_update(input [7:0] value);   // the running limit, modulo 256
function automatic bit tx_can_send();
function automatic void tx_send();                      // called once per packet sent
ItemRule (bench values)
Receiver8 slots. One packet is freed every 4 cycles when it holds any.
LinkA packet or an update takes 3 cycles to cross, plus the cycle it is sent in.
UpdateSent each time a slot is freed. It carries (8 + slots freed so far) modulo 256. Some are lost.
Order in a cycleArrivals first, then a slot may be freed, then tx_can_send() is asked once; if it says 1, a packet goes and tx_send() is called.
StartAfter tx_reset() the receiver is empty: 8 packets may go before any update arrives.

The tests run up to 20,000 cycles, long enough for the limit to wrap many times. They report overflows and how many packets you sent short of the running-limit transmitter.

Examples

Example 1

No Updates Lost
Input
no loss; 4,000 cycles
Output
overflows = 0, packets_short = 0

With nothing lost, "+1" and the running limit agree. Your transmitter sends as many packets as the reference and nothing overflows.

Example 2

2 Updates in 100 Lost
Input
20 per thousand lost; 20,000 cycles
Output
overflows = 0, packets_short = 0

Every lost "+1" update takes a credit with it. After 8 are gone the transmitter stops. A running limit loses nothing: the next update covers the lost one.

Example 3

2 In 100, Another Seed
Input
20 per thousand lost; 20,000 cycles
Output
overflows = 0, packets_short = 0

Over 20,000 cycles about 5,000 packets are sent, so the 8-bit limit wraps about 20 times. A comparison that ignores the wrap stalls at the first one.

Constraints and Contract

  • Keep the four function names and their arguments.
  • Keep SLOTS = 8.
  • Decide only from what the functions receive; the fixture's state is not yours to read.

Hints

Hint 1

What does the transmitter lose for ever when one "+1" update goes missing?

Hint 2

The update already tells you the whole story: how many packets you may have sent in all. Keep a count of what you have sent, and compare.

Hint 3

The limit wraps at 256 but your count may not. Keep both 8 bits wide and look at their difference, which wraps too.

What the grader checks: The fixture runs your transmitter on six bench links beside a running-limit transmitter with the same lost updates. It counts overflows and the packets sent short. It does not model credit types, initial advertisement or Recovery.

6 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 1 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

No Updates Lost

Input
no loss; 4,000 cycles
Expected output
overflows = 0, packets_short = 0

With nothing lost, "+1" and the running limit agree. Your transmitter sends as many packets as the reference and nothing overflows.

Run samples executes all 3 public checks. Check all tests runs 6 checks on the server.

Icarus · browser samples / server checks