From: Luke Kenneth Casson Leighton Date: Thu, 29 Mar 2018 13:08:13 +0000 (+0100) Subject: add migen safe input mux X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=33df46b23ceb8fe713f732f99c1f7ccbabe6d92e;p=pinmux.git add migen safe input mux --- diff --git a/src/migen/safeinmux.py b/src/migen/safeinmux.py new file mode 100644 index 0000000..75d10e7 --- /dev/null +++ b/src/migen/safeinmux.py @@ -0,0 +1,85 @@ +from functools import reduce +from math import log +from migen.fhdl.module import Module +from migen.fhdl.structure import Mux, Signal, Array, Constant, If, Case +from migen.fhdl import verilog +from migen.sim.core import run_simulation + +def orop(x1, x2): + return x1 | x2 + +class SafeInputMux(Module): + def __init__(self, inwidth): + wlog = int(log(inwidth, 2)) + self.inputs = Array() + for i in range(inwidth): + self.inputs.append(Signal(1, name_override="input_{}".format(i))) + self.output = Signal(name_override="output") + self.selector = Signal(max=inwidth + 1) + self.io = set(self.inputs) | set([self.output, self.selector]) + sel_r = Signal(max=inwidth + 1) + sel25 = Signal(max=1<