- [Minecraft] 4-bit Command Block CPU
- 03 Jan 2014 12:04:10 am
- Last edited by AHelper on 01 Sep 2016 12:44:32 am; edited 1 time in total
Since command blocks are great, I have been making a 4 bit CPU based around command block logic. Using testforblock and setblock in vanilla, I was able to so far create on a basis for a CPU with 4 usable registers, 2 temp registers, resiable program memory, 3 internal commands (ld d,r[f], ld r[f],d, inc pc), and one user op (ld r,imm).
Registers Left-to-right: User registers a, b, x, y, temp register d for internal commands, temp register f for flags to internal commands.
Program memory. Has ld a,6 (00nn / nnrr)
Instruction decoder is first two command blocks (00xx is ld r,imm), next 2 are block copies that move xxnn to d, next lone command block calls inc pc, next 4 block copies move nnxx to d and xxrr to f, next block calls read, last block calls inc pc.
internal commands' calling blocks and f register decoders in front.
back of internal commands.
Other op codes will just be added to on the decoder chain. Op codes include
Code:
<edit>I made a fast full adder (testing, not added to the CPU yet) that is 5 to 9 ticks per slice, depending on the logic.
Registers Left-to-right: User registers a, b, x, y, temp register d for internal commands, temp register f for flags to internal commands.
Program memory. Has ld a,6 (00nn / nnrr)
Instruction decoder is first two command blocks (00xx is ld r,imm), next 2 are block copies that move xxnn to d, next lone command block calls inc pc, next 4 block copies move nnxx to d and xxrr to f, next block calls read, last block calls inc pc.
internal commands' calling blocks and f register decoders in front.
back of internal commands.
Other op codes will just be added to on the decoder chain. Op codes include
Code:
ld r,imm Register load
ld r,r Register copy
in p IO input to port #p
out p IO output to port #p
bz n Branch if a == 0
cmp.t r Compare r with a using mode t (eq, neq, gt, lt), store result in a
add a,r
sub a,r
or a,r
and a,r
xor a,r
(inc/dec or rotates?)
<edit>I made a fast full adder (testing, not added to the CPU yet) that is 5 to 9 ticks per slice, depending on the logic.