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

wire [3:0] max1,max2,min1,min2,max3,min3;

maximum m1(a,b,max1,min1);
maximum m2(c,d,max2,min2);
maximum m3(max1,max2,max,min3);
maximum m4(min1,min2,max3,min);

endmodule

 

Was this helpful?
Upvote
Downvote