Repair an active-low alarm output whose inversion was pushed through an AND with the wrong De Morgan rule.
Hardware context: A home alarm with an active-low siren output and active-low door and window switches. Repair the siren line of an active-low alarm so that it sounds only when armed and a switch is open.
A home alarm drives its siren through an active-low output: siren_n = 0 makes the siren sound. The door and window switches are also active low: 0 means open.
The siren must sound when the system is armed and the door or the window is open. In tests it sounds when the system is off and a door opens. When the system is armed, it sounds all the time.
This is a Fix problem. The line for open_any is correct. The bug is in the line for siren_n, where an inversion was pushed through an AND.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
row | 3 | input of each check |
Full specification
module alarm (
input logic armed, // 1: the system is armed
input logic door_n, // 0: the door is open (active low)
input logic window_n, // 0: the window is open (active low)
output logic siren_n // 0: the siren sounds (active low)
);
// your logic
endmodule
| Signal | Active level | Meaning when asserted |
|---|---|---|
| armed | high (1) | the system is armed |
| door_n | low (0) | the door is open |
| window_n | low (0) | the window is open |
| siren_n | low (0) | the siren sounds |
The siren sounds only when the system is armed and at least one of the door and the window is open. In every other case siren_n must be 1.
Examples
Example 1
Armed, Door Closed, Window Open- Input
armeddoor_nwindow_n = 110
- Output
siren_n = 0
The system is armed and the window is open. The siren sounds, so siren_n is 0.
Example 2
Armed, Everything Closed- Input
armeddoor_nwindow_n = 111
- Output
siren_n = 1
Both switches read 1, so nothing is open. The siren stays quiet: siren_n is 1.
Example 3
Disarmed, Door Open- Input
armeddoor_nwindow_n = 010
- Output
siren_n = 1
The door is open, but the system is off. The siren must stay quiet.
Constraints and Contract
- Keep the module name alarm and its four ports.
- The output must depend only on the present inputs.
Hints
Hint 1
Write the rule for the siren with active-high names first: sound = armed AND open_any. The output is active low, so siren_n is the complement of sound.
Hint 2
De Morgan changes the operator: the complement of x AND y is x' OR y'. The starter kept the AND.
Hint 3
Check the row with armed = 0 and the door open. The siren must stay quiet there, so siren_n must be 1.
What the grader checks: The check applies all eight input rows, and ten more in another order. It reads siren_n one nanosecond after each change and compares it with the rule of the specification. It checks the function only, not the way you wrote it.
21 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 steps and the final capstone