// Exercise B2: De Morgan's laws.
//
// Generic version that matches schematic 1: both sides of
//
//     ~ (a & b) == ~ a | ~ b
//     ~ (a | b) == ~ a & ~ b
//
// each built from its own gates, so that the two outputs of a pair can
// be compared.  Synthesizable.

module de_morgan
(
    input  logic a,
    input  logic b,

    output logic not_a_and_b,      // ~ (a & b): an AND gate, then NOT
    output logic not_a_or_not_b,   // ~ a | ~ b: two NOT gates, then OR
    output logic not_a_or_b,       // ~ (a | b): an OR gate, then NOT
    output logic not_a_and_not_b   // ~ a & ~ b: two NOT gates, then AND
);

    wire not_a = ~ a;
    wire not_b = ~ b;

    assign not_a_and_b     = ~ (a & b);
    assign not_a_or_not_b  = not_a | not_b;

    assign not_a_or_b      = ~ (a | b);
    assign not_a_and_not_b = not_a & not_b;

endmodule
