Prev Problem
Next Problem

44. Bus Error Checker

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

 

Code

module error_checker_xz(
    input  [7:0] bus,
    output       all_known,
    output       has_unknown,
    output [7:0] bus_if_known
);

    // Detect any X or Z in the bus
    assign has_unknown = (^(bus ^ bus)) === 1'bx;

    // all_known is the opposite
    assign all_known = ~has_unknown;

    // Pass bus only if fully known
    assign bus_if_known = all_known ? bus : 8'h00;

endmodule

 

Was this helpful?
Upvote
Downvote