Write the protocol checker of a handshake crossing between two unrelated clocks: the assertions a team binds to every such crossing. It stays silent on the correct pair and raises an alarm on each of six faulty ones.
Hardware context: The crossings of ap_soc v1.5 between clk_sys, clk_aon, TCK and the pads, and the always-on bridge. A checker of a crossing's protocol.
Simulation cannot show metastability. What it can show is whether both sides of a crossing keep the protocol that makes metastability harmless. Each rule belongs to one side, so check it on that side's clock.
Write xing_check. On clk_s: (1) the payload holds while req is high. (2) req falls only after ack was seen high during that request. (3) req rises only while ack is low. On clk_a: (4) valid comes once per request. (5) data at valid equals the payload the sender held. (6) ack falls only while req is low.
Raise alarm at the first broken rule and keep it up. The bench drives the correct pair and six faulty pairs, each at three clock ratios. Your checker must stay silent on the correct pair and alarm on each faulty one.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
pair | 4 | input of each check |
Full specification
// A checker of a four-phase handshake crossing. It watches both sides; it drives nothing.
module xing_check (
input logic clk_s, // the sender's clock
input logic clk_a, // the receiver's clock
input logic resetn, // both sides out of reset
input logic req, // sender: the request level
input logic [7:0] payload, // sender: held still while req is high
input logic ack, // receiver: the acknowledge level
input logic valid, // receiver: one cycle per request
input logic [7:0] data, // receiver: the payload it captured
output logic alarm // 1 from the first broken rule on
);
...
endmodule
| Side | Clock | Rule |
|---|---|---|
| Sender | clk_s, 10 ns | 1: payload still while req = 1. 2: req falls only after ack = 1 was seen. 3: req rises only while ack = 0 |
| Receiver | clk_a: 14, 6 or 22 ns | 4: one valid per request. 5: data at valid = the held payload. 6: ack falls only while req = 0 |
Across the two clocks each side sees the other's signals late, by up to a few of its own cycles. The receiver takes a request two or three edges after req rises, and ack falls two or three edges after req falls. Write rules that hold at any ratio.
Examples
Example 1
The Correct Pair- Input
Six transfers at 14, 6 and 22 ns
- Output
alarm = no
Six transfers at each ratio. Every rule holds, so alarm stays 0.
Example 2
The Payload Moves- Input
The fourth payload changes after ack came back, before req falls.
- Output
alarm = yes
The fourth payload changes after the receiver answered but before req falls. The receiver already has it, so only rule 1 sees it, on clk_s.
Example 3
Req Falls Early- Input
The fifth request is withdrawn after two cycles, before the receiver answered; the sender then waits for the answer.
- Output
alarm = yes
The fifth request is withdrawn before any ack: rule 2.
Constraints and Contract
- Keep the module name and the ports. Use only your ports: no hierarchical names.
- alarm starts at 0 after reset and, once it rises, stays up.
- Inputs are 0 or 1 while resetn is 1.
Hints
Hint 1
Rule 2 needs a memory: was ack seen during this request?
Hint 2
Rule 5 needs the payload as the sender held it when req rose: keep a copy on the sender's clock.
Hint 3
ack legally stays up for a few receiver cycles after req falls. Which rule must not forbid that?
What the grader checks: Your checker watches the correct pair and six faulty pairs, each run at three clock ratios. It passes when it stays silent on the correct pair, in two separate runs. It must alarm on every faulty one, with the alarm still up at the end of the run. Two of the faulty pairs break two rules at once, so rules 3 and 6 are not each proved by the grade. It cannot see real metastability; it sees only whether the protocol was kept.
8 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 3 problems on this path