OpenCores
URL https://opencores.org/ocsvn/thor/thor/trunk

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64v5/] [software/] [AS64/] [source/] [Int128.h] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 robfinch
#pragma once
2
 
3
class Int128
4
{
5
public:
6
        __int64 low;
7
        __int64 high;
8
public:
9
        static Int128 *Zero() {
10
                static Int128 zr;
11
                zr.low = 0LL;
12
                zr.high = 0LL;
13
                return (&zr);
14
        };
15
        static Int128 *One() {
16
                static Int128 zr;
17
                zr.low = 1LL;
18
                zr.high = 0LL;
19
                return (&zr);
20
        };
21
        static void Assign(Int128 *a, Int128 *b) {
22
                a->low = b->low;
23
                a->high = b->high;
24
        };
25
        //fnASCarry = op? (~a&b)|(s&~a)|(s&b) : (a&b)|(a&~s)|(b&~s);
26
        // Compute carry bit from 64 bit addition.
27
        static bool AddCarry(__int64 s, __int64 a, __int64 b) {
28
                return (((a&b)|(a&~s)|(b&~s)) >> 63LL);
29
        };
30
        // Compute carry bit from 64 bit subtraction.
31
        static bool SubBorrow(__int64 s, __int64 a, __int64 b) {
32
                return (((~a&b)|(s&~a)|(s&b)) >> 63LL);
33
        };
34
        // Add two 128 bit numbers.
35
        static bool Add(Int128 *sum, Int128 *a, Int128 *b);
36
        // Subtract two 128 bit numbers.
37
        static bool Sub(Int128 *sum, Int128 *a, Int128 *b);
38
        // Shift left one bit.
39
        static bool Shl(Int128 *o, Int128 *a);
40
        static bool Shr(Int128 *o, Int128 *a);
41
        static void Mul(Int128 *p, Int128 *a, Int128 *b);
42
        static void Div(Int128 *q, Int128 *r, Int128 *a, Int128 *b);
43
        static bool IsEqual(Int128 *a, Int128 *b);
44
        static bool IsLessThan(Int128 *a, Int128 *b);
45
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.