[Libre-soc-bugs] [Bug 784] Implement cl* instructions for carry-less operations
bugzilla-daemon at libre-soc.org
bugzilla-daemon at libre-soc.org
Tue Apr 5 18:53:37 BST 2022
https://bugs.libre-soc.org/show_bug.cgi?id=784
--- Comment #13 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Luke Kenneth Casson Leighton from comment #5)
> 73 for i in range(self.width):
> 74 with m.Switch(Cat(self.a[i], self.b[i])):
> 75 with m.Case('11'):
> 76 # both have no leading zeros so far, so set carry
> 77 m.d.comb += [
> 78 addend1[i].eq(1),
> 79 addend2[i].eq(1),
> 80 ]
> 81 with m.Case('01', '10'):
> 82 # different number of leading zeros, so clear carry
> 83 m.d.comb += [
> 84 addend1[i].eq(0),
> 85 addend2[i].eq(0),
> 86 ]
> 87 with m.Case('00'):
> 88 # propagate results from lower bits
> 89 m.d.comb += [
> 90 addend1[i].eq(1),
> 91 addend2[i].eq(0),
> 92 ]
>
> that's just:
>
> comb += addend1.eq(a ^ b)
> comb += addend2.eq(a | b)
I explicitly have it more complex so I can explain all the cases and to match
1:1 with the reference algorithm.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the libre-soc-bugs
mailing list