*UPDATE* the save has been updated with a new ALU. This one fixes the problems experienced in the previous version. It is built using a custom model of the XOR gate demostrated by ProperInglish here
. It also has a lot more program memory, IIRC around 60 words. Currently it will run at 40ticks per cycle (0.25Hz), though this may change in future updates
This is the first release of my second attempt at building a CPU in Minecraft. This one is a lot different to the first, and I literally just got it working so don't be surprised if things don't work quite as they should. Beta is beta. If you do find anything that doesn't work as it should, please let me know if the comments. Any other feedback/questions/comments would also be appreciated :)
16-bit FABO input (4-bit Function Code, 4-bit A Input Address, 4-bit B Input Address, 4-bit Output Address). Function 0000 allows A and B Inputs to be interpreted as an 8-bit number to be saved at the output address.
12bytes of Dual Read RAM
7 tick instant carry 8-bit ALU capable of the following functions:
-Incrementation (A+B+1, setting B to 0 gives A++)
-Decrementation (A-B-1, setting B to 0 gives A--)
Jump capable program counter. this is addressed as a register and so can be written to and read from like any other memory cell allowing for easy jumps, and pointer arithmetic (yay!!) within the program memory.
Conditional jumping *PARTIALLY TESTED*. can jump if A==B, A!=B, A>=B, A<B.<br />
As a demo of these abilities, I've set up the CPU to run the Fibonacci sequence. You can have a look at the code to do this inside the program memory, it's only 4 lines :P
Conditional Jumping might not work. The parts are all there, but I haven't checked timings etc, so odd stuff might happen. You can try it out yourself (ALU instructions are present and correct), but don't expect anything.
Register 14 is broken. this is due to me being clumsy with MCEdit while pasting in the new ALU. I will fix it at some point, but I dont expect any of you will be using that many variables any time soon. The most I've used at once was 5 :P
Odd endian-ness. When entering numbers into the program memory, the Most Significant Bit (MSF) is on different sides depending on what is being done. This is because I designed different parts of the CPU from different sides, and didn't take into account what would happen when they were plugged together. This isn't really a bug, since it doesn't affect the operation of the CPU, but it can make programming it a pain in the arse.
The reason this CPU looks quite weird is down to the way that I arranged the buses: when building the first two prototypes, I noticed that I had to add a lot of delay to certain parts of the circuit to get the timings right. I also noticed that the timing of the read system was severely messed up: trying to add a number from the first register to a number from the last register would result in the signals getting to the ALU at completely different times, ruining the sum. This is because the address input and data output were on the same side of the system: as the redstone signal moves further down the decoder, it has to be repeated, adding latency. It then gathers more latency coming back. The solution to this is to run the decoder buses in the same direction as the data buses, which results in each register getting an equal amount of delay no matter where it is, from address input to data output. This is because the signals were travelling in the same direction, and so had to go through the same number of repeaters for each register.
This meant that I had to position the program memory output at the opposite end of the CPU to the ALU. In order to reduce the size, I placed it on top. This ensures that the far entries won't get unloaded if the player moves to the other end of the CPU.
This map contains many circuit prototypes, which you are more than welcome to look at and use in your own designs (accreditation would be appreciated if you do). However, it can be quite easy to get lost, especially since there are two CPU prototypes very close to the current one. The correct CPU is at co-ordinates x=1344 z=-117. You can press F3 to view your current co-ordinates, and type "/tp <player_name> 1344 32 -117" without quotation marks into Minecraft's chat box and replace <player_name> with your username to teleport yourself directly to it.
That's about it as far as the CPU goes, I'll update as and when I feel that I need to. Other items of note on this map are my attempts at making a screen, the fruits of which can be viewed at x=1090 z=163 (type "/tp <player_name> 1090 21 163" to teleport to it). This is currently unfinished, but still pretty impressive to look at :P
As always, suggestions/complements and criticisms are always welcome in the comments box. I recently decided to start streaming some of my development on my Twitch channel www.twitch.tv/soddit112. Most of it is just for my benefit (I've gotten very bad at logging my developments recently) and isn't very interesting to watch, especially since I'm not commentating or anything like that at the moment.