litex/migen/corelogic/multimux.py

14 lines
318 B
Python
Raw Normal View History

2011-12-16 15:30:14 -05:00
from migen.fhdl.structure import *
2011-12-08 17:04:34 -05:00
2011-12-16 10:02:55 -05:00
def multimux(sel, inputs, output):
2011-12-08 17:04:34 -05:00
n = len(inputs)
i = 0
comb = []
for osig in output:
choices = [x[i] for x in inputs]
2011-12-16 15:30:14 -05:00
cases = [[Constant(j, sel.bv), osig.eq(choices[j])] for j in range(n)]
cases[n-1][0] = Default()
comb.append(Case(sel, *cases))
2011-12-08 17:04:34 -05:00
i += 1
2011-12-16 10:02:55 -05:00
return comb