324 Chapter Thirteen
Shift
The next device to be described is the shiftentity. The shiftentity is
used to perform shifting and rotation operations within the CPU. The
shiftentity has a 16-bit input bus, a 16-bit output bus, and a selinput
that determines which shift operation to perform. This is shown by the
symbol in Figure 13-9.
The types of shift operations that can be performed by the shiftentity
are shown in Figures 13-10 and 13-11.
As can be seen by the figures, the shiftentity can perform a shift left,
shift right, rotate left, and rotate right operation. One operation that is
not shown by the figures is a pass through operation in which all input
bits are passed through to the output unchanged. Following is an entity
that performs these operations:
library IEEE;
use IEEE.std_logic_1164.all;
use work.cpu_lib.all;
entity shift is
port ( a : in bit16;
port( sel : in t_shift;
port( y : out bit16);
end shift;
architecture rtl of shift is
begin
shftproc: process(a, sel)
begin
case sel is
when shftpass =>
y <= a after 1 ns;
when shl =>
y <= a(14 downto 0) & ‘ 0 ’ after 1 ns;
when shr =>
y <= ‘ 0 ’ & a(15 downto 1) after 1 ns;
y
a
sel
Shift
Figure 13-9
Shift Symbol.