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 Shift Operators

Like in Verilog, VERA supports left and right shift operators as shown below.

   

space.gif

Operator

Description

<<

left shift

>>

right shift

   

space.gif

  • The left operand is shifted by the number of bit positions given by the right operand.
  • The vacated bit positions are filled with zeroes.
   

space.gif

   

space.gif

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

space.gif


  1 program shift {
  2   // Left Shift
  3   printf (" 4'b1001 << 1 = %b\n", (4'b1001 << 1));
  4   printf (" 4'b10x1 << 1 = %b\n", (4'b10x1 << 1));
  5   printf (" 4'b10z1 << 1 = %b\n", (4'b10z1 << 1));
  6   // Right Shift
  7   printf (" 4'b1001 >> 1 = %b\n", (4'b1001 >> 1));
  8   printf (" 4'b10x1 >> 1 = %b\n", (4'b10x1 >> 1));
  9   printf (" 4'b10z1 >> 1 = %b\n", (4'b10z1 >> 1));
 10 }
You could download file shift.vr here
   

space.gif

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

space.gif

  4'b1001 << 1 = 0010
  4'b10x1 << 1 = 0x10
  4'b10z1 << 1 = 0z10
  4'b1001 >> 1 = 0100
  4'b10x1 >> 1 = 010x
  4'b10z1 >> 1 = 010z
   

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