1 bit comparator

This is the code for a simple 1 bit comparator.

module comp
input a, b,
output led2
assign led2 = a & ~b; 

Essentially, it gives output 1 when a is greater than b. Which essentially means when a is 1 and b is 0.
The video shows the result when it is implemmented on Spartixed board.

Following ucf file is used.

NET "led2" LOC = P131;
NET "a" LOC = P33;
NET "b" LOC = P27;

Suggested Exercises

1. Modify the code so that it gives output when a is less than b.
2. Modify the code so it compares if a is equal to b

We will use the equality compasition to design a 4 bit equality comparator in next post.