[Libre-soc-isa] [Bug 560] big-endian little-endian SV regfile layout idea

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Tue Jan 5 03:51:49 GMT 2021


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

--- Comment #64 from Alexandre Oliva <oliva at libre-soc.org> ---
* ldbrx  LE: ordering of the MEANING in regfile is in {insert order}
* ldbrx  BE: ordering of the MEANING in regfile is in {insert order}

if data in memory is laid out in a way opposite to the selected CPU endianness,
with ldbrx you get the register set up as depicted in comment 60.


if it's laid out in a way that matches the selected CPU endianness,
you get these bits into the register:

1 * 2^{0} + 0 * 2^{1} + 0 * 2^{2} + 0 * 2^{3} + 0 * 2^{4} + 1 * 2^{5} + 0 *
2^{6} + 0 * 2^{7} + 0 * 2^{8} + 1 * 2^{9} + 0 * 2^{10} + 0 * 2^{11} + 0 *
2^{12} + 1 * 2^{13} + 0 * 2^{14} + 0 * 2^{15} + 1 * 2^{16} + 1 * 2^{17} + 0 *
2^{18} + 0 * 2^{19} + 0 * 2^{20} + 1 * 2^{21} + 0 * 2^{22} + 0 * 2^{23} + 0 *
2^{24} + 0 * 2^{25} + 1 * 2^{26} + 0 * 2^{27} + 0 * 2^{28} + 1 * 2^{29} + 0 *
2^{30} + 0 * 2^{31} + 1 * 2^{32} + 0 * 2^{33} + 1 * 2^{34} + 0 * 2^{35} + 0 *
2^{36} + 1 * 2^{37} + 0 * 2^{38} + 0 * 2^{39} + 0 * 2^{40} + 1 * 2^{41} + 1 *
2^{42} + 0 * 2^{43} + 0 * 2^{44} + 1 * 2^{45} + 0 * 2^{46} + 0 * 2^{47} + 1 *
2^{48} + 1 * 2^{49} + 1 * 2^{50} + 0 * 2^{51} + 0 * 2^{52} + 1 * 2^{53} + 0 *
2^{54} + 0 * 2^{55} + 0 * 2^{56} + 0 * 2^{57} + 0 * 2^{58} + 1 * 2^{59} + 0 *
2^{60} + 1 * 2^{61} + 0 * 2^{62} + 0 * 2^{63}

AKA:

0 * 2^{63} + 0 * 2^{62} + 1 * 2^{61} + 0 * 2^{60} + 1 * 2^{59} + 0 * 2^{58} + 0
* 2^{57} + 0 * 2^{56} + 0 * 2^{55} + 0 * 2^{54} + 1 * 2^{53} + 0 * 2^{52} + 0 *
2^{51} + 1 * 2^{50} + 1 * 2^{49} + 1 * 2^{48} + 0 * 2^{47} + 0 * 2^{46} + 1 *
2^{45} + 0 * 2^{44} + 0 * 2^{43} + 1 * 2^{42} + 1 * 2^{41} + 0 * 2^{40} + 0 *
2^{39} + 0 * 2^{38} + 1 * 2^{37} + 0 * 2^{36} + 0 * 2^{35} + 1 * 2^{34} + 0 *
2^{33} + 1 * 2^{32} + 0 * 2^{31} + 0 * 2^{30} + 1 * 2^{29} + 0 * 2^{28} + 0 *
2^{27} + 1 * 2^{26} + 0 * 2^{25} + 0 * 2^{24} + 0 * 2^{23} + 0 * 2^{22} + 1 *
2^{21} + 0 * 2^{20} + 0 * 2^{19} + 0 * 2^{18} + 1 * 2^{17} + 1 * 2^{16} + 0 *
2^{15} + 0 * 2^{14} + 1 * 2^{13} + 0 * 2^{12} + 0 * 2^{11} + 0 * 2^{10} + 1 *
2^{9} + 0 * 2^{8} + 0 * 2^{7} + 0 * 2^{6} + 1 * 2^{5} + 0 * 2^{4} + 0 * 2^{3} +
0 * 2^{2} + 0 * 2^{1} + 1 * 2^{0}

AKA:

0x2827262524232221 = 2893323226570760737

these are also the values you get into a register if you use ld to transfer
from memory data that's laid out with the endianness opposite to the one
selected in the CPU

it's worth pointing out that CPU endianness and ldbrx reverses bytes, but not
bits as one might expect.  that's not entirely surprising, considering that
bytes are the minimum addressable unit in memory, and opcodes that select,
shift and otherwise identify bits operate on a basis of significance rather
than endianness.  e.g., shifting left moves bits to more significant positions,
whether the CPU is in big or little endian mode.

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


More information about the Libre-SOC-ISA mailing list