When combined with looping mechanisms, timers give us the power to select particular items.
Suppose we had a large looping block of memory containing 16 words
. We want to write the 5th word
. How can we do that?
If we load 5
into our timer (000101), it will take 5 cycles to reach 0. Using a zero checker on our timer, we can make it release once it becomes 0.
At this point, the loop of memory will have moved by 5 words
. If we use the emitted by the zero checker to trigger the memory’s write mechanism, we’ll overwrite the 5th word.
SAM
This strategy of scrolling through the memory is called Sequential Access Memory (SAM). The “sequential” means that to get to (e.g.) word
10, we have to travel through 1, then 2, then 3, and so on.
Some examples of SAM you might be familiar with:
- Tape recorders and VHS (video) have to physically scroll through their tape to get to the right place
- The needle on a vinyl record travels sequentially along the groove, reading the musical data as it goes — it doesn’t jump around
- To improve performance, Hard Disk Drives (HDD) typically have sequential sections they have to scroll through, though they do have some ability to jump directly as well.
SAM is simple but slow. It’s good for storage, but for running programs at a good speed, we want something faster.
RAM
You may be more familiar with Random Access Memory, better known as RAM. Unlike SAM, RAM lets us jump quickly to any part of the memory — it’s “random” in the sense of “arbitrary”.
The key idea is that RAM lets you access any data in constant time. It doesn’t matter if you want the 1st entry, the 100th, or the 10,000th — RAM will get you the data just as quickly.
implementing RAM
How can we build RAM in roons?
Here’s a sketch of how we could approach this. As above, we take in an address written in binary. Instead of waiting for that number of steps, we use that data to dynamically construct a route. The route connects the appropriate memory address to the device that needs it, and then the just follow that route.
Later we’ll look at building a router, a device capable of controlling these dynamic paths. This is a very powerful general-purpose device that we can use for other things than memory.
There’s also another way we can get access to RAM…
RAM peripheral (WIP)
The RAM peripheral is a block of memory that plugs into the roons grid.
The peripheral contains 16 records, so the address of each record is given by 4 bits (24 = 16
). Each record is 8 bits long. So in total, the RAM peripheral stores 8 x 16 = 128
bits.
It supports two functions, read and write.
read
To read a block of data, enter a 4-bit marble stream through the left input. This makes the peripheral copy out the 8-bit record stored at that address.
write
To write a block of data, enter a 4-bit marble stream through the left input to specify the address. At the same time, enter an 8-bit stream through the central input to specify the new content; and finally, input a single at the start of the 4-bit cycle into the right-hand input. This indicates to the peripheral that a write is starting.
making do
The RAM peripheral isn’t available yet, and implementing RAM in the roons core is complicated. SAM is good enough for our needs for now. Anything RAM can do, SAM can do — just slower. Let’s build our computer first, and then figure out how to speed it up later.
This wraps up our initial tour of state! We’ll revisit this topic again to explore RAM and other enhancements. For now, we’re going to move on to building our first complete device.
finish