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, 
               input[3:0] b, 
               input[3:0] c, 
               input[3:0] d, 
               output[3:0] max,
               output[3:0] min);



               wire[3:0] max_tmp;
               wire[3:0] max_tmp1;
               wire[3:0] min_tmp;
               wire[3:0] min_tmp1;

               assign max_tmp = (a > b) ? a : b;
               assign max_tmp1 = (c > d) ? c : d;
               assign max = (max_tmp > max_tmp1)? max_tmp : max_tmp1;


               assign min_tmp = (a < b) ? a : b;
               assign min_tmp1 = (c < d) ? c : d;
               assign min = (min_tmp < min_tmp1)? min_tmp : min_tmp1;





endmodule

 

Was this helpful?
Upvote
Downvote