| // 2-bit magnitude comparator |
| // This module compares two 2-bit values A and B. LT is '1' if A < B |
| // and GT is '1'if A > B. LT and GT are both '0' if A = B. |
| |
| module magcompare2b (LT, GT, A, B); |
| |
| input [1:0] A; |
| input [1:0] B; |
| |
| output LT; |
| output GT; |
| |
| // Determine if A < B using a minimized sum-of-products expression |
| assign LT = ~A[1]&B[1] | ~A[1]&~A[0]&B[0] | ~A[0]&B[1]&B[0]; |
| |
| // Determine if A > B using a minimized sum-of-products expression |
| assign GT = A[1]&~B[1] | A[1]&A[0]&~B[0] | A[0]&~B[1]&~B[0]; |
| |
| endmodule // magcompare2b |