package DP32_TYPES is subtype BIT_8 is BIT_VECTOR(7 downto 0) ; subtype CC_BITS is BIT_VECTOR(2 downto 0) ; subtype cm_BITS is BIT_VECTOR(3 downto 0) ; -- **** !!! probl‚me de r‚solution sur types composites -- subtype BIT_32 is BIT_VECTOR(31 downto 0) ; -- type BIT_32_ARRAY is array(NATURAL range <>) of BIT_32 ; -- function RESOLVE_BIT_32(DRIVE : BIT_32_ARRAY) return BIT_32 ; -- subtype BUS_BIT_32 is RESOLVE_BIT_32 BIT_32 ; -- ***** remplacement par des tableaux de bit r‚solus a faire -- ***** fin modifs type BOOL_TO_BIT_TABLE is array(BOOLEAN) of BIT ; function BITS_TO_INT(BITS : in BIT_VECTOR) return INTEGER ; function BITS_TO_NAT(BITS : in BIT_VECTOR) return NATURAL ; procedure INT_TO_BITS(INT : in INTEGER ;BITS : out BIT_VECTOR) ; constant BOOL_TO_BIT : BOOL_TO_BIT_TABLE ; constant OP_ADD : BIT_8 := X"00" ; constant OP_SUB : BIT_8 := X"01" ; constant OP_MUL : BIT_8 := X"02" ; constant OP_DIV : BIT_8 := X"03" ; constant OP_ADDq : BIT_8 := X"10" ; constant OP_SUBq : BIT_8 := X"11" ; constant OP_MULq : BIT_8 := X"12" ; constant OP_DIVq : BIT_8 := X"13" ; constant OP_Land : BIT_8 := X"04" ; constant OP_Lor : BIT_8 := X"05" ; constant OP_Lxor : BIT_8 := X"06" ; constant OP_Lmask : BIT_8 := X"07" ; constant OP_Ld : BIT_8 := X"20" ; constant OP_St : BIT_8 := X"21" ; constant OP_Ldq : BIT_8 := X"30" ; constant OP_Stq : BIT_8 := X"31" ; constant OP_Br : BIT_8 := X"40" ; constant OP_Bi : BIT_8 := X"41" ; constant OP_Brq : BIT_8 := X"50" ; constant OP_Biq : BIT_8 := X"51" ; end DP32_TYPES ; package body DP32_TYPES is constant BOOL_TO_BIT : BOOL_TO_BIT_TABLE := (FALSE => '0' ,TRUE => '1') ; function RESOLVE_BIT_32(DRIVE : in BIT_32_ARRAY) return BIT_32 is variable RESULT : BIT_32 := X"0000_0000" ; begin for i in DRIVE'range loop RESULT := RESULT or DRIVE(i) ; end loop ; return RESULT ; end RESOLVE_BIT_32 ; function BITS_TO_INT(BITS : in BIT_VECTOR) return INTEGER is variable TEMP : BIT_VECTOR(BITS'range) ; variable RESULT : INTEGER := 0 ; begin if BITS(BITS'left) = '1' then TEMP := not BITS ; else TEMP := BITS ; end if ; for i in TEMP'range loop if TEMP(i) = '0' then RESULT := RESULT*2 ; elsif TEMP(i) = '1' then RESULT := RESULT*2+1 ; end if ; end loop ; if BITS(BITS'left) = '1' then RESULT := (-RESULT)-1 ; end if ; return RESULT ; end BITS_TO_INT ; function BITS_TO_NAT(BITS : in BIT_VECTOR) return NATURAL is variable RESULT : NATURAL := 0 ; begin for i in BITS'range loop if BITS(i) = '0' then RESULT := RESULT*2 ; elsif BITS(i) = '1' then RESULT := RESULT*2+1 ; end if ; end loop ; return RESULT ; end BITS_TO_NAT ; procedure INT_TO_BITS(INT : in INTEGER ;BITS : out BIT_VECTOR) is variable TEMP : INTEGER ; variable RESULT : BIT_VECTOR(BITS'range) ; begin if INT<0 then TEMP := -(INT+1) ; else TEMP := INT ; end if ; for i in BITS'reverse_range loop RESULT(i) := BIT'val(TEMP rem 2) ; TEMP := TEMP/2 ; end loop ; if INT<0 then RESULT := not RESULT ; RESULT(BITS'left) := '1' ; end if ; BITS := RESULT ; end INT_TO_BITS ; end DP32_TYPES ;