TTA processor. Part 2

Foreword


This is the second part of the attempt to create a TTA processor in Logisim. In the process of creation, there was a need for additional memory in which some intermediate values ​​could be stored, and for this memory there was a need to change the control device.

Part 1
Part 2

Additional memory


Since commands and constants are difficult to store in memory, it will be difficult to make a fully addressable memory, so you need something simpler, a stack or a queue is good for this.

The queue does not look very convenient, and the Forth language was invented for the stack , the compiler of which I would like to write. We implement the stack as a functional device:


It looks confusing, but in fact, this device performs simple functions: the counter points to the next cell, when data arrives, they are written to the cell that the counter points to and it increases; when data is taken, they are given from the cell previous to the one indicated by the counter and the counter decreases. Then another problem arises, how do you know what data was taken from the stack, you need a flag for this, then the control device (UU) will look like this:


For ease of connection, the outputs will be located on the left, and the inputs on the right, then the control unit and other functional devices (stack, adder, AND, OR, register, etc.):


Let's assemble a simple circuit with memory of commands, two stacks, two registers, an adder, a negator, And, Or and some constant (let it be 5):


It remains to create memory for the constants and you can write the Forth compiler, but for now let's try to write some words from it directly in memory.

Dup


The word dup does a simple thing: duplicates the data of the top cell of the stack back onto the stack. First you need to load, for example, our constant (in6 -> o1) onto the stack, now we have data in the first cell of the stack, but when you take the data, it kind of disappears from the stack, how to be? There are registers for this, load the stack cell into the register and save it there, after which we load it onto the stack twice, thereby duplicating it, the pseudocode looks like this:

1. in6 -> o1 // Loading the constant into the stack
2. in1 -> o3 // Load a cell from the stack into register
3. in3 -> o1
4. in3 -> o1 // Two times load the contents of the register onto the stack

That's all, in memory it looks like this:


And after execution, the stack looks like this:


As expected, our two constants. That's all, in a similar way you can do drop, swap, rot, etc.

Thank you for your attention, I hope it was not boring!

Github Link: GitHub

All Articles