Bay 12 Games Forum

Please login or register.

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

Author Topic: Numberabbey: 8-bit ripple-carry adder  (Read 19775 times)

Kanddak

  • Bay Watcher
    • View Profile
Numberabbey: 8-bit ripple-carry adder
« on: February 01, 2009, 04:51:52 pm »

I built this over the weekend:
http://mkv25.net/dfma/map-4523-numberabbey

I've seen a couple theoretical plans and proofs of concept for this kind of thing on the wiki, but never anything on this scale.
It runs beautifully, and some time I'll put up a video of it in operation and write a little about the problems I ran into trying to design it.
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.

DennyTom

  • Bay Watcher
  • !!Urist!!
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #1 on: February 01, 2009, 04:56:14 pm »

Well done!

I love the simplicity of output.
Logged
It is so much easier to measure life in experience points...

sonerohi

  • Bay Watcher
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #2 on: February 01, 2009, 08:36:56 pm »

 :o. I give unto thee a humble offering of eighty internets and a fresh batch of omni-cookies, 'the right flavor at the right time; omnicookies from keebler!'. That's a work of art right there, even if it makes my brain hurt.
Logged
I picked up the stone and carved my name into the wind.

Kanddak

  • Bay Watcher
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #3 on: February 01, 2009, 11:15:19 pm »

http://mkv25.net/dfma/movie-1084-numberabbeydemonstration

There's the beast doing two additions:
Code: [Select]
   27 : 0001 1011
+  82 : 0101 0010
= 109 : 0110 1101

   71 : 0100 0111
+ 123 : 0111 1011
= 194 : 1100 0010

You might have to do some tricky pausing at the end to catch the final result; the movie cuts off abruptly.

After I build it up to sixteen bits, I want to build some seven-segment displays out of retracting bridges. I don't suppose anyone around here has a good feel for the logic behind those?

Now, a little about the design process.

I wanted to build an adder, and I started here: http://www.dwarffortresswiki.net/index.php/User:Kyace/Adder
I noticed that the design has a major logical flaw. If you'll notice, a full adder with two false inputs and a true carry-in should output a true sum, but in that design, with two false inputs there is no way for water to go through the system to the sum pressure plate. I wanted a design that would be logically correct.

I also didn't like the way the design extended over z-levels with the output plates a level down, and used hatches-as-inverse-doors to control flow by draining water before it could reach the channels down to the plates. I wanted a design on one z-level, and in the interest of conserving water when running it through several adders, I wanted to avoid letting it flow through when not triggering an output.
http://www.dwarffortresswiki.net/index.php/User:SL/Logic_Gates suggested the concept of using 1x1 drawbridges as inverse doors.

I came up with a design that seemed correct and built Playsmiths. I quickly regretted combining instant doors with delayed drawbridges and resolved to use floodgates in the future. (Using delayed buildings instead of instant ones is a little bit of a bother, but I decided it was worth it to avoid the water-hogging nature of using hatches, or the overhead of supplementing each adder with an inverted for each color of door) I also had drainage problems.
I tried again with Weatherbridged. This time I discovered more significant flaws in my design, due to pressure not transferring diagonally. (I later turned this to my advantage in the drainage system for Numberabbey.)

That was a couple months ago and it was just this weekend I finally came back to it and designed a no-diagonals version of the full adder. I also settled on pushing pressurized water into each adder instead of giving each one its own pump to pull water from a supply system (didn't seem to give me enough volume) and hit on my idea of making the drainage pump feed back into the pressurized water whenever possible rather than dumping water outside unnecessarily.

But the most important innovation was building an access stairway in each separate compartment of the full adder for ease of construction.
This leads to my most important piece of advice for anyone designing such a project: Work one bit at a time, and have a meticulous method of construction which covers every single detail. There's a long row of identical constructions, and it is ridiculously easy to get confused and link something to the wrong thing — or accidentally give your link orders to the lever next to the one you meant, when you have a row of input levers — and end up having to tear everything back out and do it over again. I have four separate stages of construction for each full adder, where I build some of the parts, order them to be linked, and then build the next stage. They are always built in exactly the same order, so that they appear in exactly the same positions relative to the end of the linkable-building list.

Also, the most labor-intensive part of Numberabbey was actually the construction of the water and pump towers, but I am grateful for every minute of it. My two earlier attempts just stuck one pump next to a stream, built a cistern to store some water, and called it good. The logic part is actually pretty simple once you settle on a precise method to avoid making disastrous mistakes; the hard part is making the water system keep putting in enough water to consistently press the plates. The water-reusing drainage system was a major breakthrough in this regard, because it just gets better the more water you press into its intake.
« Last Edit: February 02, 2009, 09:57:57 am by Kanddak »
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.

Taritus

  • Bay Watcher
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #4 on: February 02, 2009, 01:10:41 am »

This is going to sound dumb, but on FallingSandGame.com there's always been an interest in using falling sand games to perform basic computing functions, and somebody finally cooked up a good adder, with a display.  You may want to check out the wxSand forums there.  I think the topic is something about a 4 bit adder with 7 segment display.  The only problem is that the display is in base-16, not base-10...  Not too sure how hard it would be to work around that...

I have a neat idea about how you could do the actual displays though.  To conserve space, I'd suggest using hatches and making the displays only 3 tiles wide and 5 tiles tall.  If you would use hatches that were the same material as the surrounding floor and had deep channels below them, deep enough to force the sky tile to appear (might just be 2 levels deep) you could use the open hatches to represent an ON signal to the display, mainly because it would be far more solid and distinct compared to a hatch the same color as everything next to it.

(My apologies for the rambliness of this post.  I'm typing on a Wii, and I can only view two lines at a time, making it difficult to carry a coherent thought...)
« Last Edit: February 02, 2009, 01:16:43 am by Taritus »
Logged



Kanddak

  • Bay Watcher
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #5 on: February 02, 2009, 01:20:44 am »

This is going to sound dumb, but on FallingSandGame.com there's always been an interest in using falling sand games to perform basic computing functions, and somebody finally cooked up a good adder, with a display.  You may want to check out the wxSand forums there.  I think the topic is something about a 4 bit adder with 7 segment display.  The only problem is that the display is in base-16, not base-10...  Not too sure how hard it would be to work around that...
Oh, hell, if it were hex it'd be easy. Each group of four bits would be the inputs to one display. No, I want to do it in decimal just for the insanity of it.

I was actually planning to use the black of underground open space for disabled display segments, and brightly colored bridges for enabled ones, with their surroundings being dull floor tiles.
Any design of that sort is going to save space compared to my original idea of flooding and draining segments with fluids (preferably magma), since you don't have to put spaces between the segments, which would then mean the segments themselves then need to be a certain size relative to the space for readability.
I think each segment's going to need to be at least three tiles wide to look good. It could certainly be done with 1x1 segments, but I don't think I'll do it that way unless I build something that really shows a vast amount of numbers and needs every possible tile of space.
« Last Edit: February 02, 2009, 01:26:32 am by Kanddak »
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.

Flaede

  • Bay Watcher
  • Beware the Moon Creatures.
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #6 on: February 02, 2009, 01:41:46 am »

Wow! I've been looking for good pictures of ACTUAL computing machines. I think this could be used to tally the year/month/season? once I figure out how long it takes water to flow how far.

...I'll wait 'till after the save-breaking release, though.

AMAZING.

ALso - Kanddak - you could save space (and get around the drainage/surroundings issue) if you use WATER for disabled segment, coloured floor tiles for one colour, and a floodgate for a second. ... and I just realized that the water would "muddy" the floor tiles.... drat.

OK. Try this then - floodgates on floortiles, then. Bridges have a delay, whereas I do not believe that floodgates do.
Logged
Toady typically doesn't do things by half measures.  As evidenced by turning "make hauling work better" into "implement mine carts with physics".
There are many issues with this statement.
[/quote]

JoRo

  • Bay Watcher
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #7 on: February 02, 2009, 03:44:38 am »

I am deeply impressed.  Bravo, sir, bravo.
Logged
You have been struck down.
The giant cave spider spits out your head.

Kanddak

  • Bay Watcher
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #8 on: February 02, 2009, 09:47:26 am »

Wow! I've been looking for good pictures of ACTUAL computing machines. I think this could be used to tally the year/month/season? once I figure out how long it takes water to flow how far.
There's another use for seven-segment displays. Of course it'll have to flash 12:00 when it's first turned on.
I was thinking about timekeeping and it occurred to me that you could take advantage of a map that freezes in winter to count years by making some system get interrupted when the map freezes and thereby increment a counter.
You could get a seasonal count by putting a pressure plate in a special hallway used only for caravan access, if you could be sure of keeping everything else out of there, and either account for the caravan going over it twice or redirect them out via another route.

Quote
OK. Try this then - floodgates on floortiles, then. Bridges have a delay, whereas I do not believe that floodgates do.
Yes, floodgates do have delays, which is why I use them with bridges in my adder design. I'm planning to use bridges over channels.
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.

AlienChickenPie

  • Bay Watcher
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #9 on: February 02, 2009, 10:50:47 am »

AFAIK, water flow is slightly random in DF, so water clocks should rely on multiple flows (or perhaps one large flow) to make sure that you get consistent results.
Also, the source that feeds the flows should be as consistent as possible, so damming a river and splitting the flow wouldn't cut it. You'd probably need pumps drawing from  distant points in the ocean, or identically shaped aquifer breaches.
Logged

qwertilliopasd

  • Bay Watcher
  • Octopus?
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #10 on: February 02, 2009, 07:36:06 pm »

After I build it up to sixteen bits, I want to build some seven-segment displays out of retracting bridges. I don't suppose anyone around here has a good feel for the logic behind those?

http://www.datasheetcatalog.org/datasheets/700/338023_DS.pdf
Is the IC I generally use for BCD to 7-seg. The equivalent logic diagrams are on page 5 of the PDF. You wouldn't need RBO, LT etc, but a display would wind up being way too much work incredibly dwarven.
Logged
What does a hermit need coffins for?
The other six dwarves.  How do you think he got to be a hermit?

LegoLord

  • Bay Watcher
  • Can you see it now?
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #11 on: February 02, 2009, 08:44:20 pm »

Congratulations.  You have built a mechanical (rather than electronic) calculator.  Now here's the real question;  would it work in real life?
Logged
"Oh look there is a dragon my clothes might burn let me take them off and only wear steel plate."
And this is how tinned food was invented.
Alternately: The Brick Testament. It's a really fun look at what the bible would look like if interpreted literally. With Legos.
Just so I remember

numerobis

  • Bay Watcher
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #12 on: February 03, 2009, 12:23:48 am »

Finally!  I've seen so much talk, up to people claiming they were going to build 32-bit computers, but never any actual fortress.
Logged

Sinergistic

  • Bay Watcher
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #13 on: February 03, 2009, 12:38:44 am »

Congratulations.  You have built a mechanical (rather than electronic) calculator.  Now here's the real question;  would it work in real life?

...

 ::)

Quite the achievement.
« Last Edit: February 03, 2009, 12:46:30 am by Sinergistic »
Logged

Kanddak

  • Bay Watcher
    • View Profile
Re: Numberabbey: 8-bit ripple-carry adder
« Reply #14 on: February 03, 2009, 01:17:40 pm »

Well, here's a controller for a 7-segment display. It turned out to be pretty easy to design, and easy to lay out in a self-explanatory manner (the pressure plates have the same spatial arrangement as the segments they'd control).

Spoiler (click to show/hide)

That'll show 0 through F. It's bigger than the combined adders that would provide its input, but still not too scary.
I don't know if I'll get to build any. I don't have a gigantic amount of time to spend on it, and I think I'd be best off starting a new fort and spending a bit more time making a properly livable fort, as well as an even bigger water system.
For the sixteen-bit adder, you'd need twelve displays (four for each of two inputs, four for the sum), and a way to make the output-display gears drive pumps that press plates that control the display inputs. (The input levers can control displays directly, as well as their associated adders.)
...and a binary-to-BCD converter. ;)
« Last Edit: February 03, 2009, 01:36:39 pm by Kanddak »
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.
Pages: [1] 2 3