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

The SystemVerilog operators are a combination of Verilog and C operators. In both languages, the type and size of the operands is fixed, and hence the operator is of a fixed type and size. The fixed type and size of operators is preserved in SystemVerilog.

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Assignment operators

In addition to the simple assignment operator, =, SystemVerilog includes the C assignment operators and special bitwise assignment operators:

   

space.gif

  • +=
  • -=
  • *=
  • /=
  • %=
  • &=
  • |=
  • ^=
  • <<=
  • >>=
  • <<<=
  • >>>=
   

space.gif

An assignment operator is semantically equivalent to a blocking assignment, with the exception that any left hand side index expression is only evaluated once.

   

space.gif

assignment_operator ::= = | += | -= | *= | /= | %= | &= | |= | ^= 
  | <<= | >>= | <<<= | >>>=
conditional_expression ::= cond_predicate ? { attribute_instance } 
  expression : expression
unary_operator ::= + | - | ! | ~ | & | ~& | | | ~| | ^ | ~^ | ^~
binary_operator ::= + | - | * | / | % | == | != | === | !== | =?= | 
  !?= | && | || | ** | < | <= | > | >= | & 
   | | | ^ | ^~ | ~^ | >> | << | >>> | <<<
inc_or_dec_operator ::= ++ | --
unary_module_path_operator ::= ! | ~ | & | ~& | | | ~| | ^ | ~^ | ^~
binary_module_path_operator ::= == | != | && | || | & | | | ^ | ^~ | ~^
   

space.gif

  ../images/main/bullet_star_pink.gif Example - Assignment
   

space.gif


  1 module assignment_operator ();
  2 
  3 reg [31:0] a = 100;
  4 
  5 initial begin
  6   $display (" a         := %h",  a );  
  7   a += 4; 
  8   $display (" a += 4    := %h",  a );  
  9   a -= 4; 
 10   $display (" a -= 4    := %h",  a ); 
 11   a *= 4; 
 12   $display (" a *= 4    := %h",  a ); 
 13   a /= 4; 
 14   $display (" a /= 4    := %h",  a ); 
 15   a %= 17; 
 16   $display (" a %s= 17    := %h", "%", a ); 
 17   a &= 16'hFFFF; 
 18   $display (" a &= 16'hFFFF    := %h",  a ); 
 19   a |= 16'hFFFF; 
 20   $display (" a |= 16'hFFFF    := %h",  a ); 
 21   a ^= 16'hAAAA; 
 22   $display (" a ^= 16h'AAAA    := %h",  a ); 
 23   a <<= 4; 
 24   $display (" a <<= 4   := %h",  a ); 
 25   a >>= 4; 
 26   $display (" a >>= 4   := %h",  a ); 
 27   a <<<= 14; 
 28   $display (" a <<<= 14  := %h",  a ); 
 29   a >>>= 14; 
 30   $display (" a >>>= 14  := %h",  a );
 31    #1  $finish;
 32 end
 33 
 34 endmodule
You could download file assignment_operator.sv here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulator Output : Assignment
   

space.gif

  a         := 00000064
  a += 4    := 00000068
  a -= 4    := 00000064
  a *= 4    := 00000190
  a /= 4    := 00000064
  a %= 17    := 0000000f
  a &= 16'hFFFF    := 0000000f
  a |= 16'hFFFF    := 0000ffff
  a ^= 16h'AAAA    := 00005555
  a <<= 4   := 00055550
  a >>= 4   := 00005555
  a <<<= 14  := 15554000
  a >>>= 14  := 00005555
   

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