Guest
Hello:
I am trying to write some code for a comparator. Is it possible to
write the code as so
module comparator(A_lt_B, A_gt_B, A_eq_zero, B_eq_zero, A, B);
parameter D_Width = 32;
output A_lt_B, A_gt_B, A_eq_zero, B_eq_zero;
reg A_lt_B, A_gt_B, A_eq_zero, B_eq_zero;
input [D_Width-1:0] A;
input [D_Width-1:0] B;
always@(A or B)
begin
if(A>B) A_gt_B = 1;
else if (A<B) A_lt_B = 1;
else if (A==0) A_eq_zero = 1;
else if (B==0) B_eq_zero = 1;
end
endmodule
I am trying to write some code for a comparator. Is it possible to
write the code as so
module comparator(A_lt_B, A_gt_B, A_eq_zero, B_eq_zero, A, B);
parameter D_Width = 32;
output A_lt_B, A_gt_B, A_eq_zero, B_eq_zero;
reg A_lt_B, A_gt_B, A_eq_zero, B_eq_zero;
input [D_Width-1:0] A;
input [D_Width-1:0] B;
always@(A or B)
begin
if(A>B) A_gt_B = 1;
else if (A<B) A_lt_B = 1;
else if (A==0) A_eq_zero = 1;
else if (B==0) B_eq_zero = 1;
end
endmodule