|  |  | 
 | 
|  |  |  | 
|  |  | 
 | 
|  |  | e Operators | 
 
|  |  | e language includes all the operators of the regular programming language, and few additional ones.
 | 
|  |  | 
 | 
|  |  | Bit Wise Operators | 
 
|  |  | Bit wise operators work at bit level, so they are called bit wise operators. Below table list each operator and its description.
 | 
|  |  | 
 | 
|  |  | 
| Operator  |  Description
 |  
| ~ | Unary bitwise negation
 |  
| & | Binary bitwise AND
 |  
| | | Binary bitwise OR
 |  
| ^ | Binary bitwise XOR
 |  
| >> | Shift bits right
 |  
| << | Shift bits left 
 |  | 
|  |  | 
 | 
|  |  | Example - Bit Wise Operator | 
 
|  |  | 
 | 
|  |  | 
  1 <'
  2 extend sys {
  3  run() is also {
  4    var a : byte;
  5    var b : byte;
  6    var c : byte;
  7    a = 0xAA;
  8    b = 0x55;
  9    outf (" a = %b b = %b\n", a, b);
 10    // Bitwise negation
 11    c = ~a;
 12    outf ("Bitwise negation a  is     :%b\n", c);
 13    // Bitwise AND operation
 14    c = a & b;
 15    outf ("Bitwise AND of a with b is :%b\n", c);
 16    // Bitwise OR operation
 17    c = a | b;
 18    outf ("Bitwise OR of a with b is  :%b\n", c);
 19    // Bitwise XOR operation
 20    c = a ^ b;
 21    outf ("Bitwise XOR of a with b is :%b\n", c);
 22    // Left shift
 23    c = a << 2;
 24    outf ("Left shift a by 2 bits is  :%b\n", c);
 25    // Right shift
 26    c = b >> 2;
 27    outf ("Right shift b by 2 bits is :%b\n", c);
 28  };
 29 };
 30 '>
You could download file e_basics5.e
 here | 
|  |  | 
 | 
|  |  | Specman Output | 
 
|  |  | 
 | 
|  |  |  a = 10101010 b = 1010101
Bitwise negation a  is     :1010101
Bitwise AND of a with b is :0
Bitwise OR of a with b is  :11111111
Bitwise XOR of a with b is :11111111
Left shift a by 2 bits is  :10101000
Right shift b by 2 bits is :10101
 | 
|  |  | 
 | 
|  |  | Boolean Operators | 
 
|  |  | Boolean operators are used in condition checking as in other languages. Below table shows e boolean operators
 | 
|  |  | 
 | 
|  |  | 
| Operator  |  Description
 |  
| ! (not)  | Returns TRUE when an expression evaluates to FALSE, and vice versa. 
 |  
| && (and) | Returns TRUE if two expressions are both TRUE. 
 |  
| || (or)  | Returns TRUE if one of two expressions is TRUE. 
 |  
| =>  | Returns TRUE when the first expression of two expressions is FALSE, or when both expressions are TRUE. 
 |  
| now  | Returns TRUE if an event has occurred in the current cycle.
 |  | 
|  |  | 
 | 
|  |  | Example - Boolean Operators | 
 
|  |  | 
 | 
|  |  | 
  1 <'
  2 extend sys {
  3  run() is also {
  4    var a : bool;
  5    var b : bool;
  6    var c : bool;
  7    var d : bool;
  8    outf (" a = %b b = %b c = %b\n", a, b,c);
  9    // Not Operator
 10    d =  ! (TRUE);
 11    outf ("Not of  (TRUE) is     :%b\n", d);
 12    // Boolean AND operation
 13    d = a && c;
 14    outf ("Boolean AND of a with c is :%b\n", d);
 15    // Boolean OR operation
 16    d = a || b;
 17    outf ("Boolean OR of a with b is  :%b\n", d);
 18    // Boolean implication operation
 19    d = (2 > 3) => (3 > 2);
 20    outf ("Boolean implication of (2 > 3) => (3 > 2) :%b\n", d);
 21    // Boolean implication operation
 22    d = (4 > 3) => (3 > 4);
 23    outf ("Boolean implication of (4 > 3) => (3 > 4) :%b\n", d);
 24    // Below code does not make sense
 25    if now @sys.any then {
 26     out("sys.any occurred");
 27    };
 28  };
 29 };
 30 '>
You could download file e_basics6.e
 here | 
|  |  | 
 | 
|  |  |  | 
|  |  | 
 | 
|  |  | Specman Output | 
 
|  |  | 
 | 
|  |  |  a = 0 b = 0 c = 0
Not of  (TRUE) is     :0
Boolean AND of a with c is :0
Boolean OR of a with b is  :0
Boolean implication of (2 > 3) => (3 > 2) :1
Boolean implication of (4 > 3) => (3 > 4) :0
 | 
|  |  | 
 | 
|  |  | Arithmetic Operators | 
 
|  |  | Arithmetic operators are same in any other programming language.
 | 
|  |  | 
 | 
|  |  | 
| Operator  |  Description
 |  
| Unary +   |  Unary plus
 |  
| Unary -   |  Unary minus
 |  
| +         |  Binary addition
 |  
| -         |  Binary addition
 |  | 
|  |  | 
 | 
|  |  | Example - Arithmetic Operators | 
 
|  |  | 
 | 
|  |  | 
  1 <'
  2 extend sys {
  3  run() is also {
  4    out("10    = ",+10);
  5    out("-10   = ",-10);
  6    out("10+10 = ", 10 +10);
  7    out("10-1  = ", 10 -1);
  8    out("10*2  = ", 10 *2);
  9    out("10/2  = ", 10 /2);
 10    out("10%3  = ", 10 %3);
 11  };
 12 };
 13 '>
You could download file e_basics7.e
 here | 
|  |  | 
 | 
|  |  | Specman Output | 
 
|  |  | 
 | 
|  |  | 10    = 10
-10   = -10
10+10 = 20
10-1  = 9
10*2  = 20
10/2  = 5
10%3  = 1
 | 
|  |  | 
 | 
|  |  | Comparison Operators | 
 
|  |  | Same as in Verilog, and few more 
 | 
|  |  | 
 | 
|  |  | 
| Operator  |  Description
 |  
| <<=>>=  |  Compares two numeric expressions or HDL pathnames.
 |  
|  == !=  |  Determines whether two expressions are equal or not. 
 |  
| === !== | Performs a 4-state, Verilog-style comparison of HDL objects. 
 |  
| ~ !~    | Determines whether two string expressions are equal or not. 
 |  
| in  | Determines whether an expression is in a list or a range.
 |  | 
|  |  | 
 | 
|  |  | String Matching | 
 
|  |  | String matching is performed with AWK-style regular expressions. You can use the standard AWK regular expression notation to write complex patterns. This notation uses the  /&/  format for the pattern to specify AWK-style regular expression syntax.
 | 
|  |  | 
 | 
|  |  | 
 | 
|  |  | Extraction and Concatenation Operators | 
 
|  |  | 
 | 
|  |  | 
| Operator  |  Description
 |  
| [ ]  | Extracts or sets a single item from a list. 
 |  
| [ ; ]  | Extracts or sets consecutive bits or slices of a scalar, a list of bits, or a list of bytes. 
 |  
| [ .. ]  | List slicing operator 
 |  
| [ range,...]  |  Range list operator 
 |  
| { ; }  | List concatenation 
 |  
| %{&}  |  Bit concatenation
 |  | 
|  |  | 
 | 
|  |  | 
 | 
|  |  | 
 | 
|  |  |  | 
|  |  | 
 |