S8.6.1 An Event Counter

MediumImplement20 minIcarus Verilog · serverReview the topic

Build a selectable event meter that keeps evidence of a wrap until firmware clears the measurement.

Hardware context: ap_soc performance monitoring. Core and peripheral performance analysis

This ap_soc exercise assigns each event source a three-bit ID. At most one event is valid per rising edge. A repeated ID on consecutive valid edges represents separate events.

Signals in the Timeline

SignalWidthRole
sample9input of each check
Full specification

Count modulo sixteen. Set overflow on the increment from fifteen to zero and retain it until clear or reset.

Examples

Example 1

Reset
Input
Reset with event 3 selected and valid.
Output
overflow = 0, count = 0

Reset opens a fresh interval.

Example 2

First Event
Input
Next edge accepts event 3.
Output
overflow = 0, count = 1

One matching event advances the count.

Example 3

Other Source
Input
Next edge sees event 7 with selector 3.
Output
overflow = 0, count = 1

The high ID bit distinguishes these sources.

Constraints and Contract

  • Use synchronous active-high reset and clear. Either clears both outputs even when disabled. Otherwise count a matching valid ID when enabled. Hold both outputs between rising edges.

Hints

Hint 1

Mark clear and reset before looking at an event.

Hint 2

Compare the full source ID.

Hint 3

Look at the old count on an accepted edge.

What the grader checks: All ID pairs, held and consecutive events, control collisions and multiple wraps are checked.

275 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 2 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

Input
Reset with event 3 selected and valid.
Expected output
overflow = 0, count = 0

Reset opens a fresh interval.

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

Icarus Verilog · server