Prev Problem
Next Problem

68. 4-bit Comparator

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

Code

/*Write your code here*/
module maxmin4(
    input [3:0] a,b,c,d,
    output reg [3:0] max,min
);

reg [3:0] temp_max,temp_min;
always @(*) begin
    temp_max = a > b ? a : b;
    temp_max = temp_max > c ? temp_max : c;
    temp_max = temp_max > d ? temp_max : d;
    max = temp_max;
    temp_min = a > b ? b : a;
    temp_min = temp_min > c ? c : temp_min;
    temp_min = temp_min > d ? d : temp_min;
    min = temp_min;
end

endmodule

 

Was this helpful?
Upvote
Downvote