Memory is used for storing values and states in dwarven computing. Typically, binary memory is used, but this isn't strictly necessary. There are multiple ways to set up a memory cell, depending on whether one is using mechanical, fluid, or creature logic. With binary memory, each cell has two possible states, generally referred to as 0 and 1, or true and false.
Memory systems in dwarf fortress, thankfully, are very good at maintaining their value (in the absence of any trolls), but they are still plagued by problems with latency and long refractory periods. Latency refers to the length of time before which a change in value will register, and the refractory period refers to the period after writing to memory during which one cannot reliably write to it a second time. Because of the delays involved with pressure plates, latency and refractory period for a given memory cell often depend on which state the memory is being changed to. For instance, the mechanical hybrid cell below has nearly no latency when being written as true, but around 100 ticks of latency when being written as false.
Some designs can trade simplicity or material needs for costs in performance.
 Fluid Logic
The simplest fluid logic latch relies on an infinite source and infinite drain, storing information in the form of the presence or absence of water in a particular location.
In this design, water flows from an infinite source
~ over an output pressure plate
^ toward an infinite drain
~. Its flow is controlled by a floodgate,
X, and a raising bridge,
╬, both linked to the same input. When
╬ are open, water will cover
^; when they are closed, there will be no water. Thus, the input source toggles the state of the memory cell, and the state of the memory cell is reflected in the output of
This is an example of flip-flop memory. The state of the memory can be toggled, but it's not possible to write one particular state (that is, for instance, true) to the memory without first examining the memory. This can be altered by replacing the bridge and floodgate with independently triggered doors. This design has relatively high latency, because of the flow rate of water, and a refractory period of 100 ticks, representing the delay associated with bridges and floodgates. Given careful enough design and sufficient water pressure, the latency of a write to true can approach 100, with the latency of a write to false around 120.
 Creature Logic
In this circuit, a creature placed between in the middle seeks its pathing goal
p but is constrained by the hatches
¢, each linked to the pressure plate
^ of the same color. When the door
+ is opened, the creature can move to the left (false)
^, and when the door
+ is opened, the creature can move to the right (true)
^, thus outputting to anything linked to that pressure plate. This is an example of memory for which it is possible to write a particular state, rather than just toggling, which allows for simpler design for some applications. Note also that rather than writing on a single on or off signal, it depends on an on-off cycle.
This design has good latency for creature logic systems, resulting in on signals around 40 ticks after writes and off signals around 150 ticks after writes. It has a 110 tick refractory period, representing the time necessary for the hatch covers to close.
 Mechanical Logic
A gear assembly can function all on its own as a memory cell, being either active or disengaged. However, some complicated applications suggest the use of hybrid mechanical-fluid memory.
In this design, two separately powered pump stacks,
%, are placed over each other-- the lower one, pumping to the right, and the higher one pumping to the left. When the water
~ is lying in the rightmost (true) cell, it activates a pressure plate
^. To write true to the memory, one triggers the lower gear assembly
☼, activating the lower pump, and to write false, one activates the higher gear assembly
☼ and pump stack. Like the creature logic memory above, this cell can be written as specifically true or false, and depends on an on-off cycle as input.
This design has very good latency (from almost nothing for a write as true to 100 ticks for a write as false) and no real refractory period-- it can be written to immediately following a previous write, although it does depend on the completion of the previous write signal (receiving the off component of the signal) before writing again.
 Memory addressing
In complicated designs, one may wish to use a memory cell abstractly-- to represent any number of different values. To use multiple such abstract cells, it's necessary to specify exactly which memory cell one wishes to read from or write to at any given moment.
This is simplest in mechanical logic. A grid of gear assemblies can represent rows and columns, and by disengaging control gears for all but the cell that lies at that particular row/column intersection, one can easily refer to a specific cell. Strict fluid logic can do something similar, by controlling the input of water to memory cells, although this involves long delays. With the creature logic design, one can use additional doors to restrict writes to any cells not referenced.
 Alternate design
Because most memory is used for a specific application, there is no single best design. It is not uncommon to see functionality built into memory circuits-- a simple circuit that increments contains its own memory. Alternate designs are important when memory needs to be written to in various ways (toggle versus specific value), when it needs to receive different kinds of input (a steady on or off versus an on-off cycle), or when latency and refractory period are unimportant compared to resource requirements such as space.