# [libre-riscv-dev] [Bug 173] dynamic partitioned "shift"

bugzilla-daemon at libre-riscv.org bugzilla-daemon at libre-riscv.org
Fri Feb 14 17:39:23 GMT 2020

```http://bugs.libre-riscv.org/show_bug.cgi?id=173

--- Comment #26 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Michael Nolan from comment #25)
> I did something similar (I think?) to your description/python code, but
> broken up into a couple parts

excellent.  it's getting complicated (the yosys graphs are unreadable when
at 100% zoom) so once we're happy with it i'll
break it down into modules.

> I first created a table of n partial results like so:
>
> # calculate shift amounts -
> s[0] = b[i]
> s[i] = Mux(gates[i-1], b[i], s[i-1])
>
> r[i] = a[i] << s[i] for i in range(n)

ah rats, you took out the "truncation" that i put on B.
ah well - that can (has to) go back in, btw, however with
the Switch statement removed that's well on the way

> Then I calculated the results by:
>
> o[0] = r[0]
> o[1] = r[1] | Mux(gates[0], 0, r[0])
> o[2] = r[2] | Mux(gates[1], 0, Mux(gates[0], 0, r[0]))
> etc.
>
> This reduced the gate count from 8k gates for a 64x8 shifter, to 1.7k, and I
> think I can do a bit better.

eeexxcellent, muhahaha

oh.. err... i thiiink i see what you did.  you actually selected
the correct "B" to perform the shift of the output, based on the
partition-info?

ee.... :)

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