A half-duplex station loses frames on a long wire, and its own collision counter never moves. Find the first bad cycle, 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.
Station A shares a wire with station B. The wire is 22 octet times long, one way. A sends a short frame, and B starts a frame of its own just before A's signal reaches it.
The log says: ERROR: A reports its frame sent, but it met B's signal at B. The frame is lost.
Step 1: find the first cycle where one of A's signals differs from a correct transmitter, and name it. Step 2: choose the cause from four bugs. Each is real and fails at a different cycle.
Step 3 is optional: fix the transmitter and run the tests.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
test_number | 8 | input of each check |
Full specification
function automatic void tx_reset();
function automatic void tx_load(input int frame_octets); // DA to FCS, before padding
function automatic bit tx_tick(input bit carrier, input int r); // one octet time; r: the backoff draw in slots
| Rule | Correct transmitter (octet times) |
|---|---|
| Deference | wait while the wire is busy, then 12 quiet octet times (96 bit times). A bench rule: the standard restarts only the first part of the gap, and then transmits whatever the carrier |
| Packet | 8 octets of preamble and SFD, then the frame padded to at least 64 octets |
| Collision | carrier while sending: count it, send 4 octets of jam (32 bits) |
| Backoff | after the jam wait r × 64 octet times; r is the draw the bench passes in |
| Give up | after 16 collisions |
| state | 0 idle, 1 defer, 2 send, 3 jam, 4 backoff, 5 sent, 6 gave up |
Cycle N is the stretch where the cycle counter shows N. A signal is wrong in cycle N if its value there differs from a correct transmitter's.
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
A Quiet Wire- Input
random frames, long quiet stretches
- Output
wrong_ticks = 0, ticks_in_hundreds = 30, first_wrong_tick = 0
Every octet time, A's output, state and collision count must equal a correct transmitter's.
Example 2
A Busy Wire- Input
many short gaps, so many collisions
- Output
wrong_ticks = 0, ticks_in_hundreds = 60, first_wrong_tick = 0
Collisions, jams and backoffs happen often. Each must start and end on the right octet time.
Example 3
A Very Busy Wire- Input
nearly every gap short
- Output
wrong_ticks = 0, ticks_in_hundreds = 200, first_wrong_tick = 0
Some frames collide many times. The backoff range and the attempt limit both matter here.
Constraints and Contract
- Keep the three functions and the six variables.
- The bench calls tx_tick once per octet time with the carrier that A hears.
- Time is counted in octet times; one slot is 64.
- Off limits: the names
rng,tb,root, names that begin withref_and the modules of the bench.
Hints
Hint 1
How long should A's packet be for a 30-octet frame? In which cycle should it end?
Hint 2
When does B's signal reach A? Is A still sending then?
Hint 3
The slot is 64 octet times for a reason: compare it with the round trip of 44.
What the grader checks: The failing run is simulated live with the faulty transmitter. The first bad cycle and each option's symptom come from runs of each version on the same bench. The optional fix is checked against a private reference transmitter at every octet time. The tests cover 69,000 octet times of random traffic. They include a storm where nine frames collide 16 times; its draws are 7 slots at most. Octet-time units are a bench choice.
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 2 steps and the final capstone