这是移位运算的一段代码,但是结果输出的时候,F3能够正常输出,CY2却输不出来,求大神帮帮忙
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY SHIFTER IS
PORT(S: IN STD_LOGIC_VECTOR(3 DOWNTO 0);
DATAA, DATAB: IN STD_LOGIC_VECTOR(7 DOWNTO 0);
F3: OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
FC, CN: IN STD_LOGIC;
CY2: OUT STD_LOGIC);
END SHIFTER;
ARCHITECTURE SHIFTER OF SHIFTER IS
BEGIN
PROCESS(S, DATAB)
VARIABLE TEMP : INTEGER range 0 to 255;
VARIABLE I : INTEGER range 0 to 7;
BEGIN
TEMP := 0;
I:=7;
FOR I IN 0 to 7 LOOP
CASE DATAB(I) IS
WHEN '0' => TEMP:=TEMP;
WHEN '1' => TEMP:=TEMP+2**I;
WHEN OTHERS =>EXIT;
END CASE;
END LOOP;
CASE S(2 DOWNTO 0) IS
WHEN "101" => F3<=DATAA((TEMP MOD 8 -1) DOWNTO 0) & DATAA(7 DOWNTO (TEMP MOD 8));
WHEN "110" =>
IF(CN = '0') THEN
F3<= '0' & DATAA(7 DOWNTO 1);
ELSIF(CN = '1') THEN
F3<= '0' & DATAA(7 DOWNTO 1);
CY2 <= DATAA(0);
ELSE
F3<=(OTHERS=>'Z');
END IF;
WHEN "111" =>
IF(CN = '0') THEN
F3<= DATAA(6 DOWNTO 0) & '0';
ELSIF(CN = '1') THEN
F3<= DATAA(6 DOWNTO 0) & '0';
CY2 <= DATAA(7);
ELSE
F3<=(OTHERS=>'Z');
END IF;
WHEN OTHERS => F3<=(OTHERS=>'Z');
END CASE;
END PROCESS;
END SHIFTER;