Unit 1c

Creating the Shifter Sub-Block

The Shifter

The Shifter block, as the name implies, is responsible for taking the input operand, A, and shifting it either left or right by a number of bits specified by the SHAMT_HIGH and SHAMT inputs. SHAMT_HIGH and SHAMT is interpreted as a six-bit unsigned integer, thus allowing us to shift the input by zero to sixty-three bits.

The direction is specified by the higher order control bit:

  • ALUOp(1) = 0 means shift left
  • ALUOp(1) = 1 means shift right
  • In addition to direction, we must also specify whether the shift is arithmetic or logical, but this is only meaningful for right shifts. A logical shift fills the bits vacated at the end with zeros. An arithmetic shift fills the bits vacated at the left end on a right shift with copies of the sign bit, since for signed twos complement integers all bits to the left of the represented number are considered to be the same as the sign. Arithmetic right shifts allow a right shift on a signed integer to be interpreted as a division by 2**(SHAMT_HIGH concatenated with SHAMT). There is no special arithmetic left shift (corresponding to a multiply by 2**(SHAMT_HIGH concatenated with SHAMT)) because all of the bits to the right of the binary point are considered to be zeros.

    The type of shift is specified by the ALUOp(0) control bit:

  • ALUOp(0) = 0 means a logical shift
  • ALUOp(0) = 1 means an arithmetic shift
  • ALUOp(0) should never be equal to one at the same time as ALUOp(1) is equal to zero. This will be ensured by the control unit.

    Implementing the Shifter with a Flowchart

    We will be implementing the Shifter block with a Flowchart view. A flowchart view creates a VHDL process block containing sequential statements to describe the behavior. Sequential VHDL statements can only be found within special constructs called processes. Within a process, these statements are executed, as the name implies, sequentially. They consist of such statements as if..then..else, case, and wait.