Prev Problem
Next Problem

48. Safe MUX

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

simply assign values according to the condition

 

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
        y           = 8'h00;
        sel_unknown = 1'b0;

        // if `sel` is 0
        if (sel === 1'b0) begin
            // Write your code here
            y = a;
        
        end

        // else if `sel` is 1
        else if (sel === 1'b1) begin
            // Write your code here
            y = b;
        end

        // `sel` is either `x` or `z`
        else begin
            // Write your code here
            sel_unknown = 1'b1;
        end
    end
endmodule

 

Was this helpful?
Upvote
Downvote