Package: LSC.Ops32

Dependencies

with LSC.Types;
use type LSC.Types.Word32;
use type LSC.Types.Index;
 inherit
    LSC.Types;

Description

Operations over 32-bit words

Header

package LSC.Ops32 is
 

Other Items:

function Bytes_To_Word
   (Byte0 : Types.Byte;
    Byte1 : Types.Byte;
    Byte2 : Types.Byte;
    Byte3 : Types.Byte) return Types.Word32;
pragma Inline (Bytes_To_Word);
Convert the four byte values Byte0, Byte1, Byte2 and Byte3 to a 32-bit word

function ByteX (Value    : Types.Word32;
                Position : Types.Byte_Array32_Index) return Types.Byte;
pragma Inline (ByteX);
Return a byte at Position of the 32-bit word Value

function Byte0 (Value : Types.Word32) return Types.Byte;
pragma Inline (Byte0);
Return the first byte of the 32-bit word Value

function Byte1 (Value : Types.Word32) return Types.Byte;
pragma Inline (Byte1);
Return the second byte of the 32-bit word Value

function Byte2 (Value : Types.Word32) return Types.Byte;
pragma Inline (Byte2);
Return the third byte of the 32-bit word Value

function Byte3 (Value : Types.Word32) return Types.Byte;
pragma Inline (Byte3);
Return the fourth byte of the 32-bit word Value

function XOR2 (V0, V1 : Types.Word32) return Types.Word32;
pragma Inline (XOR2);
Perform XOR on two 32-bit words V0 and V1
 return V0 xor V1;

function XOR3 (V0, V1, V2 : Types.Word32) return Types.Word32;
pragma Inline (XOR3);
Perform XOR on three 32-bit words V0, V1 and V2
 return V0 xor V1 xor V2;

function XOR4 (V0, V1, V2, V3 : Types.Word32) return Types.Word32;
pragma Inline (XOR4);
Perform XOR on four 32-bit words V0, V1, V2 and V3
 return V0 xor V1 xor V2 xor V3;

function XOR5 (V0, V1, V2, V3, V4 : Types.Word32) return Types.Word32;
pragma Inline (XOR5);
Perform XOR on four 32-bit words V0, V1, V2, V3 and V4
 return V0 xor V1 xor V2 xor V3 xor V4;

procedure Block_XOR
  (Left   : in     Types.Word32_Array_Type;
   Right  : in     Types.Word32_Array_Type;
   Result :    out Types.Word32_Array_Type);
pragma Inline (Block_XOR);
Perform XOR on two arrays of 32-bit words

Left - First input array
Right - Second input array
Result - Result array

 derives
   Result from Left, Right;
 pre
   Left'First  = Right'First and
   Left'Last   = Right'Last  and
   Right'First = Result'First and
   Right'Last  = Result'Last;
 post
   (for all I in Types.Index range Left'First .. Left'Last =>
        (Result (I) = XOR2 (Left (I), Right (I))));

procedure Block_Copy
   (Source : in     Types.Word32_Array_Type;
    Dest   : in out Types.Word32_Array_Type);
pragma Inline (Block_Copy);
Copy all elements of Source to Dest. Should Source be shorter than Dest, remaining elements stay unchanged.
 derives
   Dest from *, Source;
 pre
   Source'First  = Dest'First and
   Source'Last  <= Dest'Last;
 post
   (for all P in Types.Index range Source'First .. Source'Last =>
       (Dest (P) = Source (P)));
end LSC.Ops32;