[Libre-soc-dev] SVP64 Vectorised add-carry => big int add

lkcl luke.leighton at gmail.com
Mon Apr 18 17:46:44 BST 2022

On Mon, Apr 18, 2022 at 5:23 PM Jacob Lifshay <programmerjake at gmail.com> wrote:
> yes...there's 2 problems:
> 1. sum is uninitialized -- did you even compile with warnings enabled?!

no of course not: gcc test.c; ./a.out

> (another UB trap in C, if you had used Rust or basically any
> good language it would have not let you compile that).

don't. please. i'm having a really bad day.

> 2. the algorithm I gave requires carry to start at 1
> -- just like subfe does (subfe uses RT <- ~RA + RB + CA).
> that's because -x == ~x + 1 for all integers x.
> I'm trying to have the algorithm be like subfe since that likely gives simpler
> hardware, otherwise I'd just have it use the CARRY register as a borrow
> value like the original algorithm in that c you added from hackers' delight

ok i corrected it: still no dice.  i think the reason for that is that "t" is
not being set correctly: t is supposed to be used later, if is -ve, then
1 is added back onto un[].

it's almost there:

Error, dividend u = 80000000 00000000 00000003
       divisor  v = 20000000 00000000 00000001
For quotient,  got: 00000004
        Should get: 00000003

Error, dividend u = 80000000 00000000 fffffffe 00000000
       divisor  v = 80000000 00000000 ffffffff
For quotient,  got: 00000001 fffffffd
        Should get: 00000000 ffffffff

More information about the Libre-soc-dev mailing list