File : w_mul.ads
1 ------------------------------------------------------------------------------
2 ------------------------------------------------------------------------------
3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
4 -- --
5 -- (C) 2018 Stanislav Datskovskiy ( www.loper-os.org ) --
6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
7 -- --
8 -- You do not have, nor can you ever acquire the right to use, copy or --
9 -- distribute this software ; Should you use this software for any purpose, --
10 -- or copy and distribute it to anyone or in any manner, you are breaking --
11 -- the laws of whatever soi-disant jurisdiction, and you promise to --
12 -- continue doing so for the indefinite future. In any case, please --
13 -- always : read and understand any software ; verify any PGP signatures --
14 -- that you use - for any purpose. --
15 -- --
16 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
17 ------------------------------------------------------------------------------
18 ------------------------------------------------------------------------------
19
20 with Words; use Words;
21
22
23 package W_Mul is
24
25 pragma Pure;
26
27 -- The bitness of a Half-Word
28 HalfBitness : constant Positive := Bitness / 2;
29 subtype HalfWord is Word range 0 .. 2**HalfBitness;
30
31 -- The number of bytes in a Half-Word
32 HalfByteness : constant Positive := Byteness / 2;
33
34 -- Multiply half-words X and Y, producing a Word-sized product (Iron)
35 function Mul_HalfWord_Iron(X : in HalfWord; Y : in HalfWord) return Word;
36 pragma Inline_Always(Mul_HalfWord_Iron);
37
38 -- Multiply half-words X and Y, producing a Word-sized product (Egyptian)
39 function Mul_HalfWord_Soft(X : in HalfWord; Y : in HalfWord) return Word;
40 pragma Inline_Always(Mul_HalfWord_Soft);
41
42 -- Get the bottom half of a Word
43 function BottomHW(W : in Word) return HalfWord;
44 pragma Inline_Always(BottomHW);
45
46 -- Get the top half of a Word
47 function TopHW(W : in Word) return HalfWord;
48 pragma Inline_Always(TopHW);
49
50 -- Carry out X*Y mult, return lower word XY_LW and upper word XY_HW (Iron)
51 procedure Mul_Word(X : in Word; Y : in Word;
52 XY_LW : out Word; XY_HW : out Word);
53 pragma Inline_Always(Mul_Word);
54
55 -- Carry out X*X squaring, return lower word XX_LW and upper word XX_HW.
56 procedure Sqr_Word(X : in Word;
57 XX_LW : out Word;
58 XX_HW : out Word);
59 pragma Inline_Always(Sqr_Word);
60
61 end W_Mul;