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, 
    input [3:0] b, 
    input [3:0] c,
    input [3:0] d,
    output reg [3:0] max, 
    output reg [3:0] min
);
    always @(*) begin
        max = a;
        min = a;
        if(b > max) max = b;
        if(c > max) max = c;
        if(d > max) max = d;

        if(b < min) min = b;
        if(c < min) min = c;
        if(d < min) min = d;
        

    end

endmodule

 

Was this helpful?
Upvote
Downvote