[Libre-soc-bugs] [Bug 671] convert spec pseudocode to use XLEN width

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Mon Sep 6 15:02:08 BST 2021


https://bugs.libre-soc.org/show_bug.cgi?id=671

--- Comment #68 from Jacob Lifshay <programmerjake at gmail.com> ---
According to Wikipedia:
https://en.wikipedia.org/wiki/Densely_packed_decimal
(matches OpenPower/IEEE 754 definition of DPD)

DPD is designed so that one or two BCD digits can be encoded into DPD as just
the LSB 4 or 8 bits respectively, meaning that truncating the input/output of
cdtbcd and cbcdtd totally are useful and still cover all BCD digits:

elwidth=64:
use existing definition for compatibility

elwidth=32:
use LSB 32-bits of existing definition for compatibility with PowerPC 32-bit
ISAs

elwidth=16:
use LSB 16-bits of existing definition, you end up ignoring/zeroing the MSB 2
bits of the 16-bit DPD-side input/output for all valid BCD inputs:
cbcdtd:
    # for input digits 0-9, only lsb 4 bits of DPD are set;
    # idk for 0xA-0xF so keep extra bits anyway
    # for consistency with larger definition
    output = (BCD_TO_DPD(input >> 12) & 0x3F) << 10
    output |= BCD_TO_DPD(input & 0xFFF)
cdtbcd:
    output = (DPD_TO_BCD(input >> 10) & 0xF) << 12
    output |= DPD_TO_BCD(input & 0x3FF)

elwidth=8:
use LSB 8-bits of existing definition, all valid BCD inputs convert to DPD that
fits in 8-bits:
cbcdtd:
    # for input digits 0-9, only lsb 8 bits of DPD are set
    output = BCD_TO_DPD(input) & 0xFF
cdtbcd:
    output = DPD_TO_BCD(input) & 0xFF

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list