corelogic: multimux module
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Thu, 8 Dec 2011 22:04:34 +0000 (23:04 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Thu, 8 Dec 2011 22:04:34 +0000 (23:04 +0100)
migen/corelogic/multimux.py [new file with mode: 0644]

diff --git a/migen/corelogic/multimux.py b/migen/corelogic/multimux.py
new file mode 100644 (file)
index 0000000..9db49b7
--- /dev/null
@@ -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
\ No newline at end of file