Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 11

Author Topic: Dwarven Computer  (Read 167312 times)

Jong

  • Bay Watcher
    • View Profile
Dwarven Computer
« on: February 16, 2010, 01:12:20 pm »

    Design for a Dwarven Computer

    Updated:19/03/10

    EDIT:

    BWAHAHAHAHA!!!
    I FINALLY SUCCEEDED!!!



    Click Here to see my testing results
    http://www.bay12games.com/forum/index.php?topic=49641.msg1094222#msg1094222

    Introduction

    One day, I commented to my friend that my fortress power plant was far too large. He suggested I build a dwarf computer to soak up some of that excess power. I decided to take him up on that challenge, so currently I am drawing up plans for a dwarven computer and I have serious intent to actually construct it.

    I have never studied computer science and prior to this project, had no clue how computers actually functioned. Based on what I know now building a dwarven computer is starting to look like it requires even more power generation!

    A slight digression into the precedents of dwarven computing. The wiki covers in detail a number of simple logic mechanisms. The page on computing also contains a few links to mechanical marvels such as automatic magma traps, seven segment displays, adders of various sizes and even an attempt to construct a dwarven calculator. What I am attempting is essentially a fully automated calculator. This is the true nature of a computer.

    Contents

    • To do list
    • Testing Schedule
    • Design notes
    • Power sensor
    • Memory Cell
    • Registers
    • Memory Unit
      • Decoder
      • Memory unit Registers
      • Memory unit architecture
    • Designing the machine language
    • Design for the Arithmetic Logic Unit(ALU)
      • Design for a half adder
      • Design for a full adder
      • Design for an 8-bit ripple carry adder-subtracter
      • Design for a carry-look-ahead adder
      • Design for ALU architecture
    • Under construction

    Things to do:

    Design power sensor
    Design memory cells
    Design registers
    Design memory unit

    Design machine instructions
    Design ALU
    Design control unit
    Design clock
    Design bus

    Assemble designs
    Draw up blueprints
    Construct computer
    ...
    Profit!

    Warning! Giant Wall of Text!

    Spoiler (click to show/hide)
    « Last Edit: March 27, 2010, 03:52:46 am by Jong »
    Logged

    Steveninn

    • Bay Watcher
    • What ya' lookin at there buddy?!
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #1 on: February 16, 2010, 01:26:10 pm »

    *Stares in awe* :o
    Logged
    I think of it as what would happen if The Sims and Lemmings had a baby, which was then adopted by the Balrog.

    Shrike

    • Bay Watcher
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #2 on: February 16, 2010, 01:38:17 pm »

    Yes but is it turing complete?
    Can it play DF?

    I'm sure there have been a number of brainy dwarves who have attempted this, but I'm very interested in seeing a successfully completed version.


    Are you planning to do I/O in dec or bin? Binary would be easier to implement, but if you wanted to do decimal, you could lay out some levers in a keypad formation.

    Don't forget to put in a clear function lever to reset to the start state, in case some smartypants tries to throw in a divide by zero.
    Logged

    Jyppa

    • Bay Watcher
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #3 on: February 16, 2010, 01:43:37 pm »

    Oh, shit. Time to start waiting for the first simulated dwarven qubit, then!
    As for "fast on and off", the optimal design for speed might be to stack another pump on top of the first, and have it turn off whenever the other one turns on. It would pump the water to the tile right above the original source tile where it would drop down to reset the system perfectly, which preserves water and reduces the reset time to exactly 100 steps, reliably. You only need to pond fill the one tile once for each sensor, as well, which might be more convenient than an extensive water dispensal system.
    Logged

    Shinziril

    • Bay Watcher
    • !!SCIENCE!!
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #4 on: February 16, 2010, 02:38:38 pm »

    Jyppa, I've tried things like that, and the problem is that the water sometimes decides to wander sideways while falling and leaves a 1/7 residue on the walkable tile of the lower pump, which removes water from the system. 

    Also, another easy way to remember the formula for a decoder is that each unique combination of n inputs is the binary representation of the numerical designation of the output (so for n = 2; 00 = 0, 01 = 1, 10 = 2, 11 = 3) and so on.  Then you set up the combination of normal and inverted gates such that the specific output is TRUE for its numerical designation (I.E., output 0's logic is (NOT1)&(NOT2), output 2's logic is (NOT1)&(2), etc). 
    « Last Edit: February 16, 2010, 03:01:10 pm by Shinziril »
    Logged
    Quote from: lolghurt
    Quote from: Urist McTaverish
    why is Dwarven science always on fire?
    Because normal science is boring

    Jyppa

    • Bay Watcher
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #5 on: February 16, 2010, 02:46:59 pm »

    Oh, in that case you'd have to build a 4 pump circle to get it back where it started, or make the source tile replenishable to get the immediate drain benefit. Possibly too much of a space sacrifice to make direct pumping viable.
    Logged

    Shinziril

    • Bay Watcher
    • !!SCIENCE!!
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #6 on: February 16, 2010, 03:19:31 pm »

    Aha!  An idea! 

    Side view:

    Code: [Select]
       *
    #_<%_#
    #_%>^#
    #_#*##
    ######

    Top view
    Code: [Select]
    Bottom Pump       Top Pump
    ###               ###
    #^#               #.#
    #%#               #%#
    #%#               #%#
    #.#               #.#
    ###               ###

    The gear inputs come in from the top and bottom, as you can see in the side view.  You fill the level up to 7/7 on the level of the walkable tile of the bottom pump, so removing one tile for the pressure plate simply creates a sloshing 3/7 and 4/7 tile pair (which will not evaporate).  The top pump drops the tile back to the beginning.  Put two of these side-by-side (one for write, one for read) and you have a memory cell.  You can dig out a little more by the bottom input gear for more space if you need it. 

    This removes the need for a complicated water supply system for all 32 registers, which is quite nice (although it is going to use a lot of mechanisms and power).  Also, the read/write gears are no longer on the same z-level as the actual pumps they are powering, which makes it a little less intuitive to build, but I think it'll be worth it.

    I love it when an idea comes together.

    EDIT: Did some prototyping, here's a full diagram of an 8-bit register using this model:

    Level 0:
    Code: [Select]
    *=*===*=*===*=*===*=*===*=*===*=*===*=*===*=*=C
    #W#R# #W#R# #W#R# #W#R# #W#R# #W#R# #W#R# #W#R#|
    #I#o# #I#o# #I#o# #I#o# #I#o# #I#o# #I#o# #I#o#*
    ##### ##### ##### ##### ##### ##### ##### #####
    #+#+# #+#+# #+#+# #+#+# #+#+# #+#+# #+#+# #+#+#
    ##### ##### ##### ##### ##### ##### ##### #####

    Level 1:
    Code: [Select]
    #D#D# #D#D# #D#D# #D#D# #D#D# #D#D# #D#D# #D#D#
    #^#^# #^#^# #^#^# #^#^# #^#^# #^#^# #^#^# #^#^#
    #%#%# #%#%# #%#%# #%#%# #%#%# #%#%# #%#%# #%#%#*
    #%#%# #%#%# #%#%# #%#%# #%#%# #%#%# #%#%# #%#%#
    #.#.# #.#.# #.#.# #.#.# #.#.# #.#.# #.#.# #.#.#
    ##### ##### ##### ##### ##### ##### ##### #####

    Level 2:
    Code: [Select]
    ##### ##### ##### ##### ##### ##### ##### #####
    #.#.# #.#.# #.#.# #.#.# #.#.# #.#.# #.#.# #.#.#
    #%#%# #%#%# #%#%# #%#%# #%#%# #%#%# #%#%# #%#%#*
    #%#%# #%#%# #%#%# #%#%# #%#%# #%#%# #%#%# #%#%#
    #.#.# #.#.# #.#.# #.#.# #.#.# #.#.# #.#.# #.#.#
    ##### ##### ##### ##### ##### ##### ##### #####

    Level 3:
    Code: [Select]
    +++++ +++++ +++++ +++++ +++++ +++++ +++++ +++++
    +.+.+ +.+.+ +.+.+ +.+.+ +.+.+ +.+.+ +.+.+ +.+.+
    +*=*===*=*===*=*===*=*===*=*===*=*===*=*===*=*=*
    +N+N+ +N+N+ +N+N+ +N+N+ +N+N+ +N+N+ +N+N+ +N+N+
    +.+.+ +.+.+ +.+.+ +.+.+ +.+.+ +.+.+ +.+.+ +.+.+
    +++++ +++++ +++++ +++++ +++++ +++++ +++++ +++++

    Key:
    # = Wall, + = Floor, . = Open Space, * = Gear, %% = Pump, ^ = Pressure Plate, = or | = Horizontal Axle, W = Write, R = Read, I = Input, o = Output (linked to the appropriate ^), N = NOT-Input, C = Circuit Select, D = Door

    Notes:

    Need floor between individual memory bits on level 3 (to support horizontal axle), floor under D and ^ on level 1, floor under the pumps on level 2 (both tiles, to prevent power transfer between level 1 and level 2), and floor under the upper power gears on level 3 (to prevent bypassing the NOT-input gears). 

    This is probably easier constructed than dug out.  You'll probably want "scaffolding" stairs around each memory bit (the space left between the bits makes this easy).

    When constructing pumps, leave the wall orthagonally next to the unwalkable tile of the pump undone, so that the workers can get in diagonally to work on the pump but won't be able to trap themselves in when you finish the wall.

    This memory register should use about . . . 500-odd power?  Definitely less than 600, but more than 500.
    « Last Edit: February 16, 2010, 05:03:03 pm by Shinziril »
    Logged
    Quote from: lolghurt
    Quote from: Urist McTaverish
    why is Dwarven science always on fire?
    Because normal science is boring

    Jong

    • Bay Watcher
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #7 on: February 16, 2010, 09:23:13 pm »

    Ah that was pretty much how I imagined a memory cell with a pump powered drain Shinziril. I think I will link up a water supply system anyway because I already have an elaborate plumbing system in my fortress.

    One question though: Can gears be built on open space? If so, what happens when they are toggled?

    Yes but is it turing complete?
    Can it play DF?

    Well its turing completeness would depend on the instruction set the computer can execute, which will be unveiled soon. According to the document I am reading, it is complete, which means that any function can be written as a combination of the instructions, given enough memory, and time!

    Unfortunately since the prototype will only have a 5-bit address space, it is highly unlikely that you can play DF on it!

    Shinziril

    • Bay Watcher
    • !!SCIENCE!!
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #8 on: February 16, 2010, 10:10:26 pm »

    A gear assembly can be built so that it is unsupported by solid floor and designated as "hanging" in the Query menu.  If you toggle it, it will still be supported by other machinery, but (and this is an important "but") it will cease supporting other machinery.  So building a toggleable gear assembly on top of another gear assembly, connected to a gear assembly on solid ground, is perfectly fine.  But putting a windmill (or another gear assembly) on top of or beside that toggleable gear assembly, unsupported by floor, is not fine. 
    Logged
    Quote from: lolghurt
    Quote from: Urist McTaverish
    why is Dwarven science always on fire?
    Because normal science is boring

    Jong

    • Bay Watcher
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #9 on: February 17, 2010, 08:06:43 am »

    A gear assembly can be built so that it is unsupported by solid floor and designated as "hanging" in the Query menu.  If you toggle it, it will still be supported by other machinery, but (and this is an important "but") it will cease supporting other machinery.  So building a toggleable gear assembly on top of another gear assembly, connected to a gear assembly on solid ground, is perfectly fine.  But putting a windmill (or another gear assembly) on top of or beside that toggleable gear assembly, unsupported by floor, is not fine. 

    I see. I suppose the hanging gear assembly must be supported by other machinery in any case. What I had in mind was something like this:

    Code: [Select]
      TP
    # %% #
    # ####
    ######

    where T is the toggled gear and P is a supported powered gear, rather than

    Code: [Select]
      **TP
    # %% #
    # ####
    ######

    I suppose I would have to build an additional support gear next to T if the logic chain is longer than 1. Can a lone axle attached to nothing else provide support?

    I have updated my design and it now includes details of the machine instruction set and designs for a full 8-bit ripple carry adder-subtractor. Still a long way to go to a full computer!

    starburst98

    • Bay Watcher
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #10 on: February 17, 2010, 11:16:52 am »

    if the axle is on a floor, then yes, it will support things.
    Logged

    Kanddak

    • Bay Watcher
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #11 on: February 17, 2010, 01:47:37 pm »

    My experience with logic has been that toggling a bunch of pumps mechanically is a huge hassle and not the way to do things.
    I always build a huge elevated tank of water to feed all my logic systems, and control its flow with floodgates and 1x1 drawbridges. A single stack of pumps runs the whole thing.
    Logged
    Hydrodynamics Education - read this before being confused about fluid behaviors

    The wiki is notoriously inaccurate on subjects at the cutting edge, frequently reflecting passing memes, folklore, or the word on the street instead of true dwarven science.

    shadow_slicer

    • Bay Watcher
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #12 on: February 17, 2010, 01:55:54 pm »

    About the memory cells, I don't see why you need a separate cell for reading and writing.

    You should only need one cell to hold the water representing the bit with a pressure plate for reading. Then you can have that pressure plate toggle a gear assembly linked to the memory output.

    So for a single bit where the pressure plate in each of four memory cells is connected to gears i o p q with corresponding read lines (from decoder) connected to gears r s t u, the combiner at the end is:
    Code: [Select]
    *=*=*=*=Power
    i o p q
    r s t u
    *=*=*=*=Output

    If you need the output to be triggered by a pressure plate, you could even share a single "output buffer" among all of the memory cells. This buffer would basically be another memory cell, only it would used the output from the combiner as its input. This should save a significant amount of space and power.
    Logged

    Stas

    • Bay Watcher
    • Procrastination
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #13 on: February 17, 2010, 04:54:13 pm »

    Epic.

    You should make it so, when a /b/tard tries to Divide by Zero, the computer destroys itself.
    Logged

    No I'm not psychic. I just know that this is dwarf fortress. and the most stupidly awesome and inexplicable thing is probably going to be the first thing to happen.

    Keldor

    • Bay Watcher
    • Blood for the blood god!
      • View Profile
    Re: Design for a Dwarven Computer Prototype
    « Reply #14 on: February 17, 2010, 05:21:54 pm »

    Epic.

    You should make it so, when a /b/tard tries to Divide by Zero, the computer floods the fort.  With magma.

    Fixed.
    Logged
    If ignorance is bliss, why are my dwarves all tantruming?
    Pages: [1] 2 3 ... 11