G7.6.2 The Machine That Hung in State 5

MediumDebugIcarus · browser samples / server checksReview the topic

A frame-receiver controller stayed busy for ever after a supply glitch. Find the first bad cycle and name the bug that let it hang.

Hardware context: A garage-door controller and a frame receiver that must survive a glitch in their state registers. Find the bug that let a controller hang in an unused code after a glitch.

A frame receiver uses a five-state controller with binary codes. Codes 5, 6 and 7 are unused, and the spec says each must return to IDLE at the next edge. In a glitch test the controller stayed busy and never acknowledged again. The bench is correct.

Run the failing test to see its log and waveform. The bench forces an unused code into the state register twice, as a glitch would.

Step 1: find the first cycle where the controller shows a value a correct one would not, and name the signal. Step 2: choose the cause from four real bugs; each fails in a different way. Step 3 is optional: fix the controller and run the tests.

Signals in the Timeline

SignalWidthRole
script32input of each check
Full specification
The controller's ports
module rxctl (
  input  logic       clk,
  input  logic       rst,     // synchronous reset, active high: IDLE
  input  logic       sof,     // start of a frame
  input  logic       eof,     // the last word of a frame body
  output logic [2:0] state,   // IDLE 0, HDR 1, BODY 2, CRC 3, ACK 4; codes 5, 6 and 7 are unused
  output logic       busy,    // 1 in every state but IDLE
  output logic       ack      // 1 in ACK
);
  ...
endmodule
StateCodeNext state
IDLE0HDR if sof, else IDLE
HDR1BODY
BODY2CRC if eof, else BODY
CRC3ACK
ACK4IDLE
unused5, 6, 7IDLE

busy is 1 in every state but IDLE; ack is 1 in ACK. Cycle N is the stretch where the cycle counter shows N. A forced code shows in its own cycle; the edge that ends that cycle must deal with it.

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

One Frame, No Upset
Input
sof/eof per cycle: 00 10 00 00 01 00 00 00 00 00 00 00 00 00 00 00
Output
state_cycle0 = 0, state_cycle1 = 0, state_cycle2 = 1, state_cycle3 = 2, state_cycle4 = 2, state_cycle5 = 3, state_cycle6 = 4, state_cycle7 = 0, state_cycle8 = 0, state_cycle9 = 0, state_cycle10 = 0, state_cycle11 = 0, state_cycle12 = 0, state_cycle13 = 0, state_cycle14 = 0, state_cycle15 = 0

sof in cycle 1 gives HDR in 2, then BODY. eof in cycle 4 gives CRC in 5, ACK in 6 and IDLE in 7.

Example 2

Code 5 Forced While Idle
Input
sof/eof per cycle: 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00; code 5 forced in cycle 2
Output
state_cycle0 = 0, state_cycle1 = 0, state_cycle2 = 5, state_cycle3 = 0, state_cycle4 = 1, state_cycle5 = 2, state_cycle6 = 2, state_cycle7 = 2, state_cycle8 = 2, state_cycle9 = 2, state_cycle10 = 2, state_cycle11 = 2, state_cycle12 = 2, state_cycle13 = 2, state_cycle14 = 2, state_cycle15 = 2

Code 5 shows in cycle 2. The edge that ends cycle 2 must give IDLE, so cycle 3 shows 0. The sof in cycle 3 then starts a frame.

Example 3

Code 7 Forced in the Middle of a Frame
Input
sof/eof per cycle: 10 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00; code 7 forced in cycle 3
Output
state_cycle0 = 0, state_cycle1 = 1, state_cycle2 = 2, state_cycle3 = 7, state_cycle4 = 0, state_cycle5 = 0, state_cycle6 = 0, state_cycle7 = 0, state_cycle8 = 0, state_cycle9 = 0, state_cycle10 = 0, state_cycle11 = 0, state_cycle12 = 0, state_cycle13 = 0, state_cycle14 = 0, state_cycle15 = 0

The frame is lost: code 7 returns to IDLE, and the eof that comes later finds the controller idle.

Constraints and Contract

  • sof and eof are known 0/1 values.
  • Keep the module name, the ports and the state codes.

Hints

Hint 1

In the cycle of an upset the forced code is expected. Look at the cycle after it: what should the state be?

Hint 2

Compare the two upsets. Does the controller fail after the first one, or only after the second?

Hint 3

A case statement runs no arm when nothing matches. Then state_n keeps the value it was given before the case.

What the grader checks: The failing run is simulated live with the shipped controller. The first bad cycle and every option's first wrong value come from simulations on the same 16-cycle bench. The fix is compared with a JavaScript model on sixteen runs with codes 5, 6 and 7 forced at many points.

16 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 3 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

One Frame, No Upset

Input
sof/eof per cycle: 00 10 00 00 01 00 00 00 00 00 00 00 00 00 00 00
Expected output
state_cycle0 = 0, state_cycle1 = 0, state_cycle2 = 1, state_cycle3 = 2, state_cycle4 = 2, state_cycle5 = 3, state_cycle6 = 4, state_cycle7 = 0, state_cycle8 = 0, state_cycle9 = 0, state_cycle10 = 0, state_cycle11 = 0, state_cycle12 = 0, state_cycle13 = 0, state_cycle14 = 0, state_cycle15 = 0

sof in cycle 1 gives HDR in 2, then BODY. eof in cycle 4 gives CRC in 5, ACK in 6 and IDLE in 7.

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

Icarus · browser samples / server checks