[Libre-soc-isa] [Bug 817] Big Integer Math (sv.adde, sv.subfe, sv.madded, 128 by 64-bit -> 64-bit div/rem, maybe more...)

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Wed Oct 12 16:30:51 BST 2022


https://bugs.libre-soc.org/show_bug.cgi?id=817

--- Comment #54 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
last demo/test/primitive needed, using sv.divmod:

  73 unsigned long bigdiv(unsigned v, unsigned q[], unsigned const u[], int m)
  74 {
  75     unsigned long long k = 0; // the case of a
  76     for (int j = m - 1; j >= 0; j--)
  77     { // single-digit
  78         unsigned long d2 = (k << 32) | u[j];
  79         q[j] = d2 / v; // divisor here.
  80         k = d2 % v;
  81     }
  82     return k;
  83 }

this should literally be just the one instruction.  the others
(sv.shl, sv shr, sv.madded) all have simple demos.

fascinatingly for ec25519 which only needs 256 bit arithmetic
not even loops are needed. 4x64-bit regs should be enough.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Libre-SOC-ISA mailing list