From: Robert Jördens Date: Thu, 27 Jun 2013 18:56:57 +0000 (-0600) Subject: genlib/coding.py: binary vs. one-hot, priority coding X-Git-Tag: 24jan2021_ls180~2099^2~547 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ecc40620715a996e57d3777f4a7cdeb2ad74697d;p=litex.git genlib/coding.py: binary vs. one-hot, priority coding --- diff --git a/migen/genlib/coding.py b/migen/genlib/coding.py new file mode 100644 index 00000000..559dab05 --- /dev/null +++ b/migen/genlib/coding.py @@ -0,0 +1,55 @@ +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<