Saturday 4 July 2015

Combinational circuits- Magnitude comparator 4bit


4 BIT MAGNITUDE COMPARATOR

module magn4bitcomp(equal,lower,higher,a,b);
output equal,lower,higher;
reg equal,lower,higher;
input [3:0]a;
input [3:0]b;
always @(a or b)
begin
if (a>b) begin
equal=0;
higher=1;
lower=0;
end else if(a==b) begin
equal=1;
higher=0;
lower=0;
end else begin
equal=0;
lower=1;
higher=0;
end
end

endmodule

No comments:

Post a Comment