Write the checker for a four-phase request/acknowledge crossing. Catch the five ways a partner breaks it, and stay silent on two clocks that never line up.
Hardware context: A request/acknowledge crossing between two unrelated clock domains. Check a four-phase crossing for out-of-turn changes and moving data, against five broken partners.
Lesson P1.12 gave the four-phase handshake two rules. req moves only while ack has caught up, and ack only while req has moved away. Across two clocks those rules are all you can check. Neither side shares an edge with the other.
Write module hs_checker. It samples req, ack and data on a fast clock that sees every change. It adds one to errors for every change that breaks a rule. Data that moves while req waits for ack counts too.
Six pairs drive it, each a sender on one clock and a receiver on another. One pair is correct. Each of the others breaks one rule once. Four scenarios change the clock ratio, the receiver's delay and the gaps between words.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
clk_a | 1 | stimulus, the same for every design |
clk_b | 1 | stimulus, the same for every design |
rst_n | 1 | stimulus, the same for every design |
req | 1 | output of the design under test |
ack | 1 | output of the design under test |
data | 8 | output of the design under test |
your errors | 32 | output of the design under test |
Full specification
module hs_checker (
input logic clk, // a fast sampling clock: every change on req, ack and data is seen
input logic rst_n,
input logic req,
input logic ack,
input logic [7:0] data,
output int errors
);
// your checker
endmodule
| Rule | Judged at a sample, against the previous sample |
|---|---|
| requester | req may change only if, at the previous sample, ack equalled req. |
| responder | ack may change only if, at the previous sample, req differed from ack. |
| bundled data | If req was 1 and ack was 0 at the previous sample and req is still 1, data has not changed. |
| reset | While rst_n is 0, req and ack are both 0. |
Each scenario has two reset samples and runs 258 more. Data may change in the same sample in which req rises.
For each pair you get alarm = yes or no. For the correct pair you also get first_alarm_scenario and first_alarm_cycle.
Examples
Example 1
The Correct Pair Must Not Raise an Alarm- Input
Pair: keeps every rule Scenarios: Clock A faster than clock B; Clock B faster than clock A; A receiver that takes its time; Gaps between the words
- Output
alarm = no
The sender loads each word in the same sample in which it raises req. That is not a data change under a waiting request.
Example 2
A Request Dropped Too Soon- Input
Pair: The sender drops req before ack Scenarios: Clock A faster than clock B; Clock B faster than clock A; A receiver that takes its time; Gaps between the words
- Output
alarm = yes
On the third word req falls while ack is still 0. At the previous sample req and ack differed, so it was not the sender's turn.
Example 3
The Next Request Too Soon- Input
Pair: The sender starts the next word while ack is still up Scenarios: Clock A faster than clock B; Clock B faster than clock A; A receiver that takes its time; Gaps between the words
- Output
alarm = yes
On the fourth word req rises again while ack is still 1. At the previous sample they differed, so the sender had to wait.
Constraints and Contract
- Every input is always 0 or 1. Use only your ports.
- errors never decreases.
Hints
Hint 1
Keep the previous req, ack and data. Every rule compares a change with the state before it.
Hint 2
Exactly one side may move in each state. If you find yourself checking a new value against a new value, you have one sample too few.
Hint 3
The sender loads a new word in the same sample in which it raises req. That change is legal.
What the grader checks: Your checker watches one correct and five faulty pairs over four clock and traffic scenarios. Passing shows that it catches these five faults on this traffic, without false alarms.
6 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 2 steps and the final capstone