Forums - Open Redstone Engineers
Easing my way back into CPU design and building - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: ORE General (https://forum.openredstone.org/forum-39.html)
+--- Forum: Projects & Inventions (https://forum.openredstone.org/forum-19.html)
+---- Forum: In Progress (https://forum.openredstone.org/forum-20.html)
+---- Thread: Easing my way back into CPU design and building (/thread-10874.html)

Pages: 1 2 3


Easing my way back into CPU design and building - tokumei - 09-12-2016

Links: Specification (GDocs), Mapping (GSheets)

The title sums it up well. I'm going to be working on a new architecture / instruction set and building a CPU to go along with it. It's just a warmup exercise for some of the cooler stuff I'm planning for later :3.

Ideas so far:
  • Harvard memory architecture
  • 4 bit data width; 8 bit instruction width
  • 3 general purpose registers and one null register (might substitute for a 4th GPR)
  • 16 lines of instruction memory
  • No higher level storage 8 16 words of secondary data storage
  • No call stacks - not practical for such a small instruction space
  • 2 or 3 stage pipeline - a new thing I haven't done yet
  • Conditional branching with some simple conditions (zero/overflow flags)
  • Branch prediction
More details will come out during the week. By next Monday I plan to have a first draft of the architecture spec and instruction set done.

Updates:
  • 2016-09-12: I have made an official for mapping of the instruction set. Please check it out and make comments here!
  • 2016-09-13: I have added two new instructions, Load and Store, both of which take up the rest of the empty instruction space. They accept 3 bit memory addresses which are separate from the register address space, so it adds an extra 8 words of data capacity.
  • 2016-09-13: I have added a new document, the architecture specification. This will be the home of all the specs that fit better in a typed document than a table.
  • 2016-09-16: A rough wiring diagram has been drawn; now working on digitizing it and figuring out tick speeds for components.
  • 2016-11-15: I got distracted by school and some other projects, I'm going to start working on this again.



RE: Easing my way back into CPU design and building - Koyarno - 09-12-2016

Some suggestions:

What about a 2 operand IS with a 4 bit opcode? A as source and destination and B only as source.
Register 4 could be a stack to handle the load immidiates and memory operations if you dont want to deal with 2-word instructions.
If you want to start on pipelines, best is to keep to 2 stages. A fetch/decode and Execute so you dont have to deal with forwarding/stack inconsistensies.
It also makes conditional jumps right in line with the conditions from the previous instruction, so no flushing of wrong instructions is needed.

Hope that helps out Tongue


RE: Easing my way back into CPU design and building - tokumei - 09-12-2016

(09-12-2016, 10:16 AM)Koyarno Wrote: Some suggestions:

What about a 2 operand IS with a 4 bit opcode? A as source and destination and B only as source.
Register 4 could be a stack to handle the load immidiates and memory operations if you dont want to deal with 2-word instructions.
If you want to start on pipelines, best is to keep to 2 stages. A fetch/decode and Execute so you dont have to deal with forwarding/stack inconsistensies.
It also makes conditional jumps right in line with the conditions from the previous instruction, so no flushing of wrong instructions is needed.

Hope that helps out Tongue

That was my plan, 4 bit opcode and 2 operand layout using operations like += and -=. Of course the immediate would use a full word (both operands) so it will probably have a designated register (though it's also GPR). Another idea, I could remove 2 bits off the opcode for the "add immediate" instruction - there will likely be enough extra instruction space to do so.

There won't be any "memory operations" as there won't be any external memory to work upon. Existing ALU operations like add/subtract can be used to move register values around if (but not likely to be) needed.

Thanks for the pipelining advice too. This is my first time so it's going to be fun learning how to implement it.


RE: Easing my way back into CPU design and building - tokumei - 09-13-2016

Okay, I have made an official for mapping of the instruction set. Please check it out and make comments here!

I have a few empty opcodes that could potentially be used to expand the functionality of the current instructions. Or I could add a few new ones. Maybe some external memory for longer term storage?


RE: Easing my way back into CPU design and building - Nickster258 - 09-13-2016

I find your ADDi very interesting.

Definitely tempted to do something similar to this for my next(hell, maybe?) project.


RE: Easing my way back into CPU design and building - tokumei - 09-13-2016

(09-13-2016, 06:22 AM)Nickster258 Wrote: I find your ADDi very interesting.

Definitely tempted to do something similar to this for my next(hell, maybe?) project.

Yeah, variable length opcodes are in a lot of RISC architectures. See page 13 on this pdf (ARM instruction set) for an example. In most of those cases, the opcode is partially replaced with flags that modify the behavior of the operation, but some others use the extra space for more operands.


RE: Easing my way back into CPU design and building - Nickster258 - 09-13-2016

My only problem with that, in that it has not just one but a few variable width opcodes, is issues with instruction decoding time.


RE: Easing my way back into CPU design and building - tokumei - 09-13-2016

Decoding time will hardly be affected. I will just have to pipe the first 5 bits into a logic array that has hardcoded sum-of-product equations for each control signal needed by the ALU or other components.

For example, the control signal for "cut carry" is only needed when the input matches 0110x (NOR) and 0111x (XOR), which can be simplified to 011xx. Therefore, the sum-of-product equation (implemented using AND and OR) is a simple monomial: (!b0)b1b2 (b standing for bit).

Computing any control signal using this method will take 2 ticks, maybe 3 at the absolute worst case. On top of that, it is much more versatile than a decoder that has an output for every instruction. Using that method, control signals have to be spaghettied together from multiple decoder outputs. I used that method a few times before I discovered logic arrays, and I never want to go back to it.


RE: Easing my way back into CPU design and building - tokumei - 09-13-2016

I have added two new instructions, Load and Store, both of which take up the rest of the empty instruction space. They accept 3 bit memory addresses which are separate from the register address space, so it adds an extra 8 words of data capacity.


RE: Easing my way back into CPU design and building - Matthew - 09-14-2016

(09-13-2016, 06:22 AM)Nickster258 Wrote: I find your ADDi very interesting.

Definitely tempted to do something similar to this for my next(hell, maybe?) project.

nick?... redstoning?... i cant believe my eyes