[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
Mon Jan 4 04:33:10 GMT 2021


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

--- Comment #39 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
it is currently 4am so please do take that into consideratoon

to get the data into the correct order in the ALUs if it is stored in memory in
the "wrong" order then the bytereverse LD/ST operations are (or are not) used.

if the processor is in LE mode and the data in memory is BE ordered then the
bytereverse LDST operations are used. result: the data is in LE when stored in
the regfile

if the processor is in BE mode and the data in memory is BE ordered then the
standard non-reversing LDST opcodes are used ***AND THE THESE ARE ALL
PROGRAMMED TO PERFORM A SWAP BECAUSE THE PROCESSOR IS IN BE MODE***.  result:
data is in LE when stored in the regfile.

in each case: data is stored in LE order in the regfile.

actually what is done is that the MSR.BE flag is XORed with the LDST
bytereverse bit from the opcode.  it should be in the source code somewhere.

this is how it is done in microwatt, and it's how it's done in libresoc.

i already did the walkthrough but you missed the significance of the clarifying
statements about using bytereversed LD/ST.

again: the LE/BE ordering is a property of memory not of the ALUs or regfiles
and it is the responsibility of the programmer to use the right one.

the BE memory is inverted at the point of LD because that is where the size
(1,2,4,8 bytes) is known.

the use of the correct LD/ST instructions by the programmer take care of
removal of the reverse ordering.

thus, beyond that load point the treatment of the data is exactly the same
because in both cases it has been converted to the convention of always
internally operating in LE.

this is probably why you believe that i did not cover BE in the walkthrough,
when if you look at it again, in light of the explanation of LDST bytereverse
and how that is XORed with MSR.BE you will see what i did.

again: i reiterate: microwatt does this exact same trick, it's where i got it
from

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


More information about the Libre-SOC-ISA mailing list