[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 08:04:55 GMT 2021
--- Comment #50 from Alexandre Oliva <oliva at libre-soc.org> ---
ok, I can tell you've got the concept of significance all confused with
Significance has to do with the quantity the symbol stands for, not with its
Consider our numbering system: 123 stands for one hundred, twenty-three. The
positional systems assign different significance according to position. Most
systems we're used to represent numbers with highest significant at leftmost
positions, i.e., we assign a higher significance to the digits on the left. So
it's 1 hundred, 2 tens and 3 units. Other numbering systems make the opposite
convention: rightmost symbols take on highest significance. E.g., one could
read out this number as three-and-twenty-and-a-hundred. That would reverse the
order, but not change the significance.
Another example that could help clear up the difference between position and
significance is that of date conventions. Month is more significant than day,
when counting time, but if you take Dec 25, whether it's represented as 12/25
or 25/12, though the order changes to fit each convention, the month remains
the most significant quantity.
Byte swapping for endianness adjustment is like changing the representation of
dates: the date remains the same, each component symbol remains the same, but
it's moved to the corresponding position of the same significance: the month is
moved to the position that signifies the month, and the day is moved to the
position that signifies the day.
Loading a big-endian word from memory to a register, reversing bytes, does the
same: the clear or set bit that stands for 1 is placed in the corresponding bit
in the other representation that stands for 1; the bit that stands for 2, or 4,
or 8, 16, etc, is placed in the corresponding bit in the other representation
OF THE SAME SIGNIFICANCE. the most significant bit, that is often used to
represent the sign, goes in the most significant bit in the other
representation too. that reverses the order, but the significands retain their
significance, being positioned in the corresponding-significance positions,
just like day and month in a date.
do you see now why it doesn't make sense that the conversion from BE to LE (or
vice versa) places the MSByte in the LSByte? it doesn't! that would change
the represented value. what changes is the order of the bits, so that they
*retain* their significance in the alternate representation, i.e., so that they
still represent (= mean, signify) the same number.
now, we represent numbers in conventions that tie position with significance.
though we normally read them from left-to-right, most arithmetic algorithms
that we learn at school go right-to-left. that doesn't change the significance
of the digits, does it?
if you take an unmarked soroban abacus (those that have some beads
conventionally standing for 1, and others in a separate part of the same row
standing for 5), move the beads so that they represent a certain large number,
and then look at the abacus in a mirror, you may be a little confused because
then the digits, from most to least significant, appear from right to left
rather than left to right.
but if you're given a picture of an unmarked soroban, and you're told it might
or might not be a picture of a mirror reflection, you won't know how to assign
the significance to each row of beads. the unmarked soroban is like a
register: without a predefined order (e.g. memory addresses) and convention
(e.g., increasing or decreasing significance), you know the bits, but not the
significance. now, once you establish a convention of significance, e.g. by
training the performance of arithmetic operations from right to left, you have
assigned meaning to the rows, but you can still read them right-to-left,
least-significant first (three-and-twenty-and-a-hundred) or left-to-right,
most-significant first (one hundred, twenty-three). the convention of how
significance relates with order of representation in memory is called
endianness. if lower-address implies lower-significance, and vice-versa,
that's LE; if lower-address implies higher-significance, and vice-versa,
that's BE. if we were to take address order as left to right (a frequent but
not mandatory convention), then our positional numbering systems would be BE,
as would MM/DD, whereas DD/MM would be LE.
I hope this helps.
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Libre-SOC-ISA