v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Difference between revisions of "v0.34:Memory (computing)"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
(+)
(Section on flip flop memory, minecart memory example, power-to-signal vs memory; electronics peeps, feel welcome to correct terminology lol i don't even)
Line 3: Line 3:
 
{{av}}
 
{{av}}
  
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 logic|mechanical]], [[fluid logic|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 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 logic|mechanical]], [[fluid logic|fluid]], [[creature logic]], or [[minecart logic]].  With binary memory, each cell has two possible states, generally referred to as 0 and 1, or true and false.
 
 
  
 +
===Flip-flops versus latches===
 +
The most basic characteristic of memory in Dwarf Fortress is that it acts as a signal splitter: given a series of on-off signal cycles, it outputs a series of alternating on or off signals.  Memory that does this, and only this, acts like a flip-flop: every time you trigger the memory, it changes state.  Such memory is perfect for devices such as [[Adder (Computing)|counters]].  However, it's common to desire the ability to write state directly to your memory, rather than toggling it-- that is, to write either '''true''' or '''false''' to memory directly, without knowing the current state of the memory.  This can be described with a chart where the memory value feeds back into itself:
 +
{| class="wikitable" border=1
 +
|-
 +
! input
 +
! latch state
 +
! output
 +
! new latch state
 +
|-
 +
| 0
 +
| 0
 +
| none
 +
| 0
 +
|-
 +
| 0
 +
| 1
 +
| off
 +
| 0
 +
|-
 +
| 1
 +
| 0
 +
| on
 +
| 1
 +
|-
 +
| 1
 +
| 1
 +
| none
 +
| 1
 +
|}<br />
 
===Performance===
 
===Performance===
 
 
Memory systems in dwarf fortress, thankfully, are very good at maintaining their value (in the absence of any [[troll]]s), 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 plate]]s, 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.
 
Memory systems in dwarf fortress, thankfully, are very good at maintaining their value (in the absence of any [[troll]]s), 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 plate]]s, 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.
  
Line 58: Line 85:
  
 
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.
 
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 versus Power-to-signal===
 +
It can be tricky to differentiate memory from [[Mechanical_logic#Power_to_signal_converter|power to signal]] conversion.  Through feedback, power-to-signal devices can often be changed into memory cells, and powered memory devices can be adapted into power-to-signal.  Previous to the introduction of minecarts, the most common power-to-signal device bore strong resemblance to the memory cell described above.  There is, however, a large difference between memory and power-to-signal.  While memory designs receive on-off signal cycles and output discrete '''on''' or '''off''' signals in return, power-to-signal converters return exactly what they're given.  That is, a signalling device that receives then loses power should return a full on-off signal cycle.
 +
 +
==Minecart Logic==
 +
There are numerous ways for minecarts to hold information.  Some memory designs use movement or the absence of movement; others use just the position of a minecart.  Advanced designs could use the weight or direction of movement of a minecart.  The following powered minecart design by Bloodbeard is the smallest memory circuit currently known to dwarvenkind:
 +
 +
[[File:3tdcbm.png]]
 +
 +
The diagram shows the minecart layer at the top, the roller/furniture layer in the middle, and finally the track layer at the bottom.
 +
When the northern gear assembly is activated, powering the northern roller, a heavy minecart (copper, in this example) is pushed southwards.  This pushes a lighter minecart (iron here) south, and triggers a pressure plate that is built to only signal on the weight of a copper minecart, and not on the weight of the lighter iron minecart.
 +
With the activation of the southern gear assembly, the situation reverses.  The iron minecart pushes on to the pressure plate, and an '''off''' signal is sent.
  
 
==Memory addressing==
 
==Memory addressing==
Line 65: Line 104:
  
 
==Alternate design==
 
==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.
+
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) or when latency and refractory period are unimportant compared to resource requirements such as space.
  
  
 
{{Category|Computing}}
 
{{Category|Computing}}

Revision as of 22:01, 16 February 2014

This article is about an older version of DF.

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, creature logic, or minecart logic. With binary memory, each cell has two possible states, generally referred to as 0 and 1, or true and false.

Flip-flops versus latches

The most basic characteristic of memory in Dwarf Fortress is that it acts as a signal splitter: given a series of on-off signal cycles, it outputs a series of alternating on or off signals. Memory that does this, and only this, acts like a flip-flop: every time you trigger the memory, it changes state. Such memory is perfect for devices such as counters. However, it's common to desire the ability to write state directly to your memory, rather than toggling it-- that is, to write either true or false to memory directly, without knowing the current state of the memory. This can be described with a chart where the memory value feeds back into itself:

input latch state output new latch state
0 0 none 0
0 1 off 0
1 0 on 1
1 1 none 1


Performance

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.

~ X ^ ~

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 X and 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

p ¢ ^ ¢ ¢ ^ ¢ p

In this circuit, a creature placed between in the middle seeks its pathing goal p but is constrained by the hatches ¢ and ¢, 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.

z + 2
% %
z + 1
% % ^
z + 0
~

In this design, two separately powered pump stacks, %% and %%, 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 versus Power-to-signal

It can be tricky to differentiate memory from power to signal conversion. Through feedback, power-to-signal devices can often be changed into memory cells, and powered memory devices can be adapted into power-to-signal. Previous to the introduction of minecarts, the most common power-to-signal device bore strong resemblance to the memory cell described above. There is, however, a large difference between memory and power-to-signal. While memory designs receive on-off signal cycles and output discrete on or off signals in return, power-to-signal converters return exactly what they're given. That is, a signalling device that receives then loses power should return a full on-off signal cycle.

Minecart Logic

There are numerous ways for minecarts to hold information. Some memory designs use movement or the absence of movement; others use just the position of a minecart. Advanced designs could use the weight or direction of movement of a minecart. The following powered minecart design by Bloodbeard is the smallest memory circuit currently known to dwarvenkind:

3tdcbm.png

The diagram shows the minecart layer at the top, the roller/furniture layer in the middle, and finally the track layer at the bottom. When the northern gear assembly is activated, powering the northern roller, a heavy minecart (copper, in this example) is pushed southwards. This pushes a lighter minecart (iron here) south, and triggers a pressure plate that is built to only signal on the weight of a copper minecart, and not on the weight of the lighter iron minecart. With the activation of the southern gear assembly, the situation reverses. The iron minecart pushes on to the pressure plate, and an off signal is sent.

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) or when latency and refractory period are unimportant compared to resource requirements such as space.