G6.10.1 PRBS Checker That Counts Each Error Once

MediumImplementIcarus Verilog + Yosys · serverReview the topic

Lock onto a PRBS7 stream from its first seven bits, then flag and count every wrong bit exactly once.

Hardware context: A link's bit-error tester that checks a PRBS7 test pattern, and a chip's built-in self-test. Build a PRBS7 checker that locks on seven bits and counts each wrong bit once.

A link test sends PRBS7, x^7 + x^6 + 1. Each bit is the XOR of the bits sent 6 and 7 edges earlier. The test equipment must report the number of wrong bits on the link. A wrong bit must be counted once, not once per tap.

This is an Implement problem. The starter only collects bits. Complete prbs7_check. The check runs 48 edges per case, with flipped bits and resets.

Signals in the Timeline

SignalWidthRole
bits48input of each check
Full specification
The module (keep the name and the ports)
module prbs7_check (
  input  logic       clk,
  input  logic       rst,      // synchronous reset: lock again from the next bit
  input  logic       rx,       // one received bit at every edge
  output logic       locked,   // 1 once the checker has taken its 7 seed bits
  output logic       err,      // 1 for one cycle after an edge that took a wrong bit
  output logic [7:0] errors    // wrong bits since the last reset
);
  ...
endmodule
At a rising edgeEffect
rst = 1locked = 0, err = 0, errors = 0; the next 7 bits are the seed again
not lockedtake rx as the next seed bit; the edge that takes the 7th sets locked = 1
lockedrx is checked against the sequence the seed starts: err = 1 if it differs, and errors counts it

After locking, the expected bits are the PRBS7 sequence that the 7 seed bits begin, whatever arrives. So one flipped bit gives err = 1 after exactly one edge. err, locked and errors change only at edges. The result shows err after every edge, errors after edges 24 and 48, and the first edge after which locked is 1.

Examples

Example 1

A Clean Stream
Input
PRBS7 from seed 1000000; no bit flipped
Output
err_by_edge = 'b000000000000000000000000000000000000000000000000, errors_after_edge24 = 0, errors_after_edge48 = 0, first_edge_locked = 7

The first 7 bits are the seed, so locked is 1 after edge 7. Every later bit matches: err stays 0 and errors is 0.

Example 2

One Wrong Bit at Edge 20
Input
PRBS7 from seed 1000000; bits flipped at edges 20
Output
err_by_edge = 'b000000000000000000000000000010000000000000000000, errors_after_edge24 = 1, errors_after_edge48 = 1, first_edge_locked = 7

err is 1 after edge 20 only, and errors is 1. err_by_edge lists edges from the right: edge 1 is the last digit.

Example 3

A Reset at Edge 30, Then the Checker Locks Again
Input
PRBS7 from seed 1011001; bits flipped at edges 12, 40; rst at edge 30
Output
err_by_edge = 'b000000001000000000000000000000000000100000000000, errors_after_edge24 = 1, errors_after_edge48 = 1, first_edge_locked = 7

The reset clears errors. The checker takes the next 7 bits as a new seed, locks again and counts the wrong bit at edge 40.

Constraints and Contract

  • All inputs are known 0/1 values and change only between edges. No case has more than 100 wrong bits.
  • Keep the module name and the ports. The design must synthesize with no latches.

Hints

Hint 1

Keep the last 7 bits of the sequence in a shift register. The next bit is the XOR of the oldest two.

Hint 2

A checker that shifts in the received bit counts one wrong bit three times. What should enter the register once it has locked?

Hint 3

Count the seed bits after a reset. On the edge that takes the 7th, set locked; from the next edge on, compare and count.

What the grader checks: Nine directed and ten seeded streams of 48 edges, from different seeds and points in the sequence. They include flipped bits at the lock boundary and in a row, and resets. err after every edge, errors at two points and the lock edge are compared with a JavaScript model. Synthesis must report no latches.

The submitted design must synthesize with 0 latches and no combinational loop. Counts come from the pinned open-source synthesis flow. They are proxies for logic size and depth, not physical area or timing.

19 checks on Icarus Verilog + Yosys · server. 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 1 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

A Clean Stream

Input
PRBS7 from seed 1000000; no bit flipped
Expected output
err_by_edge = 'b000000000000000000000000000000000000000000000000, errors_after_edge24 = 0, errors_after_edge48 = 0, first_edge_locked = 7

The first 7 bits are the seed, so locked is 1 after edge 7. Every later bit matches: err stays 0 and errors is 0.

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

Icarus Verilog + Yosys · server