|
|
|
|
|
|
|
|
|
|
|
|
Relational Operators
|
|
|
Relational operators are used with if, while statements. Relational operators like in Verilog, return true or fales of relation being checked. |
|
|
|
|
|
Operator
|
Description
|
a < b
|
a less than b
|
a > b
|
a greater than b
|
a <= b
|
a less than or equal to b
|
a >= b
|
a greater than or equal to b
|
|
|
|
|
|
|
- The result is a scalar value (example a < b)
- 0 if the relation is false (a is bigger then b)
- 1 if the relation is true ( a is smaller then b)
- x if any of the operands has unknown x bits or z bits (if a or b contains X or Z)
|
|
|
|
|
|
Note: If any operand is x or z, then the result of that test is treated as false (0) |
|
|
|
|
|
|
|
|
|
|
|
Example : Relational Operators
|
|
|
|
|
|
1 program relational {
2 integer a = 5;
3 bit [7:0] b = 10;
4 bit [3:0] c = 4'b10zx;
5 printf (" %4d <= %8d = %b\n", a,b,(a <= b));
6 printf (" %4d >= %8d = %b\n", a,b,(a >= b));
7 printf (" %b <= %b = %b\n", c,b,(c <= b));
8 printf (" %b <= %b = %b\n", c,b,(c <= b));
9 }
You could download file relational.vr here
|
|
|
|
|
|
Simulation : Relational Operators
|
|
|
|
|
|
5 <= 10 = 1
5 >= 10 = 0
10zx <= 00001010 = x
10zx <= 00001010 = x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|