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
| Signal | Width | Role |
|---|---|---|
test_number | 8 | input of each check |
Full specification
function automatic void rx_reset(); // before each packet
function automatic [8:0] rx_bit(input bit b); // one wire bit; returns {valid, octet}
| Part | Correct receiver |
|---|---|
| Preamble | Seven 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 delimiter | The 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 octets | The next bit is bit 0 of the first frame octet. Every octet arrives low bit first. |
rx_bit result | valid is 1 in the cycle of the eighth bit of a frame octet, with that octet. Otherwise the result is 0. |
| Signal | In each cycle |
|---|---|
| b | The bit on the wire. |
| in_frame | 1 once the delimiter is complete. |
| nb | Bits of the current octet received so far, after this bit. |
| octet, octets | The 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 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_resetis 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,rootand 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