G2.5.1 De Morgan on an Active-Low Alarm

EasyFixIcarus · browser samples / server checksReview the topic

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

SignalWidthRole
row3input of each check
Full specification
The module you repair (keep the name and the ports)
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
SignalActive levelMeaning when asserted
armedhigh (1)the system is armed
door_nlow (0)the door is open
window_nlow (0)the window is open
siren_nlow (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

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Armed, Door Closed, Window Open

Input
armeddoor_nwindow_n = 110
Expected output
siren_n = 0

The system is armed and the window is open. The siren sounds, so siren_n is 0.

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

Icarus · browser samples / server checks