A UART transmitter fails on some seeds of a random test, each in a different-looking way. Find the first bad cycle and signal, name the one bug behind them, and fix it.
Hardware context: The UART transmitter under eight seeds of random bytes and gaps. Writing a bug report someone else can replay.
The bench runs three seeds. Each sends five random bytes with a random gap of idle clocks before each one, then compares what a receiver model collected. It also checks that busy rises after every start.
Run the failing test below and read its log and its waveform. Before you debug, put the failing seeds side by side and look for what they share.
Step 1: find the first cycle where busy or tx is not what the specification says, and name the signal. Step 2: choose the cause. Step 3, optional: fix uart_tx; the fix is graded by the normal rows.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
scenario | 8 | input of each check |
Full specification
// uart_tx: sends one byte as a frame: a start bit (0), eight data bits low bit first, a stop bit (1).
// Each bit lasts 4 clocks. start is taken whenever busy is 0; data is read in the same clock.
module uart_tx (input logic clk, rst, start, input logic [7:0] data, output logic tx, busy);
...
endmodule
busy rises in the clock after a start is taken and falls after the stop bit. A start is taken in any clock in which busy is 0, including the first clock after busy falls. Cycle N is the stretch after the N-th falling edge of the bench's clock.
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
Two Bytes with Idle Time Between Them- Input
29 after 6 idle, 5a after 6 idle
- Output
bytes = 2, frame_errors = 0, byte1 = 0x29, byte2 = 0x5a, byte3 = 0x0, byte4 = 0x0
Two bytes with six idle clocks before each: both arrive, no frame errors.
Example 2
Two Bytes Back to Back: No Idle Clock- Input
0f after 0 idle, f0 after 0 idle
- Output
bytes = 2, frame_errors = 0, byte1 = 0xf, byte2 = 0xf0, byte3 = 0x0, byte4 = 0x0
A byte sent in the very first clock after busy falls must be taken too.
Example 3
Bytes with the High Bit Set- Input
80 after 2 idle, ff after 3 idle, 7f after 1 idle
- Output
bytes = 3, frame_errors = 0, byte1 = 0x80, byte2 = 0xff, byte3 = 0x7f, byte4 = 0x0
Bit 7 travels last in a frame; every bit of the byte must arrive.
Constraints and Contract
- Keep the module name and the ports.
- Each bit lasts 4 clocks; reset is synchronous and active high.
Hints
Hint 1
Which gap did each failing byte have before it?
Hint 2
Each cause shows first in a different cycle or on a different signal: watch busy as well as tx.
Hint 3
Read how the design decides that it may take a start.
What the grader checks: The failing run is simulated live with the shipped transmitter. The fix is graded on five scripts of bytes and gaps, each after reset. Each row reports what a receiver model collected: bytes, frame errors and the first four bytes.
5 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 2 problems on this path