quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bullet_green_ball.gif Introduction

Like Verilog and VHDL, Vera supports following operators.

   

space.gif

  • Arithmetic Operators
  • Bitwise Operators
  • Logical Operators
  • Relational Operators
  • Equality Operators
  • Reduction Operators
  • Shift Operators
  • Increment and Decrement Operators
  • Concatenation Operators
  • Conditional Operators
  • Operator Precedence
   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Arithmetic Operators

The Vera arithmetic operators (+ - * / % and unary -) perform the respective operations on the two's complement representation of their operands. Operands must be of integral type, and the integer X value is interpreted as 32'bx. The result is of type integer if all operands are of type integer or enum, and is of type bit vector if any operand is a reg or bit vector. If any operand contains an unknown (x) or high impedence (z) values, the result becomes unknown (x). The unary arithmetic operator (-) takes precedence over the binary arithmetic operators.

   

space.gif

  • + : Addition
  • - : Subtraction
  • * : Multiplication
  • / : Division
  • % : Modulo
  • Unary - : Invert the sign of value on LHS.
   

space.gif

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

space.gif


  1 program arithmetic {
  2   integer a,b,c;
  3   bit [15:0] d,e,f;
  4   integer ra,rs,rm,rd,rmo;
  5   a = 10;
  6   b = 100;
  7   c = 1000;
  8   d = 2;
  9   e = 20;
 10   f = 200;
 11   // Binary operators
 12   ra = a + b; // Addition
 13   rs = a - b; // Subtraction
 14   rm = c * d; // Multiplication
 15   rd = f / b; // Divion
 16   rmo = b % 3; // Modulo
 17 
 18   printf("Binary Addition      of %5d with %5d is %5d\n",a,b,ra);
 19   printf("Binary Subtraction   of %5d with %5d is %5d\n",a,b,rs);
 20   printf("Binary Muliplication of %5d with %5d is %5d\n",c,d,rm);
 21   printf("Binary Divion        of %5d with %5d is %5d\n",f,b,rd);
 22   printf("Binary Modulo        of %5d with %5d is %5d\n",b,3,rmo);
 23    
 24   // Unary operators
 25   ra = - rs; // Assigning Negative value of rs
 26   rs = - b;  // Assigning Negative value of b
 27 
 28   printf("Unary  -             of %5d            is %5d\n",(a-b),ra);
 29   printf("Unary  -             of %5d            is %5d\n",b,rs);
 30 
 31 }
You could download file arithmetic.vr here
   

space.gif

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

space.gif

 Binary Addition      of    10 with   100 is   110
 Binary Subtraction   of    10 with   100 is   -90
 Binary Muliplication of  1000 with     2 is  2000
 Binary Divion        of   200 with   100 is     2
 Binary Modulo        of   100 with     3 is     1
 Unary  -             of   -90            is    90
 Unary  -             of   100            is  -100
   

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