PACKAGE mypack IS
  SUBTYPE eightbit IS BIT_VECTOR(0 TO 7);
  SUBTYPE fourbit IS BIT_VECTOR(0 TO 3);
  FUNCTION shift_right(val : BIT_VECTOR)
    RETURN BIT_VECTOR;
END mypack;

PACKAGE BODY mypack IS
  FUNCTION shift_right(val : BIT_VECTOR) RETURN BIT_VECTOR IS
    VARIABLE result : BIT_VECTOR(0 TO (val'LENGTH - 1));
  BEGIN
    result := val;
    IF (val'LENGTH > 1) THEN
      FOR i IN 0 TO (val'LENGTH - 2) LOOP
        result(i) := result(i + 1);
      END LOOP;
      result(val'LENGTH - 1) := '0';
    ELSE
      result(0) := '0';
    END IF;
    RETURN result;
  END shift_right;
END mypack;


