quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Relational Operators

Relational operators are used with if, while statements. Relational operators like in Verilog, return true or fales of relation being checked.

   

space.gif

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

   

space.gif

  • 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)
   

space.gif

Note: If any operand is x or z, then the result of that test is treated as false (0)

   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example : Relational Operators
   

space.gif


 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
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation : Relational Operators
   

space.gif

     5  <=        10 = 1
     5  >=        10 = 0
  10zx  <=  00001010 = x
  10zx  <=  00001010 = x
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com