The ISA for the CPU is pretty low density. With a word size of 32 bits, there's a fair amount of room to do everything... except for absolute addresses and some large constants. As I've experimented with the ISA, I've left gaps, extra bits, etc and it's a bit messy. I'm starting to clean up and make things a little more orthogonal now, with the idea that this will also allow the CPU core to become more efficient.
The ISA is defined in my Opcode worksheet, and I try to make sure this is up to date as I make changes to the core and the assembler.
After some review, it turns out that it's a little more compact than I originally thought. Here's a summary of the types of opcodes. Most of them share a common structure.
REG | 00oo oooo oxxx aaaa bbbb cccc xxxx xxxx |
REGIND | 01oo oooo vvvv aaaa bbbb vvvv vvvv vvvv |
IMM | 10oo oooo vvvv aaaa xxxx vvvv vvvv vvvv |
DIR (32 bit) | 11oo oooo vvvv aaaa bbbb vvvv vvvv vvvv |
DIR (64 bit) | 11oo oooo xxxx aaaa xxxx xxxx xxxx xxxx AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA |
The key for the above is:
- First two bits are the form value. The different forms used to have very different structure, but now they have kind of merged together quite a bit and so in many ways this is not just an extension of the opcode number.
- o = opcode number, unique within the form.
- a, b, c = the 4 bit register identifiers. The specific opcode may not use all of these.
- v = a signed offset of some kind. Used for PC offset addressing, register offset addressing, as well as for constant values for various functions.
- A = the 32 bits of the second word. In most cases it is used as an absolute address, but for the ldi instruction it is a 32 bit constant.
- x = unused bits. Maybe an opportunity to build more compact forms. For example, instead of having the ALU command be part of the opcode number, maybe I could have a single opcode number for the ALU (or floating point, etc), and use some of these bits to indicate the type of operation. Unfortunately, these bits aren't always available in all addressing modes, so it's not always an easy choice.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
neat :-)
Are you sure? yes | no