Prev Problem
Next Problem

48. Safe MUX

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

 

Code

module safe_mux2 (
    input  [7:0] a,
    input  [7:0] b,
    input        sel,
    output reg [7:0] y,
    output reg       sel_unknown
);

always @* begin
    sel_unknown = 1'b0;

    if (sel === 1'b0) begin
        y = a;
    end

    else if (sel === 1'b1) begin
        y = b;
    end

    else begin
        y = 8'h00;
        sel_unknown = 1'b1;
    end

end

endmodule

 

Was this helpful?
Upvote
Downvote