In the last video I showed you a music generator made of the new electrics in Survivalcraft. The problem was that the sound of the generator was a bit annoying. So I added some more instruments. Here’s a new video quickly showing all 7 of them:
You select the instrument via the clock input at the bottom of the sound generator. Depending on what analog value you send there, a different instrument will play. The default one (when you just send a logic high signal from e.g. a button) is a piano.
As promised, here’s a description of another bit of the new electrics.
If you have trouble understanding the below, don’t worry. This is a fairly advanced piece of Survivalcraft electrics and you don’t need to use it unless you want to create some advanced electric devices!
The Memory Bank
Memory bank is a device that can store a large amount of data, which can be used by other elements, for example displays or music generators. It supports both reading and writing, as well as manual entry via a dialog box.
A memory bank
A single memory bank stores up to 256 “words”, each word being 4 bits in length.
The access to the data is sequential, i.e. you can only access a single word at a time. To select which word should be read from the memory bank, two address lines are used. Why two? Because each line is 4 bits, and 8 bits are needed to address all 256 memory locations.
If you look at the picture of the memory bank above, you will see two inputs, left and right, one output at the top, and one clock input at the bottom (remember the convention: blue is input, red is output).
The inputs on left and right are address lines. The one with a single dot sets the 4 low bits of the address. The one with two dots sets the 4 high bits. If you only want to use no more than 16 elements from the memory bank, you only need to use the low input and can leave high disconnected. That will give you 4 bit addressing, i.e. up to 16 locations.
Side note: a good element to use for generating addresses is a 4-bit counter. It outputs a 4 bit value that can be directly connected to the address input of the memory bank. You can cascade two such counters (using the overflow output of the first one) to make a 8 bit counter and address the entire bank. See the picture below:
8 bit addressing using two chained 4-bit counters
The value stored in the memory bank is available through the top output.
The clock input is optional and works the same way as in SR latch. If it is connected, the address lines will only be sampled at the rising edge of the clock signal. At all other times the output of the memory bank will keep showing the last addressed location, no matter what is currently supplied to address lines. This is useful for synchronous circuits.
To write to the memory block, you need to use the “in” input (i.e. the one accessible when you place the memory bank on wire-through-block element). The value supplied on this input will be written at the address given by address lines on the rising edge of the clock input, which must be 0.7V or less. Anything above 0.7V will cause a synchronous read, as described above.
Memory block is editable. This is a new concept in Survivalcraft. Basically, when you hold a memory block in your hand (or look at a mounted one from close distance), the sneak button will change into edit button:
When you click this button, the edit dialog box will open for the given element:
Edit memory bank dialog
In there you can enter the data you need, either using a grid or paste it into a single text box.
There are more elements that use the new edit mechanics, more on it later.