From: Jacob Lifshay <programmerjake@gmail.com>
To: Libre-RISCV General Development <libre-riscv-dev@lists.libre-riscv.org>
Subject: [libre-riscv-dev] more compatible alternative to BE instructions on LE processor
Date: Tue, 12 May 2020 19:56:45 -0700
Message-ID: <CAC2bXD4xp7+4qWk1Frg4mW+ukuLPBs0=2wCB=ZCz4=pWeV46Gw@mail.gmail.com> (raw)
Since having the instruction stream be BE is not directly compatible with
existing LE instructions since calling between them requires a mode switch
to switch endian, I propose a different solution that doesn't require any
mode switch, is compatible with LE instructions, and allows supporting
instructions that are any size, though will probably be limited to
multiples of 16 bits.
My idea is to switch the logical order that instructions are decoded such
that decoding 32-bit LE words starts with the most-significant byte which
contains the opcode, instead of the least-significant byte.
PC would effectively be split into two fields, where the top N-2 bits are
the address like usual, but the bottom 2 bits instead address memory in
reversed order:
PC value -> memory address
0x1000 -> 0x1003
0x1001 -> 0x1002
0x1002 -> 0x1001
0x1003 -> 0x1000
0x1004 -> 0x1007
0x1005 -> 0x1006
0x1006 -> 0x1005
0x1007 -> 0x1004
0x1008 -> 0x100B
0x1009 -> 0x100A
0x100A -> 0x1009
0x100B -> 0x1008
0x100C -> 0x100F
0x100D -> 0x100E
0x100E -> 0x100D
0x100F -> 0x100C
0x1010 -> 0x1013
Since all currently existing Power instructions are a multiple of 32 bits,
this wouldn't change how they are decoded or executed, however, would
change how new 16 or 48-bit instructions are laid out.
If the processor is switched to BE mode (for both instructions and data),
this address reordering would be disabled, since BE mode already has the
opcode byte as the first byte anyway.
(PDP endian resurrected -- sort of)
Jacob
_______________________________________________
libre-riscv-dev mailing list
libre-riscv-dev@lists.libre-riscv.org
http://lists.libre-riscv.org/mailman/listinfo/libre-riscv-dev
next reply index
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-13 2:56 Jacob Lifshay [this message]
2020-05-13 6:29 ` Lauri Kasanen
2020-05-13 8:09 ` Luke Kenneth Casson Leighton
2020-05-13 8:17 ` Luke Kenneth Casson Leighton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAC2bXD4xp7+4qWk1Frg4mW+ukuLPBs0=2wCB=ZCz4=pWeV46Gw@mail.gmail.com' \
--to=programmerjake@gmail.com \
--cc=libre-riscv-dev@lists.libre-riscv.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Libre RISC-V Mailing list Archives (accessible via public-inbox)
Archives are clonable: git clone --mirror https://inbox.libre-soc.org/libre-riscv-dev
Example config snippet for mirrors
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git