corelogic: multimux module

This commit is contained in:
Sebastien Bourdeauducq 2011-12-08 23:04:34 +01:00
parent b0c5b74c22
commit b2bc5ad4f4
1 changed files with 13 additions and 0 deletions

View File

@ -0,0 +1,13 @@
from migen.fhdl import structure as f
def MultiMux(sel, inputs, output):
n = len(inputs)
i = 0
comb = []
for osig in output:
choices = [x[i] for x in inputs]
cases = [(f.Constant(j, sel.bv), [f.Assign(osig, choices[j])]) for j in range(n)]
default = cases.pop()[1]
comb.append(f.Case(sel, cases, default))
i += 1
return comb