S6.8.2 The Counter Read in Two Halves

HardFix32 minIcarus Verilog · serverReview the topic

Repair a split counter interface that invents a timestamp when two independent readers cross a carry.

Hardware context: Timer event register. Peripheral register interfaces

Two bus managers share one peripheral clock. Its synchronized 64-bit input count can change between any two edges. The low-word convention promises each reader a coherent pair, even if the other reader runs between its accesses.

Signals in the Timeline

SignalWidthRole
sample10input of each check
Full specification

A completed low read returns the live low half and replaces that reader’s saved high half from the same sample. A completed high read consumes only that reader’s snapshot. With no snapshot, high reads return live high.

data always shows the addressed view, even in a wait. done qualifies a completion on the rising edge. The bus samples data before state changes. Synchronous active-low reset discards both snapshots and takes precedence over done.

Examples

Example 1

Reset Edge
Input
reader=0, high=0, done=0, count=64'h00000003fffffffe, reset_n=0
Output
captured = 0xfffffffe

The selected low view is live while reset discards old snapshots.

Example 2

Read the Last Low Word
Input
reader=0, high=0, done=1, count=64'h00000003ffffffff, reset_n=1
Output
captured = 0xffffffff

Reader zero starts a pair at the end of epoch three.

Example 3

Carry Between Transfers
Input
reader=0, high=1, done=1, count=64'h0000000400000000, reset_n=1
Output
captured = 0x3

Reader zero completes the pair after the counter advances to epoch four.

Constraints and Contract

  • Keep counter_reader and its ports. reader identifies one of two independent requesters. A repeated low read starts a fresh pair. There is no bound on the change in count.

Hints

Hint 1

Define when a pair begins and ends.

Hint 2

One reader can have a pending pair while its neighbor starts another.

Hint 3

A wait may expose a view without consuming it.

What the grader checks: Samples check every bit in both data halves with complementary patterns, interleaved ownership, replacement, stalls and reset.

511 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

Reset Edge

Input
reader=0, high=0, done=0, count=64'h00000003fffffffe, reset_n=0
Expected output
captured = 0xfffffffe

The selected low view is live while reset discards old snapshots.

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

Icarus Verilog · server