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 [3:0] max,
    output [3:0] min
);
wire [3:0] ab_min,ab_max,cd_min,cd_max;
assign ab_min = (a<b)? a:b;
assign ab_max = (a<b)? b:a;

assign cd_min = (c<d)? c:d;
assign cd_max = (c<d)? d:c;

assign min = (ab_min<cd_min)? ab_min:cd_min;
assign max = (ab_max<cd_max)? cd_max:ab_max;
endmodule

 

Was this helpful?
Upvote
Downvote