A test sends one byte through a small UART transmitter, which sends a byte one bit at a time on one wire. It never sees busy fall. Its time limit turns the hang into a failure. Find the first cycle the transmitter goes wrong, name the bug, and fix it.
Hardware context: The end-of-test logic of a bench, and a small UART transmitter that may never finish. The end-of-test logic of a block bench.
Without a time limit this run would wait for ever. The bench gives busy 100 clocks to fall after the frame should have ended, then stops with a timeout error. That line says the design never finished. It does not say why.
Step 1: find the first cycle where tx or busy breaks the specification, and name the signal. Step 2: choose the cause. Step 3, optional: fix the transmitter; the fix is graded by the normal cases.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
scenario | 4 | input of each check |
Full specification
// A small UART transmitter. When start is 1 and busy is 0, it takes data and sends a frame on tx:
// a start bit (0), eight data bits low bit first, a stop bit (1), each bit 4 clocks long. busy is 1 from the
// edge that takes start until the last clock of the stop bit; it falls at the edge that ends the stop bit.
module uart_tx (
input logic clk, rst,
input logic start,
input logic [7:0] data,
output logic tx,
output logic busy
);
...
endmodule
| Clocks after the edge that takes start | tx | busy |
|---|---|---|
| 1 to 4 | 0 (the start bit) | 1 |
| 4k + 1 to 4k + 4, k = 1 to 8 | data bit k - 1 | 1 |
| 37 to 40 | 1 (the stop bit) | 1 |
| 41 onward | 1 | 0 |
Cycle N is the stretch after the N-th rising edge of clk in the bench. The bench checks tx in the middle of each bit, then waits for busy to fall.
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
One Byte, 96- Input
96
- Output
frames_right = 1, busy_clocks = 0, byte0 = 0x96, byte1 = 0x0, byte2 = 0x0, byte3 = 0x0, busy_low_in_frame = 0, idle_ok = 1
One frame of 96: start bit 0, data bits low first, stop bit 1. busy is high only during the frame, so none of the bench's idle samples sees it.
Example 2
Two Bytes, 00 and FF- Input
00 ff
- Output
frames_right = 2, busy_clocks = 0, byte0 = 0x0, byte1 = 0xff, byte2 = 0x0, byte3 = 0x0, busy_low_in_frame = 0, idle_ok = 1
Two frames, 00 and FF, 51 clocks apart. Each is decoded from the middle of its bits.
Example 3
Three Bytes, 55 A5 01- Input
55 a5 01
- Output
frames_right = 3, busy_clocks = 0, byte0 = 0x55, byte1 = 0xa5, byte2 = 0x1, byte3 = 0x0, busy_low_in_frame = 0, idle_ok = 1
Three frames in a row. A transmitter that never drops busy would refuse the second start.
Constraints and Contract
- Keep the module name and the ports.
- start is 1 for one clock, and only while busy is 0.
Hints
Hint 1
The frame itself is right in the log: no frame error is printed. What should happen at the end of the stop bit?
Hint 2
Find the clock where busy should fall. What do busy and tx each do there?
Hint 3
Two causes keep busy high. Read tx after the stop bit to tell them apart, then read the compare that ends the stop bit.
What the grader checks: The failing run is simulated live with the shipped transmitter. The fix is graded on five scripts of one to four bytes, 51 clocks apart. Each reports the frames with right start and stop bits and the bytes decoded. It also reports busy seen low in the middle of a bit and busy seen high in the idle gaps. Last, it reports whether the line ended idle.
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