// Exercise BB5: a BCD-to-decimal decoder, like the 4028.
//
// Generic version that matches schematic 1, not tied to any chip: output
// q [k] is 1 when the code is k.  For codes 10-15, which are not decimal
// digits, all outputs are 0.  Synthesizable.

module decoder
(
    input  logic [3:0] code,  // D C B A: code [3] is D, weight 8
    output logic [9:0] q
);

    for (genvar k = 0; k < 10; k ++)
    begin : output_k
        assign q [k] = code == 4' (k);
    end

endmodule
