S3.12.3 Parity by Hand

EasyImplement12 minIcarus Verilog · serverReview the topic

Work out parity bits, check words that were read back, and count what parity costs in a memory.

Hardware context: A memory of four words, each 8 data bits with one even-parity bit beside them, and an error injector, as test code. Parity protection of caches and other memories that hold copies

A memory stores one parity bit beside each byte. The parity is even: a byte and its parity bit together hold an even number of ones. A stored word is written here with the parity bit first, then an underscore, then the byte: 1_0110_1101.

This worksheet uses named constants. The first three entries show how to record your decisions.

Signals in the Timeline

SignalWidthRole
question8input of each check
Full specification

Enter every answer as a whole number. For a yes or no question, enter 1 for yes and 0 for no.

EntryYour decision
ONES_IN_6DHow many ones has the byte 0110_1101?
PARITY_OF_6DWhich parity bit is stored beside 0110_1101?
PARITY_OF_F0Which parity bit is stored beside 1111_0000?
ERROR_IN_169The word 1_0110_1001 is read back. Does the parity check fail?
ERROR_IN_129The word 1_0010_1001 is read back. Does the parity check fail?
THREE_FLIPSThree bits of a stored word flip. Does the parity check fail?
FOUR_FLIPSFour bits of a stored word flip. Does the parity check fail?
BITS_PER_WORDA word has 32 data bits and one parity bit for each byte. How many bits does the memory store for a word?
PARITY_BITS_16_WORDSHow many parity bits has a memory of 16 such words?
BITS_IN_BYTE_WRITEA write changes one byte of a word, and nothing else. How many stored bits may change at most?
FAILING_BYTEA read reports parity errors as 0100, one bit for each byte, with byte 0 on the right. Which byte failed?
PARITY_BITA byte holds ONES ones. Give its even parity bit.

Examples

Example 1

ONES IN 6D
Input
How many ones has the byte 0110_1101?
Output
matches = 1

Count them: 0, 1, 1, 0, 1, 1, 0, 1 has five.

Example 2

PARITY OF 6D
Input
Which parity bit is stored beside 0110_1101?
Output
matches = 1

Five ones are odd. A parity bit of 1 makes six.

Example 3

PARITY OF F0
Input
Which parity bit is stored beside 1111_0000?
Output
matches = 1

Four ones are even already.

Constraints and Contract

  • Keep the parameter and named constants. Use the numeric codes and units on this page.
  • For PARITY_BIT, enter a constant expression using ONES. Only this entry changes with the parameter. The supported integer range is 0 through 8, inclusive.

Hints

Hint 1

For a parity bit, count the ones of the byte. For a check, count the ones of all nine bits.

Hint 2

An odd count on a read is a parity error. An even count passes.

Hint 3

One bit for each byte: add four bits to every word of 32.

What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.

12 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 3 problems on this path

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

ONES IN 6D

Input
How many ones has the byte 0110_1101?
Expected output
matches = 1

Count them: 0, 1, 1, 0, 1, 1, 0, 1 has five.

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

Icarus Verilog · server