raw
ffa_ch3_shifts.kv       1 ------------------------------------------------------------------------------
ffa_ch3_shifts.kv 2 ------------------------------------------------------------------------------
ffa_ch3_shifts.kv 3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
ffa_ch3_shifts.kv 4 -- --
ffa_ch3_shifts.kv 5 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
ffa_ch3_shifts.kv 6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
ffa_ch3_shifts.kv 7 -- --
ffa_ch3_shifts.kv 8 -- You do not have, nor can you ever acquire the right to use, copy or --
ffa_ch3_shifts.kv 9 -- distribute this software ; Should you use this software for any purpose, --
ffa_ch3_shifts.kv 10 -- or copy and distribute it to anyone or in any manner, you are breaking --
ffa_ch3_shifts.kv 11 -- the laws of whatever soi-disant jurisdiction, and you promise to --
ffa_ch3_shifts.kv 12 -- continue doing so for the indefinite future. In any case, please --
ffa_ch3_shifts.kv 13 -- always : read and understand any software ; verify any PGP signatures --
ffa_ch3_shifts.kv 14 -- that you use - for any purpose. --
ffa_ch3_shifts.kv 15 -- --
ffa_ch3_shifts.kv 16 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
ffa_ch3_shifts.kv 17 ------------------------------------------------------------------------------
ffa_ch3_shifts.kv 18 ------------------------------------------------------------------------------
ffa_ch3_shifts.kv 19
ffa_ch3_shifts.kv 20 with W_Shifts; use W_Shifts;
ffa_ch3_shifts.kv 21
ffa_ch3_shifts.kv 22
ffa_ch3_shifts.kv 23 package body FZ_Shift is
ffa_ch3_shifts.kv 24
ffa_ch3_shifts.kv 25 --------------------------------------------------------------
ffa_ch3_shifts.kv 26 -- Shift Right
ffa_ch3_shifts.kv 27 --------------------------------------------------------------
ffa_ch3_shifts.kv 28
ffa_ch3_shifts.kv 29 -- ShiftedN := N >> Count (with Overflow Input and Output)
ffa_ch3_shifts.kv 30 procedure FZ_ShiftRight_O_I(N : in FZ;
ffa_ch3_shifts.kv 31 ShiftedN : out FZ;
ffa_ch3_shifts.kv 32 Count : in WBit_Index;
ffa_ch3_shifts.kv 33 Overflow : out Word;
ffa_ch3_shifts.kv 34 OF_in : in Word) is
ffa_ch3_shifts.kv 35 Ni : Word;
ffa_ch3_shifts.kv 36 Carry : Word := OF_in;
ffa_ch3_shifts.kv 37 begin
ffa_ch3_shifts.kv 38 for i in reverse N'Range loop
ffa_ch3_shifts.kv 39 Ni := N(i);
ffa_ch3_shifts.kv 40 ShiftedN(i) := Shift_Right(Ni, Count) or Carry;
ffa_ch3_shifts.kv 41 Carry := Shift_Left(Ni, Bitness - Count);
ffa_ch3_shifts.kv 42 end loop;
ffa_ch3_shifts.kv 43 Overflow := Carry;
ffa_ch3_shifts.kv 44 end FZ_ShiftRight_O_I;
ffa_ch3_shifts.kv 45 pragma Inline_Always(FZ_ShiftRight_O_I);
ffa_ch3_shifts.kv 46
ffa_ch3_shifts.kv 47
ffa_ch3_shifts.kv 48 -- ShiftedN := N >> Count (with Overflow Output only)
ffa_ch3_shifts.kv 49 procedure FZ_ShiftRight_O(N : in FZ;
ffa_ch3_shifts.kv 50 ShiftedN : out FZ;
ffa_ch3_shifts.kv 51 Count : in WBit_Index;
ffa_ch3_shifts.kv 52 Overflow : out Word) is
ffa_ch3_shifts.kv 53 begin
ffa_ch3_shifts.kv 54 FZ_ShiftRight_O_I(N, ShiftedN, Count, Overflow, 0);
ffa_ch3_shifts.kv 55 end FZ_ShiftRight_O;
ffa_ch3_shifts.kv 56 pragma Inline_Always(FZ_ShiftRight_O);
ffa_ch3_shifts.kv 57
ffa_ch3_shifts.kv 58
ffa_ch3_shifts.kv 59 -- ShiftedN := N >> Count (no Overflow output or input)
ffa_ch3_shifts.kv 60 procedure FZ_ShiftRight(N : in FZ;
ffa_ch3_shifts.kv 61 ShiftedN : out FZ;
ffa_ch3_shifts.kv 62 Count : in WBit_Index) is
ffa_ch3_shifts.kv 63 Overflow : Word;
ffa_ch3_shifts.kv 64 pragma Unreferenced(Overflow);
ffa_ch3_shifts.kv 65 begin
ffa_ch3_shifts.kv 66 FZ_ShiftRight_O_I(N, ShiftedN, Count, Overflow, 0);
ffa_ch3_shifts.kv 67 end FZ_ShiftRight;
ffa_ch3_shifts.kv 68 pragma Inline_Always(FZ_ShiftRight);
ffa_ch3_shifts.kv 69
ffa_ch3_shifts.kv 70 --------------------------------------------------------------
ffa_ch3_shifts.kv 71 -- Shift Left
ffa_ch3_shifts.kv 72 --------------------------------------------------------------
ffa_ch3_shifts.kv 73
ffa_ch3_shifts.kv 74 -- ShiftedN := N << Count (with Overflow Input and Output)
ffa_ch3_shifts.kv 75 procedure FZ_ShiftLeft_O_I(N : in FZ;
ffa_ch3_shifts.kv 76 ShiftedN : out FZ;
ffa_ch3_shifts.kv 77 Count : in WBit_Index;
ffa_ch3_shifts.kv 78 Overflow : out Word;
ffa_ch3_shifts.kv 79 OF_in : in Word) is
ffa_ch3_shifts.kv 80 Ni : Word;
ffa_ch3_shifts.kv 81 Carry : Word := OF_in;
ffa_ch3_shifts.kv 82 begin
ffa_ch3_shifts.kv 83 for i in N'Range loop
ffa_ch3_shifts.kv 84 Ni := N(i);
ffa_ch3_shifts.kv 85 ShiftedN(i) := Shift_Left(Ni, Count) or Carry;
ffa_ch3_shifts.kv 86 Carry := Shift_Right(Ni, Bitness - Count);
ffa_ch3_shifts.kv 87 end loop;
ffa_ch3_shifts.kv 88 Overflow := Carry;
ffa_ch3_shifts.kv 89 end FZ_ShiftLeft_O_I;
ffa_ch3_shifts.kv 90 pragma Inline_Always(FZ_ShiftLeft_O_I);
ffa_ch3_shifts.kv 91
ffa_ch3_shifts.kv 92
ffa_ch3_shifts.kv 93 -- ShiftedN := N << Count (with Overflow Output only)
ffa_ch3_shifts.kv 94 procedure FZ_ShiftLeft_O(N : in FZ;
ffa_ch3_shifts.kv 95 ShiftedN : out FZ;
ffa_ch3_shifts.kv 96 Count : in WBit_Index;
ffa_ch3_shifts.kv 97 Overflow : out Word) is
ffa_ch3_shifts.kv 98 begin
ffa_ch3_shifts.kv 99 FZ_ShiftLeft_O_I(N, ShiftedN, Count, Overflow, 0);
ffa_ch3_shifts.kv 100 end FZ_ShiftLeft_O;
ffa_ch3_shifts.kv 101 pragma Inline_Always(FZ_ShiftLeft_O);
ffa_ch3_shifts.kv 102
ffa_ch3_shifts.kv 103
ffa_ch3_shifts.kv 104 -- ShiftedN := N << Count (no Overflow output or input)
ffa_ch3_shifts.kv 105 procedure FZ_ShiftLeft(N : in FZ;
ffa_ch3_shifts.kv 106 ShiftedN : out FZ;
ffa_ch3_shifts.kv 107 Count : in WBit_Index) is
ffa_ch3_shifts.kv 108 Overflow : Word;
ffa_ch3_shifts.kv 109 pragma Unreferenced(Overflow);
ffa_ch3_shifts.kv 110 begin
ffa_ch3_shifts.kv 111 FZ_ShiftLeft_O_I(N, ShiftedN, Count, Overflow, 0);
ffa_ch3_shifts.kv 112 end FZ_ShiftLeft;
ffa_ch3_shifts.kv 113 pragma Inline_Always(FZ_ShiftLeft);
ffa_ch3_shifts.kv 114
ffa_ch3_shifts.kv 115 end FZ_Shift;