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,  //  when every bit of bus is 0/1 (no x/z)
    output has_unknown,  // 1 when any bit of bus is x or z
    output [7:0] bus_if_known
);
    // haz x/z input bit
    wire any_xz = (^(bus ^ bus)) === 1'bx;

    assign has_unknown  = any_xz;
    assign all_known    = ~any_xz;
    assign bus_if_known = all_known ? bus : 8'h00;

endmodule

 

Was this helpful?
Upvote
Downvote