| 
 | 
|   | 
  | 
 
  | 
 
 | 
 | 
 
 | 
 
|   | 
  | 
 
  | 
 
|   | 
  | 
Shift Operators
 | 
  
 | 
 | 
Like in Verilog, VERA supports left and right shift operators as shown below.  | 
 
|   | 
  | 
 
  | 
 
 | 
 | 
| 
 Operator 
 | 
 Description 
 | 
 
| 
 <<   
 | 
 left shift 
 | 
 
| 
 >>   
 | 
 right shift 
 | 
 
 
 | 
 
|   | 
  | 
 
  | 
 
 | 
 | 
-     The left operand is shifted by the number of bit positions given by the right operand.
 
-     The vacated bit positions are filled with zeroes.
 
 
 | 
 
|   | 
  | 
 
  | 
 
 | 
 | 
 
 | 
 
|   | 
  | 
 
  | 
 
|   | 
  | 
Example : Shift Operators
 | 
  
|   | 
  | 
 
  | 
 
 | 
 | 
  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
 | 
 
|   | 
  | 
 
  | 
 
|   | 
  | 
Simulation :  Shift Operators
 | 
  
|   | 
  | 
 
  | 
 
 | 
 | 
  4'b1001 << 1 = 0010
  4'b10x1 << 1 = 0x10
  4'b10z1 << 1 = 0z10
  4'b1001 >> 1 = 0100
  4'b10x1 >> 1 = 010x
  4'b10z1 >> 1 = 010z
 
 | 
 
|   | 
  | 
 
  | 
 
|   | 
  | 
 
  | 
 
|   | 
  | 
 
  | 
 
 | 
 | 
 
 | 
 
|   | 
  | 
 
  | 
 
 
 
 | 
 | 
| 
  
  | 
  
  | 
  
  | 
| 
 
  
 | 
    | 
 
Copyright © 1998-2025  | 
 
Deepak Kumar Tala - All rights reserved  | 
 
| 
 Do you have any Comment? mail me at:deepak@asic-world.com
  | 
 
 
 
 |