Search This Blog

Wednesday 14 May 2014

Shift Operators in VHDL


Shift operators are playing very important role in VHDL language. It is very usefull to shift or rotate digits of binary numbers.

There are total six shifting operators in VHDL language.
  •  sll
    • It means Logical Shift Left.
    • It shifts the elements in the array by n places to left and fill vacanted positions with "0".
    • Ex
      • "1000_1010" sll 3 will give "0101_0000".
      • "1000_1010" sll -2 will give "0010_0010".
  • srl
    • It means Logical Shift Right.
    • It shifts the elements in the array by n places to right and fill vacanted positions with "0".
    • Ex
      • "1000_1111" srl 2 will give "0010_0011".
      • "1001_0111" srl -6 will give "1100_0000".
  • sla
    • It means Arithmatic Shift Left.
    • It shifts the elements in the array by n places to left and fill vacanted positions with a copy of the element at the end being vacated.
    • Ex
      • "0000_1100" sla 2 will give "0011_0000".
      • "0001_0001" sla 2 will give "0100_0111".
      • "0011_0000" sla -2 will give "0000_1100".
  • sra
    • It means Arithmatic Shift Right.
    • It shifts the elements in the array by n places to right and fill vacanted positions with a copy of the element at the end being vacated.
    • Ex
      • "0100_1011" sra 3 will give "0000_1001".
      • "1001_0111" sra 3 will give "1111_0010".
      • "0001_0001" sra -2 will give "0100_0111".
  • rol
    • It means Rotate Shift Left.
    • It shifts the elements in the array by n places to left and fill vacated positions with from these shifted bits.
    • Ex
      • "1001_0011" rol 1 will give "0010_0111".
      • "1001_0011" rol -1 will give "1100_1001".
  • ror
    • It means Rotate Shift Right.
    • It shifts the elements in the array by n places to right and fill vacated positions with from these shifted bits.
    • Ex
      • "1001_0011" ror 1 will give "1100_1001".
      • "1001_0011" ror -1 will give "0010_0111".

No comments:

Post a Comment