from migen.fhdl.std import * """ Encoders and decoders between binary and one-hot representation i: input (binary or one-hot) o: output (one-hot or binary) n: "none" signal (in/out), binary value is invalid """ class Encoder(Module): def __init__(self, width): self.i = Signal(width) # one-hot self.o = Signal(max=width) # binary self.n = Signal() # invalid: none or multiple act = dict((1<