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.

Editing User:Immibis/RAM

Jump to navigation Jump to search

Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.


The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
<s>Please note that the content of this page is (currently) only an idea and has not been tested.</s>
+
Please note that the content of this page is (currently) only an idea and has not been tested.
Update 04:44, 13 September 2010 (UTC): The main design (but not the control logic) has been tested with a prototype lever-controlled 2-bit RAM. Procedures for reading and writing have been updated to work around a bug in Dwarf Fortress.
 
  
 
==Space-efficient Random Access Memory==
 
==Space-efficient Random Access Memory==
Line 6: Line 5:
  
 
The overall layout is like this:
 
The overall layout is like this:
  Z-1
+
  Z -1
 
  x x x x    x = wall
 
  x x x x    x = wall
 
  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 D D D    D = door for access
 
x x x x    . = channel
 
 
  x x x x
 
  x x x x
 
  x x x x
 
  x x x x
  Z 0      Z+1
+
x x x x
 +
x x x x
 +
  Z 0      Z +1
 +
xxxxxxx  xxxxxxx
 +
xHxHxHx  x x x x
 +
xxxxxxx  xxxxxxx
 +
xHxHxHx  x x x x
 
  xxxxxxx  xxxxxxx
 
  xxxxxxx  xxxxxxx
  xHxHxHx  x.x.x.x
+
  xHxHxHx  x x x x
xxDxDxD  xxxxxxx
 
xHxHxHx  x.x.x.x
 
 
  xxxxxxx  xxxxxxx
 
  xxxxxxx  xxxxxxx
xHxHxHx  x.x.x.x
+
continued for a while in each direction.
xxDxDxD  xxxxxxx
 
continued for a while in each direction. To make Z+1 you probably want to build down-stairs on the channel tiles, up-stairs where the hatches will go, then remove the up-stairs.
 
  
The number of rows must be a power of two, the number of columns doesn't have to be.
+
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.
 
The values would be stored in the cells on Z+1.
Line 40: Line 39:
 
This is a destructive read, so the data must be rewritten afterwards.
 
This is a destructive read, so the data must be rewritten afterwards.
  
To write a 1 to a cell (ORDER IS IMPORTANT):
+
To write a 1 to a cell:
# Flood all columns to Z0.
+
# Flood all columns except the desired column to Z0. Flood the desired column to Z1.
 
# Open the hatches in the desired row.
 
# Open the hatches in the desired row.
# Flood the desired column to Z1.
 
 
# Water will flow into the cell, if it isn't already there.
 
# Water will flow into the cell, if it isn't already there.
  
To write a 0 to a cell (ORDER IS IMPORTANT):
+
To write a 0 to a cell:
# Flood all columns except the desired column to Z0.
+
# Flood all columns except the desired column to Z0. Drain the desired column.
# Drain the desired column.
 
 
# Open the hatches in the desired row.
 
# Open the hatches in the desired row.
 
# Water will flow out of the cell, if it's there.
 
# Water will flow out of the cell, if it's there.
Line 66: Line 63:
 
  x.^<span style='color: red'>#</span> x x x
 
  x.^<span style='color: red'>#</span> x x x
 
  xxxx <span style='color: blue'>#</span> x x
 
  xxxx <span style='color: blue'>#</span> x x
  x.^<span style='color: blue'>#</span> xxx xxx
+
  x.^<span style='color: blue'>#</span> xxx x
  xxxxxx x # <-- pressurized water source
+
  xxxxxx x <-- pressurized water source
  x.^<span style='color: red'>#</span> xxx xxx
+
  x.^<span style='color: red'>#</span> xxx x
 
  xxxx <span style='color: red'>#</span> x x
 
  xxxx <span style='color: red'>#</span> x x
 
  x.^<span style='color: blue'>#</span> x x x
 
  x.^<span style='color: blue'>#</span> x x x
Line 76: Line 73:
 
  x.^<span style='color: blue'>#</span> xxx
 
  x.^<span style='color: blue'>#</span> xxx
 
  xxxxxx
 
  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 [[floodgate]]s or [[door]]s 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)
+
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 [[floodgate]]s or [[door]]s 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.
  
 
===Per-column machinery===
 
===Per-column machinery===
Line 85: Line 82:
 
  x x  x^x  xxx
 
  x x  x^x  xxx
 
  x x  x.x  x.x
 
  x x  x.x  x.x
  x'''%'''x  x'''%'''x  x'''%'''x S = stairs for access
+
  x'''%'''x  x'''%'''x  x'''%'''x
  S%** S%** S%** '''%''' = pump output tile
+
  x%** x%** x%** '''%''' = pump output tile
 
  x.x  x.x  x.x  % = pump input tile
 
  x.x  x.x  x.x  % = pump input tile
 
  xxx  xxx  x x  . = channel
 
  xxx  xxx  x x  . = channel
Line 95: Line 92:
 
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 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)
+
The pressure plate should be set to about 2-7 or 3-7, as there will be 7 water which will spread between the pressure plate and the tile next to it.
 
 
===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 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 column's inputs aren't disconnected.
 
 
 
==AutoHotKey script==
 
This does most of the designation of the main area for you. It will designate enough for 1024 bits (32x32).
 
Before running this script, you must be in designate mode with the cursor on the bottom right lower-z corner of the 64x64x3 area.
 
 
 
<pre>
 
<nowiki>
 
#NoEnv
 
SetBatchLines, -1
 
ListLines, Off
 
 
 
SetKeyDelay, 15, 0
 
IfWinExist, Dwarf Fortress
 
{
 
WinActivate
 
WinWaitActive
 
 
 
; this is Z-1
 
; designate a 64x64 area to the top-left of (and including) the currently selected square for digging
 
Send d{ENTER}+{UP 6}{UP 3}+{LEFT 6}{LEFT 3}{ENTER}
 
 
 
; un-designate walls between columns, then return to starting point
 
Send x
 
Loop, 16
 
Send {RIGHT}{ENTER}+{DOWN 6}{DOWN 3}{ENTER}{RIGHT 2}{ENTER}+{UP 6}{UP 3}{ENTER}{RIGHT}
 
Send {LEFT}+{DOWN 6}{DOWN 3}
 
 
 
; make an access tunnel halfway up and return to starting point
 
Send d+{UP 3}{UP 1}{ENTER}+{LEFT 6}{LEFT 3}{ENTER}+{RIGHT 6}{RIGHT 3}+{DOWN 3}{DOWN 1}
 
 
 
; move one z-level up
 
Send +,
 
 
 
; this is Z0
 
; designate the same 64x64 area for up-stairs
 
Send u{ENTER}+{UP 6}{UP 3}+{LEFT 6}{LEFT 3}{ENTER}
 
 
; un-designate walls between columns and rows, then return to starting point
 
Send x
 
Loop, 16
 
Send {RIGHT}{ENTER}+{DOWN 6}{DOWN 3}{ENTER}{RIGHT 2}{ENTER}+{UP 6}{UP 3}{ENTER}{RIGHT}
 
Send {LEFT}
 
Loop, 16
 
Send {DOWN}{ENTER}+{LEFT 6}{LEFT 3}{ENTER}{DOWN 2}{ENTER}+{RIGHT 6}{RIGHT 3}{ENTER}{DOWN}
 
Send {UP}
 
 
 
; designate access door spaces for digging and return to starting point
 
Send d
 
Loop, 16
 
{
 
Send {UP 2}
 
Loop, 32
 
Send {ENTER 2}{LEFT 2}
 
Send +{RIGHT 6}{RIGHT 4}
 
Send {UP 2}
 
}
 
Send +{DOWN 6}{DOWN 4}
 
 
 
; move one z-level up
 
Send +,
 
 
 
; this is Z+1
 
 
 
; designate the same 64x64 area for down-stairs
 
Send j{ENTER}+{UP 6}{UP 3}+{LEFT 6}{LEFT 3}{ENTER}
 
 
; un-designate walls between columns and rows, then return to starting point
 
Send x
 
Loop, 16
 
Send {RIGHT}{ENTER}+{DOWN 6}{DOWN 3}{ENTER}{RIGHT 2}{ENTER}+{UP 6}{UP 3}{ENTER}{RIGHT}
 
Send {LEFT}
 
Loop, 16
 
Send {DOWN}{ENTER}+{LEFT 6}{LEFT 3}{ENTER}{DOWN 2}{ENTER}+{RIGHT 6}{RIGHT 3}{ENTER}{DOWN}
 
Send {UP}
 
 
 
; move two z-levels down
 
Send +{. 2}
 
 
 
; finished
 
}
 
else
 
{
 
MsgBox Dwarf Fortress is not running
 
}
 
</nowiki>
 
</pre>
 

Please note that all contributions to Dwarf Fortress Wiki are considered to be released under the GFDL & MIT (see Dwarf Fortress Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)