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

module maxmin4(
    input [3:0] a, b, c, d,
    output [3:0] max, min
);

wire [3:0] r1;
wire [3:0] r2;
wire [3:0] r3;
wire [3:0] r4;


assign r1 = (a > b) ? a : b; 
assign r2 = (c > d) ? c : d; 

assign r3 = (a > b) ? b : a; 
assign r4 = (c > d) ? d : c; 

assign max = (r1 > r2) ? r1 : r2; 
assign min = (r3 > r4) ? r4 : r3; 


endmodule

 

Was this helpful?
Upvote
Downvote