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 [3:0] max,min
);
    wire[3:0] a1,b1,c1,d1;
    assign a1 = (a>b) ? a : b;
    assign b1 = (a<b) ? a : b;

    assign c1 = (c>d) ? c : d;
    assign d1 = (c<d) ? c : d;

    assign max = (a1 > c1) ? a1 : c1;
    assign min = (b1 < d1) ? b1 : d1;

endmodule

 

Was this helpful?
Upvote
Downvote