P11.3.1 Debug the Receiver That Drops Every Frame

MediumDebugIcarus Verilog · serverReview the topic

A bit-serial receiver delivers nothing, and no error counter moves. Find the first cycle where it went wrong, and name the bug.

Hardware context: An Ethernet MAC and physical coding sublayer: frame builder and checker, reconciliation sublayer and block encoder. Build, check and pace Ethernet frames, and code them for the physical layer as IEEE 802.3 specifies.

A new receiver is connected to a working sender. Frames go in and nothing comes out. The log says: ERROR: 0 frame octets received, expected 6.

Run the failing test to see its log and waveform. Each cycle is one bit on the wire. The sender transmits the preamble, the start frame delimiter and six address octets.

Step 1: find the first cycle where a receiver signal shows the wrong value, and name that signal. The error line at the end is where the problem surfaced, not where it started.

Step 2: choose the cause from four possible bugs. Each is a real bug that fails at a different cycle. Step 3 is optional: fix the receiver in the editor and run the tests.

Signals in the Timeline

SignalWidthRole
test_number8input of each check
Full specification
The receiver API
function automatic void rx_reset();                 // before each packet
function automatic [8:0] rx_bit(input bit b);       // one wire bit; returns {valid, octet}
PartCorrect receiver
PreambleSeven octets of 55h. Low bit first, so the wire shows 1, 0, 1, 0 and so on. Some of its first bits may be missing, and stray bits may come before it.
Start frame delimiterThe wire bits 1, 0, 1, 0, 1, 0, 1, 1 in that order. in_frame goes to 1 in the cycle of the last of them.
Frame octetsThe next bit is bit 0 of the first frame octet. Every octet arrives low bit first.
rx_bit resultvalid is 1 in the cycle of the eighth bit of a frame octet, with that octet. Otherwise the result is 0.
SignalIn each cycle
bThe bit on the wire.
in_frame1 once the delimiter is complete.
nbBits of the current octet received so far, after this bit.
octet, octetsThe last complete frame octet, and how many are complete.

Cycle N is the stretch where the cycle counter shows N. Cycle 1 carries the first preamble bit. A signal is wrong in cycle N if its value there differs from what a correct receiver shows.

Diagnose the Failing Run

The test below runs the buggy design. Read its log, then find where it first goes wrong in the waveform.

Log

Waveform

Click a signal at a cycle to select it. Or focus the waveform and use the arrow keys: Left and Right move one cycle, Up and Down one signal.

Step 1 · The first bad cycle and signal
Step 2 · The cause

Step 3 is optional: fix the code in the editor, then run the tests.

Examples

Example 1

Whole Packets
Input
30 packets with all 64 bits of preamble and delimiter
Output
wrong_frames = 0, frames_sent = 30, first_wrong_frame = 0

The delimiter completes at bit 64. Every frame octet after it must match the sender, in order.

Example 2

Idle Line Before the Packet
Input
5 zero bits, then each packet
Output
wrong_frames = 0, frames_sent = 30, first_wrong_frame = 0

The zeros must not start a frame. The delimiter then completes at bit 69.

Example 3

Preamble Bits Lost
Input
packets whose first bits are missing
Output
wrong_frames = 0, frames_sent = 30, first_wrong_frame = 0

A receiver that slides over the bits still finds the delimiter, because only its eight bits matter.

Constraints and Contract

  • Keep the two function names and their arguments.
  • Bits arrive one at a time, in order. rx_reset is called before each packet.
  • A frame ends when the caller stops; the receiver need not detect the end.
  • Off limits: the names lib, rng, tb, root and the modules of the bench.

Hints

Hint 1

How many bits do the preamble and the delimiter have together? In which cycle should in_frame rise?

Hint 2

Write down the last eight wire bits at that cycle, oldest first. Compare them with the constant in the code.

Hint 3

The register shifts new bits in at bit 0. Which end of it holds the first bit of the delimiter?

What the grader checks: The failing run is simulated live with the faulty receiver. The fixture simulates the correct and each faulty receiver on the same packet. The first bad cycle and each option's first wrong value come from those runs. The optional fix is checked on 210 seeded frames against the bench library. In 60 of them, stray idle bits hold 11 or 101011 before the preamble.

6 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. 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

Whole Packets

Input
30 packets with all 64 bits of preamble and delimiter
Expected output
wrong_frames = 0, frames_sent = 30, first_wrong_frame = 0

The delimiter completes at bit 64. Every frame octet after it must match the sender, in order.

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

Icarus Verilog · server