Code conversion
The amaranth.lib.coding
module provides building blocks for conversion between different encodings of binary numbers.
One-hot coding
- class amaranth.lib.coding.Encoder
Encode one-hot to binary.
If one bit in
i
is asserted,n
is low ando
indicates the asserted bit. Otherwise,n
is high ando
is0
.
- class amaranth.lib.coding.Decoder
Decode binary to one-hot.
If
n
is low, only thei
-th bit ino
is asserted. Ifn
is high,o
is0
.
Priority coding
- class amaranth.lib.coding.PriorityEncoder
Priority encode requests to binary.
If any bit in
i
is asserted,n
is low ando
indicates the least significant asserted bit. Otherwise,n
is high ando
is0
.