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 "User:Immibis/RAM"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
Line 9: Line 9:
 
  x x x x    H = hatch
 
  x x x x    H = hatch
 
  x x x x    All the hatches in a single (horizontal) row are connected to one pressure plate
 
  x x x x    All the hatches in a single (horizontal) row are connected to one pressure plate
  x x x x   D = door for access
+
  x D D D   D = door for access
 
  x x x x
 
  x x x x
 
  x x x x
 
  x x x x
Line 16: Line 16:
 
  xxxxxxx  xxxxxxx
 
  xxxxxxx  xxxxxxx
 
  xHxHxHx  x x x x
 
  xHxHxHx  x x x x
  xxxxxxx   xxDxxxD
+
  xxDxxxD   xxDxxxD
 
  xHxHxHx  x x x x
 
  xHxHxHx  x x x x
 
  xxxxxxx  xxxxxxx
 
  xxxxxxx  xxxxxxx
 
  xHxHxHx  x x x x
 
  xHxHxHx  x x x x
  xxxxxxx   xxDxxxD
+
  xxDxxxD   xxDxxxD
 
continued for a while in each direction.
 
continued for a while in each direction.
  

Revision as of 07:50, 12 February 2010

Please note that the content of this page is (currently) only an idea and has not been tested.

Space-efficient Random Access Memory

The basic idea is to have a grid of 1x1 cells that can hold some water (or magma). The specific cell to read/write would be selected by selecting the row and the column of the desired cell. This will require some complicated machinery to manage, however.

The overall layout is like this:

Z -1
x x x x    x = wall
x x x x    H = hatch
x x x x    All the hatches in a single (horizontal) row are connected to one pressure plate
x D D D    D = door for access
x x x x
x x x x
x x x x
Z 0       Z +1
xxxxxxx   xxxxxxx
xHxHxHx   x x x x
xxDxxxD   xxDxxxD
xHxHxHx   x x x x
xxxxxxx   xxxxxxx
xHxHxHx   x x x x
xxDxxxD   xxDxxxD

continued for a while in each direction.

The number of rows should be a power of two, the number of columns doesn't have to be.

The values would be stored in the cells on Z+1.

Notes:

  • The "desired column" means the column containing the cell to be read/written.
  • The "desired row" means the row containing the cell to be read/written.
  • "Flood XXX to ZZ" means to flood the area up to and including the Z-level ZZ.
  • "Drain XXX" means the area should not be flooded at all.

To read a cell:

  1. Flood all columns except the desired column to Z0. Flood the desired column to Z-1.
  2. Open the hatches in the desired row.
  3. If the cell contains water, the water will flow onto a pressure plate on Z0 of the column (not shown in the diagram)

This is a destructive read, so the data must be rewritten afterwards.

To write a 1 to a cell:

  1. Flood all columns except the desired column to Z0. Flood the desired column to Z1.
  2. Open the hatches in the desired row.
  3. Water will flow into the cell, if it isn't already there.

To write a 0 to a cell:

  1. Flood all columns except the desired column to Z0. Drain the desired column.
  2. Open the hatches in the desired row.
  3. Water will flow out of the cell, if it's there.

Memory controller

Just another reminder: this is all theory and hasn't been tested.

The controller described here requires a source of highly pressurized water. (From a pump or an infinite source, which should be a few z-levels higher than the machinery). Remember to be very careful!

Per-row machinery

Each row needs a single pressure plate connected to all hatches along that row. The input to this part of the controller is a binary number indicating which row to select. Since the number of rows must be a power of two, this is easy:

xxxxxx
x.^# xxx
xxxx # x
x.^# x xxx
xxxxxx # x
x.^# x x x
xxxx # x x
x.^# xxx xxx
xxxxxx x # <-- pressurized water source
x.^# xxx xxx
xxxx # x x
x.^# x x x
xxxxxx # x
x.^# x xxx
xxxx # x
x.^# xxx
xxxxxx

Continue this pattern for more rows. Vertical lines of # marks are all related to the same bit of the input (it doesn't matter which line connects with which bit). Blue # marks are floodgates or doors linked to that bit. Red # marks are floodgates or doors linked to the inverse of that bit (they will be open when the red ones are shut and vice-versa). "." is a channel to a drain, probably down a few z-levels. The floodgate which is not red or blue lets water into the machine. This is used to close all hatches. The pressure pads should be set to about 3-7 (experimentation needed)

Per-column machinery

Each column needs three pumps with gears, one for each Z-level that can be flooded (-1, 0 and 1). They also need floodgates or pumps at the other end to drain them. Also, a pressure plate on Z0 is required. They might be arranged like this:

Z-1  Z 0  Z+1
x x  xxx
x x  x^x  xxx
x x  x.x  x.x
x%x  x%x  x%x  S = stairs for access
S%** S%** S%** % = pump output tile
x.x  x.x  x.x  % = pump input tile
xxx  xxx  x x  . = channel
           ^
           | pressurized
           | water source

The floor below the pumps should NOT be channeled or they will transfer power to each other. The left gear on each z-level will be connected to the control logic and the right gear provides power between Z-levels. The right gears have channels between them to transfer power.

The pressure plate should be set to about 2-6 or 3-6, as there will be 7 water which will spread between the pressure plate and the tile next to it. However, if there is 7 water on each tile, then the column must be flooded to Z0 or Z+1 in which case the output needs to be 0 (so we can OR all columns to get the result)

Control logic

When unused, all columns should be flooded to Z0. The pumps and drains for each column should be connected to a logic circuit as follows: (the drain could be a pump or a floodgate) (this assumes the inputs are disconnected for undesired columns)

  • Z-1 pump = read
  • Z0 pump = NOT (write-1 OR read OR write-0)
  • Z+1 pump = write-1
  • Drain = write-0

Alternatively:

  • Z-1 pump = read AND selected
  • Z0 pump = NOT selected
  • Z+1 pump = write-1 AND selected
  • Drain = write-0 AND selected.

The read, write-0 and write-1 inputs can be connected together for every column, if there is a way of disconnecting individual columns from all three at once.

The control logic needs to do the following (in any order or simultaneously), for any operation:

  • Disconnect inputs to all unused columns, so they will be pumped to Z0.
  • Send the appropriate signals for 'read', 'write-1' and 'write-0' (one will be true, indicating the operation to be performed)

It then needs to open the hatches for the particular row after a delay, by opening the floodgate to let water into the row control machinery.

write-0 = LATCH(SET = write-operation AND NOT data, RESET = NOT busy)
write-1 = LATCH(SET = (write-operation AND data) OR read-output, RESET = NOT busy)
read = LATCH(SET = (read-operation AND NOT read-sensor), RESET = NOT busy)
read-output = LATCH(SET = read-sensor, RESET = NOT busy)
busy = LATCH(SET = start, RESET = DELAY(start))
(none of this has been tested)

start, write-operation, read-operation are inputs to the device. read-output is an output from the device. read-sensor is generated by OR'ing together all the sensing pressure plates. read-operation and write-operation should probably be latched when 'start' becomes true.

The address is used as follows:

  • As mentioned earlier, the number of rows MUST be a power of two, but the number of columns doesn't need to be.
  • If there are 2^N rows, the lower N bits of the address go directly to the row control machinery.
  • The upper bits of the address select which row's inputs aren't disconnected.