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

/*Write your code here*/
module error_checker_xz (
    input  [7:0] bus,
    output       all_known,
    output       has_unknown,
    output [7:0] bus_if_known
);
    // Propagate unknowns: (bus ^ bus) -> 0 on known bits, X on X/Z bits.
    // Reduction XOR of that is X iff any bit was X/Z.
    wire any_xz = (^(bus ^ bus)) === 1'bx;

    assign has_unknown  = any_xz;
    assign all_known    = ~any_xz;
    assign bus_if_known = {8{all_known}} & bus;  // pass when known, else 00
endmodule

 

Was this helpful?
Upvote
Downvote