B3.4.1 The Four-Cycle Checker

MediumImplement25 minIcarus · browser samples / server checksReview the topic

Write a checker, in plain code, for the rule "every request is answered within four clock edges". Count late requests, answered requests and acks that answer nothing.

Hardware context: A responder that answers each request with an acknowledge. Bounded-response checkers on handshakes.

A responder must answer each req with ack within four rising edges of the clock. A scoreboard would only see that answers came; this checker sees when. You write it as plain code, as the lesson did before showing the same rule as one assertion.

Write resp_checker. At every rising edge, look at rst, req and ack and update two counters: errors and answered. Several copies of your checker run at once, each watching its own script of inputs.

One choice is made here that a team would settle in its plan: after a request times out, it is forgotten. A late ack then has nothing to answer, so it also counts as an error.

Signals in the Timeline

SignalWidthRole
scenario8input of each check
Full specification
At each rising edge, in this orderWhat the checker does
rst is 1Forget any waiting request. Nothing else counts at this edge.
A request waits and ack is 1answered + 1; the request is done.
A request waits and ack is 0If this is the fourth edge after the request's edge: errors + 1, forget the request.
Nothing waits and ack is 1errors + 1: an ack that answers nothing.
Then, if req is 1A new request waits, counting from this edge.

An ack at the same edge as its req does not answer it: answers come one to four edges later. Requests are one-clock pulses. The bench never sends a req while one is waiting, except at the edge where the waiting one is answered. errors and answered start at 0 and are never cleared, not even by rst.

Examples

Example 1

Answered One and Two Edges After the Request
Input
edges: rr.qa.....q.a... (r reset, q req, a ack, b both)
Output
errors = 0, answered = 2

The first request is answered at the next edge, the second two edges later: two answered, no errors.

Example 2

Answered Exactly Four Edges After the Request
Input
edges: rr.q...a..q...a. (r reset, q req, a ack, b both)
Output
errors = 0, answered = 2

Four edges after the request is still in time; this is the last edge allowed.

Example 3

Answered Five Edges After the Request: Late
Input
edges: rr.q....a....... (r reset, q req, a ack, b both)
Output
errors = 2, answered = 0

No ack within four edges: an error at the fourth. The ack at the fifth edge answers nothing, so it is a second error.

Constraints and Contract

  • Keep the module name and the ports.
  • Count at rising edges of clk only.

Hints

Hint 1

One counter of edges since the request is enough; use -1 for "nothing waiting".

Hint 2

Check ack before you start a new request at the same edge.

Hint 3

The fourth edge after the request is the last one allowed; an error is counted there.

What the grader checks: Ten scripts of rst, req and ack run at once, one copy of your checker each, one character per clock. Each row compares your two counters at the end of its script with the rules on this page. Requests never overlap, so a checker that tracks several requests at once is not needed.

10 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 problem 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

Answered One and Two Edges After the Request

Input
edges: rr.qa.....q.a... (r reset, q req, a ack, b both)
Expected output
errors = 0, answered = 2

The first request is answered at the next edge, the second two edges later: two answered, no errors.

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

Icarus · browser samples / server checks