some of you might know me...i've been out of the ftb/modded mc scene for a while due to Real Life(tm)
but I'm back in it..with a nice machine to play all these new packs with. While im messing around with SkyFactory...i found a redstone pack which is absolutely *perfect* for building all sorts of cool redstone/pr stuff.
I started on the idea of a very simple cpu, something that could implement BrainF*ck (google it...not hard to find info on it one component this cpu needs is a binary counter. playing around with PR's toggle latches, I came up with this
just a basic +1 counter. it works very similar to a piston based counter...but without the cool 'instacarry' traits you could get with normal redstone
That's neat...but it needs a reset function:
simply adding AND gates to the toggles between their outputs and the reset line will reset the toggles. The logic there is to only toggle the latch if it's on
But that's not enough...we need to be able to load in a value (aka load branch)
I'm using xor's on the toggle output and branch inputs...the xor determines if the toggle needs to be
switched if the toggle output and the branch input are not equal. Had to add buffers to keep the signals from the xor's triggering the clock line
We're almost there. The circuit can count up...but not down. lets add that as well:
here the green wire controls an xor gate on each toggles output. if the green wire is off, the signal from the toggle goes through unchanged. if on, the xor inverts the outputs...causing the circuit to count backwards!
I came up with this pretty much by trial and error. I tried implementing a counter using a ripple carry adder and wasn't too happy on its size and complexity (needed latches, output fed back to inputs, busing inputs/outputs all over the place, timing issues...yaaaa). This circuit is not easy to look at either but it does exactly what a bidirectional binary counter needs to do, with all the functions you'd expect
As you can see it's easily tile-able, the image only shows 3 bits implemented. I have an 8 bit version of this for the cpu build im attempting:
This is being built bitslice style...each layer is one bit of the cpu, and 8 layers making this an 8bit cpu (makes busing *much* easier). On the left side is the topmost slice of the binary counter. just after that are 2 registers and the edge of the ram array (64 bits per slice, x8 for 64 bytes of ram) and far down on the bottom you can see part of the ram address decoder.
still needs quite a bit:
rom space for bf programs
cpu controller
and something to track jump points in the bf code
If you look at how a bf program is written, the '[' and ']' commands are the loops. a very simple interpreter would simply scan forward or back for the start/end of the loop if needed...more advanced interpreters maintain arrays on where loops start/end or break out the loops into their own sub blocks of code. I like the jump table idea...and i think i have something for that:
this is what i call KVROM (unless someone knows of a device that does this): key/value rom. The idea is an input value comes in on the input bus. There are xnors on top paired to latches and the inputs. if the input value matches whats latched on the input side then the blue wire becomes active and enables the outputs for the second set of latches on the bottom. If you're familiar with javascript..this is almost like assigning properties with values to an object. You would program one of these with 2 values: a key, and its associated value. This requires 'precompiling' the code as you cant access this memory like normal ram. but it would be highly convenient so that, for example, if i'm at rom location 12 and the instruction is a '[' opcode...the value 12 would be on the input bus for several of these roms...if one responds to the value '12' then the output will show the address of the other end of the loop. Id have to use computercraft anyway to load the scripts into the computer...so programming the kvrom can be part of the loading process. more coming as i work on it
but I'm back in it..with a nice machine to play all these new packs with. While im messing around with SkyFactory...i found a redstone pack which is absolutely *perfect* for building all sorts of cool redstone/pr stuff.
I started on the idea of a very simple cpu, something that could implement BrainF*ck (google it...not hard to find info on it one component this cpu needs is a binary counter. playing around with PR's toggle latches, I came up with this
That's neat...but it needs a reset function:
But that's not enough...we need to be able to load in a value (aka load branch)
switched if the toggle output and the branch input are not equal. Had to add buffers to keep the signals from the xor's triggering the clock line
We're almost there. The circuit can count up...but not down. lets add that as well:
I came up with this pretty much by trial and error. I tried implementing a counter using a ripple carry adder and wasn't too happy on its size and complexity (needed latches, output fed back to inputs, busing inputs/outputs all over the place, timing issues...yaaaa). This circuit is not easy to look at either but it does exactly what a bidirectional binary counter needs to do, with all the functions you'd expect
As you can see it's easily tile-able, the image only shows 3 bits implemented. I have an 8 bit version of this for the cpu build im attempting:
still needs quite a bit:
rom space for bf programs
cpu controller
and something to track jump points in the bf code
If you look at how a bf program is written, the '[' and ']' commands are the loops. a very simple interpreter would simply scan forward or back for the start/end of the loop if needed...more advanced interpreters maintain arrays on where loops start/end or break out the loops into their own sub blocks of code. I like the jump table idea...and i think i have something for that: