P3.14.1 The Completer's Parity Block

MediumImplementIcarus · browser samples / server checksReview the topic

Give an APB5 completer its parity. Make the check signals of its outputs, and check each request check signal only when it must be right.

Hardware context: The parity block of an APB5 completer with Check_Type Odd_Parity_Byte_All. Implement the completer's parity generator and checker for every APB5 check signal it touches.

Lesson P3.14 caught a flipped PWDATA bit with odd parity. A real completer needs the whole set: three check signals to drive and six to check. Each has its own rule for when it counts.

Write module apb5_parity_rx. It is combinational. Drive PREADYCHK, PRDATACHK and PSLVERRCHK from the completer's outputs. Raise one error flag for each request check signal that disagrees with its payload. Do it only while its Check Enable term is true.

Three details trap most first attempts. PADDR here is 12 bits, so the top check bit covers four. PCTRLCHK is one bit over PPROT, PWRITE and PNSE. PSELCHK must be right whenever PRESETn is high, even with no transfer.

Signals in the Timeline

SignalWidthRole
flips4input of each check
Full specification
The module you write (keep these ports)
module apb5_parity_rx (
  input  logic        presetn,
  // the request as it arrived at the completer, with its check signals
  input  logic        psel,
  input  logic        penable,
  input  logic        pwrite,
  input  logic        pnse,
  input  logic [11:0] paddr,        // ADDR_WIDTH = 12
  input  logic [2:0]  pprot,
  input  logic [31:0] pwdata,
  input  logic [3:0]  pstrb,
  input  logic [1:0]  paddrchk,
  input  logic        pctrlchk,
  input  logic        pselchk,
  input  logic        penablechk,
  input  logic [3:0]  pwdatachk,
  input  logic        pstrbchk,
  // the completer's own response, which this block protects
  input  logic        pready,
  input  logic [31:0] prdata,
  input  logic        pslverr,
  output logic        preadychk,
  output logic [3:0]  prdatachk,
  output logic        pslverrchk,
  // one error flag per request check signal: [0] PADDRCHK [1] PCTRLCHK [2] PSELCHK
  // [3] PENABLECHK [4] PWDATACHK [5] PSTRBCHK
  output logic [5:0]  err
);
  // your parity block
endmodule
SignalCoversCheck Enable
PADDRCHK[1:0]PADDR[7:0], PADDR[11:8]PSEL
PCTRLCHKPNSE, PPROT[2:0], PWRITE in one bitPSEL
PSELCHKPSEL (the inverse)PRESETn
PENABLECHKPENABLE (the inverse)PSEL
PWDATACHK[3:0]PWDATA, one bit per bytePSEL and PWRITE
PSTRBCHKPSTRB[3:0] in one bitPSEL and PWRITE

Every check bit uses odd parity: the bits it covers and the check bit hold an odd number of ones together. Drive the three response check signals correctly at all times; that is always legal.

The result is {preadychk, prdatachk, pslverrchk, 2'b0, err} in bits 13 to 0, read one nanosecond after the inputs change.

Examples

Example 1

Everything Right
Input
presetn=1 psel=1 penable=1 pwrite=1 pnse=0 paddr=0x234 pprot=2 pwdata=0x11223344 pstrb=15 pready=1 prdata=0x80000001 pslverr=0
Every check signal correct
Output
preadychk = 'b0, prdatachk = 'b0110, pslverrchk = 'b1, err = 'b000000

All six request check signals match, so err is 000000. PRDATA 80000001 has one 1 in byte 0 and one in byte 3, so their check bits are 0. The middle two are 1.

Example 2

Not Checked in a Read
Input
presetn=1 psel=1 penable=1 pwrite=0 pnse=0 paddr=0x234 pprot=2 pwdata=0x11223344 pstrb=15 pready=1 prdata=0x80000001 pslverr=0
Check signals correct except pwdatachk (mask 11)
Output
preadychk = 'b0, prdatachk = 'b0110, pslverrchk = 'b1, err = 'b000000

PWDATACHK is wrong, but PWRITE is 0. Its enable term is false, so the flag stays low.

Example 3

Checked While Idle
Input
presetn=1 psel=0 penable=0 pwrite=0 pnse=0 paddr=0x234 pprot=2 pwdata=0x11223344 pstrb=15 pready=1 prdata=0x80000001 pslverr=0
Check signals correct except pselchk (mask 1)
Output
preadychk = 'b0, prdatachk = 'b0110, pslverrchk = 'b1, err = 'b000100

No transfer is running, but PRESETn is high. PSELCHK must still be the inverse of PSEL, so err[2] is set.

Constraints and Contract

  • Keep the module name and the ports. The block has no clock.
  • Every input is 0 or 1. err must be 0 for a check signal whose enable term is false.

Hints

Hint 1

The odd parity bit of a group is ~^ of the group.

Hint 2

Write the enable terms as plain if statements around the comparisons.

Hint 3

For PSELCHK, the enable is PRESETn alone.

What the grader checks: Your block is driven with 25 vectors: thirteen directed corners and twelve seeded mixes, some with one or two wrong check signals. Its outputs are compared with a model of the odd-parity rules and the Check Enable terms.

25 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 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

Everything Right

Input
presetn=1 psel=1 penable=1 pwrite=1 pnse=0 paddr=0x234 pprot=2 pwdata=0x11223344 pstrb=15 pready=1 prdata=0x80000001 pslverr=0
Every check signal correct
Expected output
preadychk = 'b0, prdatachk = 'b0110, pslverrchk = 'b1, err = 'b000000

All six request check signals match, so err is 000000. PRDATA 80000001 has one 1 in byte 0 and one in byte 3, so their check bits are 0. The middle two are 1.

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

Icarus · browser samples / server checks