Skip to content

Instantly share code, notes, and snippets.

@pervognsen
Last active July 30, 2018 12:47
Show Gist options
  • Save pervognsen/a66e88ae35c5ebf9ae3b5d2cf9b939be to your computer and use it in GitHub Desktop.
Save pervognsen/a66e88ae35c5ebf9ae3b5d2cf9b939be to your computer and use it in GitHub Desktop.
def funnel_shifter_unit(x, n, dir, shift, arith):
s = rep(arith & x[-1], len(x)-1)
low = when(dir, x[:-1], when(shift, s, x[1:]))
mid = when(dir, x[-1], x[0])
high = when(dir, when(shift, s, x[:-1]), x[1:])
return funnel_shifter(low @ mid @ high, when(dir, n, ~n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment