Connect three devices to an open-drain interrupt line that other devices share, and tell your requests from theirs.
Hardware context: A board bus shared by a CPU, peripherals and a DMA engine through tri-state drivers, with a keeper. Share an open-drain interrupt line with devices outside the block.
Several boards share one active-low interrupt line. Each board may pull the line low or let go, but never drive it high. So two requests can overlap without a fight. When nobody pulls, a pull-up makes the line 1.
This is an Implement problem. Write irq_share for one board with three devices. Each device pulls the line low while its req bit is 1. Put the line's pull-up in this block. irq is 1 while the line is low, whoever pulls it. others is 1 while the line is low but none of this block's devices requests.
The fixture adds an outside device on the same line, through its own open-drain driver. It applies eight steps, one per nanosecond, and records the line, irq and others. A line that reads x or z is flagged.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
script | 32 | input of each check |
Full specification
module irq_share (
input logic [2:0] req, // this block's three devices: 1 = needs service
inout wire line_n, // the shared interrupt line, low while anyone requests
output logic irq, // 1 while the line is low
output logic others // 1 while the line is low but none of req is 1
);
// your design
endmodule
| Requests | line_n | irq | others |
|---|---|---|---|
| nobody | 1 (the pull-up) | 0 | 0 |
| one or more of req | 0 | 1 | 0 |
| only the outside device | 0 | 1 | 1 |
The result fields per step are line_n_stepK (0 when it was x or z), line_x_stepK, line_z_stepK, irq_stepK and others_stepK.
Examples
Example 1
This Block's Devices, One at a Time- Input
req=000, req=001, req=010, req=100, req=000, req=111, req=011, req=000
- Output
line_n_step0 = yes, line_x_step0 = no, line_z_step0 = no, irq_step0 = no, others_step0 = no, line_n_step1 = no, line_x_step1 = no, line_z_step1 = no, irq_step1 = yes, others_step1 = no, line_n_step2 = no, line_x_step2 = no, line_z_step2 = no, irq_step2 = yes, others_step2 = no, line_n_step3 = no, line_x_step3 = no, line_z_step3 = no, irq_step3 = yes, others_step3 = no, line_n_step4 = yes, line_x_step4 = no, line_z_step4 = no, irq_step4 = no, others_step4 = no, line_n_step5 = no, line_x_step5 = no, line_z_step5 = no, irq_step5 = yes, others_step5 = no, line_n_step6 = no, line_x_step6 = no, line_z_step6 = no, irq_step6 = yes, others_step6 = no, line_n_step7 = yes, line_x_step7 = no, line_z_step7 = no, irq_step7 = no, others_step7 = no
Any of the three devices pulls the line low, so irq is 1 and others stays 0.
Example 2
The Outside Device Alone- Input
req=000, req=000 + outside, req=000, req=000 + outside, req=000 + outside, req=000, req=000 + outside, req=000
- Output
line_n_step0 = yes, line_x_step0 = no, line_z_step0 = no, irq_step0 = no, others_step0 = no, line_n_step1 = no, line_x_step1 = no, line_z_step1 = no, irq_step1 = yes, others_step1 = yes, line_n_step2 = yes, line_x_step2 = no, line_z_step2 = no, irq_step2 = no, others_step2 = no, line_n_step3 = no, line_x_step3 = no, line_z_step3 = no, irq_step3 = yes, others_step3 = yes, line_n_step4 = no, line_x_step4 = no, line_z_step4 = no, irq_step4 = yes, others_step4 = yes, line_n_step5 = yes, line_x_step5 = no, line_z_step5 = no, irq_step5 = no, others_step5 = no, line_n_step6 = no, line_x_step6 = no, line_z_step6 = no, irq_step6 = yes, others_step6 = yes, line_n_step7 = yes, line_x_step7 = no, line_z_step7 = no, irq_step7 = no, others_step7 = no
The outside device pulls the line low. This block's irq follows the line, and others is 1 because none of its own devices requested.
Example 3
Both at Once- Input
req=001 + outside, req=010 + outside, req=000 + outside, req=100, req=100 + outside, req=111 + outside, req=000, req=000 + outside
- Output
line_n_step0 = no, line_x_step0 = no, line_z_step0 = no, irq_step0 = yes, others_step0 = no, line_n_step1 = no, line_x_step1 = no, line_z_step1 = no, irq_step1 = yes, others_step1 = no, line_n_step2 = no, line_x_step2 = no, line_z_step2 = no, irq_step2 = yes, others_step2 = yes, line_n_step3 = no, line_x_step3 = no, line_z_step3 = no, irq_step3 = yes, others_step3 = no, line_n_step4 = no, line_x_step4 = no, line_z_step4 = no, irq_step4 = yes, others_step4 = no, line_n_step5 = no, line_x_step5 = no, line_z_step5 = no, irq_step5 = yes, others_step5 = no, line_n_step6 = yes, line_x_step6 = no, line_z_step6 = no, irq_step6 = no, others_step6 = no, line_n_step7 = no, line_x_step7 = no, line_z_step7 = no, irq_step7 = yes, others_step7 = yes
Two pulls agree on 0, so the line stays a clean 0. others is 1 only in the steps where this block has no request.
Constraints and Contract
- Inputs are known 0/1 values. Each step is held for one nanosecond and the outputs are sampled at its end.
- Keep the module name and the ports. The line is a net shared with the fixture: drive it only with strengths that let other drivers win.
Hints
Hint 1
An open-drain driver pulls the line to 0 or does not drive at all. In SystemVerilog a continuous assignment with the strengths (strong0, highz1) does exactly that.
Hint 2
One such assignment per device, each driving 0 when its device requests. The primitive pullup gives the line a weak 1 when nobody pulls.
Hint 3
irq must read the line itself, so it sees requests from outside the block too. others is irq while none of this block's req bits is 1.
What the grader checks: Five directed and eight seeded cases of eight steps each mix this block's requests with an outside device on the same line. The line, its x and z flags, irq and others are compared with a model written in JavaScript after every step.
13 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 steps and the final capstone