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
iis asserted,nis low andoindicates the asserted bit. Otherwise,nis high andois0.
- class amaranth.lib.coding.Decoder
Decode binary to one-hot.
If
nis low, only thei-th bit inois asserted. Ifnis high,ois0.
Priority coding
- class amaranth.lib.coding.PriorityEncoder
Priority encode requests to binary.
If any bit in
iis asserted,nis low andoindicates the least significant asserted bit. Otherwise,nis high andois0.