Bay 12 Games Forum

Please login or register.

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

Author Topic: Need for speed (dwarven computing)  (Read 11758 times)

Larix

  • Bay Watcher
    • View Profile
Re: Need for speed (dwarven computing)
« Reply #45 on: February 17, 2015, 12:54:47 pm »

I threw something together to see how to make a data processor with variable length instruction words.
Spoiler (click to show/hide)
Dwarven computers so far (all two or three of them) have used instructions of fixed length, because keeping signals apart in DF is a massive pain. But variable instruction word lengths would be one way to build more complicated machines; the other would be using much longer instruction words, which would quickly lead to escalating investments in raw machinery. So, to keep it simple, i slapped together a crude tape processor that has no computing power whatsoever: it uses a two-bit "instruction", allowing for four activities:
00: invert contents of the accumulator
01: right-rotate contents of the accumulator
10: load accumulator from adress
11: store accumulator at adress

00 and 01 need no extra argument, 10 and 11 take a second double bit as argument, and for that end, the machine must be able to handle a single vs. a double-length "instruction grunt".

For now, i'll just put up two pictures of the finished demo installation and try to explain the issues when i feel like it:
The two activated plates on the southern track show the last operation was double-length. Above, the activities show the operation was 11 01 - store at adress 10 (adresses are decoded through simple gears, so they actually output the XOR of the two "grunts": store operations take the inverse of the actual adress as second argument, loads use +/-2).

Spoiler: "ALU" (click to show/hide)
The actual operation circuit. Decoded signals are sent here and either one or both carts get moving. The cart to the left is heavier and only calculates the inverse of the accumulator's contents, everything else - read/write and right-rotate are done by the lighter cart on the right side - currently somewhere in the southeast of the circuit (not visible because apparently i hit print in the wrong half-second).

Four "memory" and one "accumulator" locations of six bits each (ordinary water-logic cells), sixteen-grunt looping tape; processing speed somewhere between 150 and 200 steps per full operation. Took something like a thousand mechanisms.

EDIT:
O.k., so what's the point?

Primarily, variable-length instruction words are something that greatly increases the capability of real-world computers relative to their notional instruction word length: an eight-bit chunk of program data gives 256 options, which would allow for a large number of operations, but would be next to nothing if you have operations that can occur with a large number of different parameters like memory adresses to read from/write to. Expanding the size of the basic instruction word to fit the bill is not necessarily the best option; a common approach in microprocessors was/is to construct some of the instructions from several bytes, often a variable number.

Now, a real-world instruction pipeline would be difficult to implement in DF: reading and moving data is generally complicated and slow in the game. But i was curious how viable the basic principle would be. That's all this Single-Purpose Experimental Machine (S.P.E.M.) is supposed to achieve and demonstrate.

The Tapes:

The PROGRAM TAPE holds one minecart per position. Carts fall into one of four weight groups: up to 100, 100-400, 400-500, 500 and above. Minecarts are set in motion by signals from the COUNTING TAPE. The single cart on that tape is pushed forward one position everytime power is received.

On each advancement, the counting cart sends activation signals to two positions on the program tape. This sets the two carts in motion and pushes them over two weight-sensitive pressure plates: one responds to weights 400 and above, the other to 100-500. This decodes the cart weights into signal outputs:
</= 100: 00
100-400: 01
400-500: 11
>/= 500: 10

Operation identification:

Of course, if we fed all received signals into a single unified decoder, we'd just get some (boolean) function derived from _both_ carts' values. This would mean information loss - when two states of the first bit are XORed (as usual with single signal-driven gears), the output is either 0 or 1, while we have four possible input configurations. Only the first position's value interests us for the operation itself, so we need to keep the first and second carts' signals separate. We also must keep in mind that with variable-length instructions, values can switch roles: if on one read you find a single-grunt instruction, the operation's "parameter", derived from the value of the second grunt, will be discarded. The counting cart will advance one position and on the next read, the erstwhile second cart is now the first and determines the operation.

Thus, i built a "position-sensitive" OPERATION DECODER:
Code: [Select]
  1A
PR☼☼RO
 R☼☼R
  2B

Decodes one bit; there are two of these since we're dealing with a two-bit processor. An eight-bit processor would need eight. If instructions could be three "instruction atoms" long, each bit-decoder would need to be three instead of two gear pairs wide.

P- power supply
R- NS-rollers, only used for power transmission
O- output

1- gear assembly engaged by the "odd" position signal of the counting tape
2- gear assembly engaged by the "even" position signal of the counting tape
A- gear assembly engaged when weight of the cart at the "odd" position matches
B- gear assembly engaged when weight of the cart at the "even" position matches

The trick is that the cart on the counting tape alternates between engaging the 1 and 2 gear on successive advancements. At the same time, the weighing plates on the program tape are only wired to one of the A and B assemblies, they also alternate between A and B with each position. The output will be on when either 1 and A or 2 and B are on.

The value of the "operand" is decoded by inputting signals from both positions to the same gear: since we already successfully determined the precise value of the first grunt, the second _can_ now be reverse-decoded from an XOR of grunts one and two. The same would apply for instructions with even more parts - if we already know the value of grunts one and two, a parity-gate indiscriminately checking grunts one to three is enough to determine the value of grunt three.

Stepping control

Now, the second issue is that with occasional longer instructions, the counting cart needs to advance an extra step sometimes. This could cause all sorts of issues: generally, the counting cart will disengage power supply to the counting tape to limit its advancement to a single step. After a double-length instruction, this blockage must be bypassed to allow the extra advancement (unless you want to wait the full 100 steps for normal time-out. I don't.). But wait, there's more! If you bypass the limit, the next self-limiting signal of the counting cart could just re-engage the "limiter" gear assembly. Solution, quite simply: use two limiter assemblies in line and alternate between them again. The result is this TAPE CONTROL CLUTCH:

Code: [Select]

PI-R12R-PO
   RBLR


PI- Power in
R- Rollers, as above
PO- Power out

1- self-limiter from "odd" positions
2- self-limiter from "even" positions
B- bypass gear assembly, engaged when the bypass condition is fulfilled
L- bypass limiter, disengaged a few steps after triggering the bypass (two pressure plates on the same minecart circuit)

The only remaining control measure is another power-interrupt triggerred from the program tape, so that the program signals are limited and the advancing counting cart can't trigger another program read.

Component cost:

Each pressure plate on the counting tape is connected to: two gears in the decoder, two gears powering rollers on the program tape, an interruptor gear, the operation trigger (minecart delay circuit). Twelve linkage mechanisms for each position.
Each position on the program tape contains three pressure plates. Two are weighing plates, each linked to two decoders - one position-sensitive operation decoding, one insensitive adress decoding (just XORs both grunts where the second is not reused by other instructions, thus no impediment on adressing). One plate built on every other position connects power to the decoder (not actually required), another also only built on every other position (thus three per-position) disconnects power to the program tape. Ten mechanisms (averaged) per position for links.

This gives us 22 mechanisms for linkages only. There are seven more mandatory for pressure plates, rollers and powering gears; add another for power supply and we get thirty mechanisms per program position, to handle two-bit "words". Trying to tell the purposes apart, i'd say that comes out at fourteen mechanisms per position to regulate the tapes, eight mechanisms per position per bit for decoding program data.

Conclusion

The S.P.E.M. works reliably and pretty quickly, just under 160 steps per full operation, including double-length instructions. The main obstacle to getting closer to the intrinsic limit of signal processing (the 100 step signal time-out)  is decoding: it takes ~30 steps to properly read and identify an instruction. Shaving off another ten steps from the current 160 should be feasible without fiddly step-by-step finetuning, but i expect a hard limit of around 130 for this overall design. The 30 bits of fluid memory, as usual, are suffering from overseer stupidity - once again, i built the memory bank directly below the river's main level, allowing vermin fish into the construction, which of course went and gummed up the works.

Variable-length instruction words are possible in DF and can be executed at fairly high speed: the given case performs at 159 steps per instruction, while the theoretical signal-processing limit is 100 theoretically, 110 practically. Operations of actual computational value would be more complicated, but could likely run at similar speeds. The one-off and per-bit-per-position investment costs for the controller are substantial; limiting activity times of machinery is crucial and fairly complicated. The actual usefulness hasn't really been touched on because the S.P.E.M. is only a feature demonstrator, not an actual dwarven computer.
« Last Edit: February 18, 2015, 05:56:02 am by Larix »
Logged

gchristopher

  • Bay Watcher
    • View Profile
Re: Need for speed (dwarven computing)
« Reply #46 on: February 18, 2015, 01:54:37 pm »

Wow, having fun watching this!
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Need for speed (dwarven computing)
« Reply #47 on: February 18, 2015, 09:59:22 pm »

Everything I know about programming I learned from Dwarf Fortress.

"Wow, you studied the code and learned how to write your own from it?"
'What? No! I bashed minecarts together across ramps and repurposed trap components.'
Logged

Larix

  • Bay Watcher
    • View Profile
Re: Need for speed (dwarven computing)
« Reply #48 on: February 20, 2015, 03:18:16 pm »

A Modest Proposal for a minecart-based ALU

The Arithmetic-Logic Unit is the core of data manipulation in computers; it takes data as input and outputs various arithmetic or logic (hence the name) functions: addition, subtraction, logical AND/OR etc., stuff like that; the output sent is governed by the operation requested by the control logic.

A core component of an ALU would usually be an adder: with some input preprocessing, it can usually double as subtraction engine and in real-world circuits, it's often quite easy to derive one-input inversion, logical AND and XOR by just tapping into logic gates required by the adder/subtractor anyway.

It's not very different in dwarf fortress: an adder has to generate some preliminary logic to arrive at the sum, and that logic can be wired as output, too. It's not so easy to do this in the instant-result mechanical adder, but the Cart+Door adder i recently designed really only needs enough pressure plates and different-weight carts to do most simple binary comparisons:

Spoiler (click to show/hide)


The basic cell looks like this:

Code: [Select]

#║###          #║###
#╚╚╗####       #╚▲1###
#║#╚╚═╗#       #A#╚▲4╗#
#╚╗╬╔═╗#       #╚╗B▲2╗#
##╗╔##╗###     ##▲▲##▲###
##║║##╚══╗#    ##║3##5══╗#
##╚╚╗╗╬╔═╗#    ##╚╚▲6C▲7╗#
#####║╔##╗#    #####║▲##▲#
    #║║##║#        #║8##x#
    #╚╚╚═╗#        #╚╚▲9╗#
    #####╚         #####╚

  Paths           Buildings/structures

All ramps are impulse ramps, installed to regulate cart movement, i.e. to force carts to touch the pressure plates behind them.

The only switching devices are the three doors:
A - door linked to input A
B - door linked to input B
C - door representing the carry/borrow calculated on the last (next lower) bit

Output is derived from the various pressure plates. Important for actual addition and subtraction are the pressure plates 2,3,7 and 8

Plate 2: activated when the cart passes through doors A and B; logical AND, generated carry.
Plate 7: activated when inputs A and B are different and the carry input is on: propagated carry.
Plate 3: on when cart is deflected at door A and passes through door B - Minuend zero, subtrahend one, generated "borrow"
Plate 8: activated when inputs A and B are equal and the borrow input is on: propagated borrow.

When carries/borrows are calculated, the circuit does proper addition or subtraction. The sum can be taken at plate 9. If desired, a "reverse sum" can be taken at plate x.

The other plates generate ordinary binary functions:
Plate 1: activated when cart is deflected at door A - NOT A.
Plate 2: see above, logical AND
Plate 3: activated when cart is deflected at both A and B - NOR
Plate 5: activated when cart is deflected at A and B or when it passes A and B - equivalence (of dubious value)
Plate 6: activated when cart is deflected at A and passes B, or when it passes A and is deflected at B - XOR (obsolete)

To be able to do both addition and subtraction on the same circuit, the carry and borrow plates must respond to different cart weights (sum uses the same logic in both cases - Carry XOR (A XOR B). I think. ). The various binary logic functions _could_ be derived by having a bunch of "output buffers" that'd be enabled, depending on the desired function. But that'd be lame. We can sort all (or at least most of it) out just by setting up the proper pressure plate conditions and using the correct carts to run the circuit:

Example configuration:
Plate 1: 1-50
Plate 2: 100-350
Plate 3: 350-400
Plate 4: 450-600
Plate 5: 750-800
Plate 6: not installed
Plate 7: 300-350
Plate 8: 350-400
Plate 9: 250-500
Plate x: not installed

Carts used:
I - Wood (1-50): activates Plate 1 - NOT A 
II - Aluminium (100-150): activates Plate 2 - AND
IV - Iron (300-350): activates Plates 2, 7, 9 - positive carries and sum - ADD
V - Copper (350-400): activates Plate 3, 8, 9 - subtractive borrows and sum - SUBtract
VI - Silver (400-450): activates Plate 9 - sum without carries - XOR
VII - Lead (450-500): activates Plates 4 and 9 - NOR and XOR - NAND
VIII - Electrum (550-600): activates Plate 4 - NOR
IX - Gold (750-800): activates Plate 5 - EQUivalence

If a non-sum XOR plate is also installed, a cart III triggering both the AND and XOR can be used to derive OR. I had at first put the OR function in the list, but my proposed setup doesn't use a separate XOR plate and instead takes XOR from the sum plate: a triggered AND changes the sum at the next bit, because it's used as carry, so this doesn't give logical-or as output. OR can also be derived through input configuration: compare two A-wired inputs (or B-wired, if you must) and use sum as output.

There's still room for platinum (850-900), but i couldn't come up with a function for it.

Eight functions for the ALU would mean ALU operations could be cleanly encoded in three bits.

The big attraction to me is that this design really only has the two doors linked to input. Every additional source of input would need to be wired to one of the doors per bit, that's it. You could link a whole bank of registers right into the ALU without the need to go through a bus. I haven't tested the full thing, but the pure adder works very nicely, at ~10 steps per bit. This imposes a bit of a time cost, especially when eyeballing larger processor sizes, but should be manageable if you don't insist on building a 64-bit computer in DF (alright, it'd start to become notable around 15 and painful around 30 bits, but the two full DF computers i know worked on eight-bit (Jong's beast) and ten-bit (mine) data).

PS: i decided to come up with proper specs for a DF ALU after i read some question & answers stuff about real-computer ALUs somewhere and slapped together a 48-bit simulated one in Logisim for shits and giggles. It's a useful component and it's not _that_ difficult to implement in DF logics.
« Last Edit: February 21, 2015, 03:35:54 am by Larix »
Logged

Larix

  • Bay Watcher
    • View Profile
Re: Need for speed (dwarven computing)
« Reply #49 on: March 10, 2015, 11:15:00 am »

I considered using iterative algorithms for the generation of "random" numbers. As far as i can tell, that's actually common practice in software RNGs implemented in actual computers. An obvious simple method would be the fibonacci series, set to simply wrap around in a limited-size register (say, 20 bits or so). It appears to generate a fairly random-looking pattern when you let it run for long enough. However, there are clear reasons why the simple fibonacci isn't used for serious randomness generation:

1. bit-patterns to evaluate must be picked very carefully: in the basic fibonacci series, two out of three numbers have the lowest bit set, in a completely regular pattern.
2. cycle length depends on lowest set bit (when calculating it in binary) - when starting with only even numbers, all results in the cycle will be even, and the cycle will be shorter. The longest possible cycles in a 4-bit generator are 24 long, with 8 bits, it's 384 etc. (3/2 the amount of numbers expressable with the given number of bits).
3. there are very irregular result patterns possible: if you  generate 4-bit patterns and look at set/unset bits in the results, you get eight different 24-number cycles; the lowest bit will be set 16 times vs. clear 8 times, in all cases. The highest bit is either 14-10 or 10-14, the second highest is distributed 12-12 in four cases, 8-16 twice and 16-8 twice.
4. With simple evaluations, conspicuously long series of set or clear bits occur, much longer than would be expected in actual random distributions.

All this can presumably be ironed out enough to make decent pseudo-RNGs; and the Fibonacci series is trivially easy to generate iteratively.

What really struck me was that this casts my findings with the water-split RNG (look into the spoiler) in a very interesting light: the very long runs of identical results bear a suspicious similarity with Fibonacci-generated pseudo-randomness. It may be that water movement and job acquisition (numbers were generated by lever-pull) run on completely regular clocks with little or no use of the in-game randomiser, making the output a function that's too controllable or regular to be properly random. I may be completely wrong, of course - the statistical basis is beyond slim - but i feel justified in being doubtful. I'd recommend building a feedback shift register for evenly-distributed randomness.

PS: in other news, i don't think i'll really build an expanded dwarven computer. I pushed some ideas around, and there's certainly a lot possible, but since there seems to be no interest in the community to actually use such a thing, it'd be an absurd amount of work (~100 000 mechanisms, easily half a year or more real-time) for a mere conversation piece. My kilobit machine with the six-bit instructions serves that purpose just fine.
« Last Edit: March 10, 2015, 11:50:54 am by Larix »
Logged

gchristopher

  • Bay Watcher
    • View Profile
Re: Need for speed (dwarven computing)
« Reply #50 on: March 30, 2015, 06:17:48 pm »

Yeah, this is an esoteric-enough topic that I think having gone as far as you did is more than enough to claim success. Anything beyond that would have to be primarily to further satisfy the strange mood that pushed you here in the first place.
Logged

Larix

  • Bay Watcher
    • View Profile
Re: Need for speed (dwarven computing)
« Reply #51 on: June 13, 2015, 01:16:51 pm »

A better minecart-trap ring counter

Ring counters have many potential uses in dwarven engineering. Basically, they allow turning a uniform series of inputs (e.g. daily pulses from a clock/calendar) into a sequence of outputs (e.g. weekday displays). I mainly became interested in them because i found them the easiest way to regulate programme flow in dwarven computers.

I wasn't entirely happy with the ring counters i used in the Maple 6/6 and in the Mark Lumberjack: they need power to operate and require one roller per counting position, potentially even more machinery for regulation (to avoid moving multiple positions per input pulse). I had designed a powerless ring counter, but the first of those took even more machinery. But what about bridges?

A bridge blocking the exit of a double-ramp pit can be retracted to provide an exit. And it can be made ten tiles wide, blocking the exits of up to _ten_ pits set up side by side. Thus, to regulate a ten-position ring counter, it should be possible to make do with a single bridge, built from three building blocks and needing only three mechanisms to regulate - one trigger building and two mechanisms for the linkage. It's a lot less compact, because limiting the advancement to one position per input pulse must be done by the natural cycle of the bridge(1), i.e. the cart needs a long enough advancement path that it takes over 100 steps for each position advancement. The main question was how to build the paths so the cart could actually advance through the ring. I could have gone with one-way branches and a bit of spaghetti pathing:



Only engraved the paths and did a simple unregulated testing run. The cart advances from left to right and returns to the start from position ten.

But i decided to go with more ramp bugs instead:



Cart advances from left to right, and this contraption was built and successfully tested.

How the hell does this even work?

Propulsion and input processing should be clear enough: there are ten double-ramp pits in the north (each contains two NS ramps), where the southern ramps are covered by the northern ten-wide bridge. The cart bounces back and forth in its current pit until the bridge opens. Once the bridge retracts, the cart emerges and travels south.

The cart travels over one tile of plain track, then a vehicle-triggered pressure plate (on track). That's to allow sending cycles to long-reaction buildings (bridges, grates, floodgates or bars). The cart spends only a single step on the tile directly outside the pit due to the checkpoint effect, a pressure plate there will only send a 100-step signal cycle which _toggles_ long-reaction buildings (you can of course put your pressure plates there if you want a toggle; shorter-reaction buildings like doors and gear assemblies will not toggle but cycle normally).

It then travels through a one-wide pit with NS track. Since the ramp has no "down" connection, it doesn't change the cart's speed.

It encounters an additonal bridge, but that's just a one-wide raising bridge which can be used to bring the cart to a halt if desired for maintenance or the like.

After that, the cart travels the length of the array until it comes to one of two possible setups:

Code: [Select]
io     io
║║     ║║
║▼     ▼║
║▼     ▼║
║║     ║║
║+     +║
▼▼     ▼▼
╚╝     ╝╚
       ║║
       ╚╝

a      b


Cart enters from "in" direction, goes around the loop, leaves in "out" direction

a - "short" return: the cart goes over flat track right to the single-long ramp pit in the very south, passes through it (without changing speed) rounds the track loop just south of it and returns through the pit one position to the east, then through a double-ramp pit picking up speed on the return trip

b - "long" return: the cart goes through a double-ramp pit, picking up additional speed. Before it encounters the single-long pit, it passes over a tile of normal floor (can be rough, smooth or engraved but must not be track or bridge). Instead of entering the pit, the cart jumps. Thanks to the additional speed, it manages to clear both the pit and the corner directly behind it. In fact, it's fast enough that it even jumps past the straight track tile two south of the pit, a corner track there has no effect. The cart only "lands" on the third tile past the pit, rounds the corner there and once again returns one tile further east.

On the way back to the bridge, the cart now has to pass the next pressure plate and you might want to avoid triggering it. That's what the one-long ramp pits just south of the pressure plates and the ordinary floor just south of them are for: on the way south, the carts just pass normally through the pit, since they come from normal track (must be so, or the pressure plates wouldn't trigger). On the way north, the carts come from non-track floor and jump past both the pit and the pressure plate, failing to trigger it.

The concept for the whole thing was pretty clear to me from the start. Getting speeds and paths right was pretty hit-and-miss, though. The extra acceleration is required to ensure proper jump lengths on both ends, but it turned out that it also lengthened the jump on the southern branch enough to require expanding the catch-return loops by one tile. The counting ring is closed - the cart returns from position ten to position one - but you could of course assemble ten of these full arrays and make a hundred-step ring, you can let it end after the last position and you can include extra machinery to extract the cart and direct it to an arbitrarily-chosen specific position ("programme jump").

The whole thing needs proper "pulse" inputs to ensure minimum opening time for the bridge - the cart takes barely over 100 steps to advance one position. You can't directly operate the bridge by lever, because dwarven pulls are going to be too irregular. You need some intermediate logic to create short signal cycles, either by an "edge detector" design or other "pulse generator" (can be as simple as a cart pushed or guided over a pressure plate "always, after one day"). Maximum advancement speed is one position per 200 steps, there's a 3-21 step latency from the moment the bridge opens to the moment the pressure plate is triggered.

Footnote (1): a shorter path would require holding the cart back from reaching its waiting position after advancement until the bridge reset. That'd require either extra buildings (not fitting the objective of minimal building and mechanism requirement) or even fiddlier bug-based constructions (and in fact i wouldn't know how to do this with a bridge servicing ten positions).
« Last Edit: June 13, 2015, 02:11:26 pm by Larix »
Logged

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Need for speed (dwarven computing)
« Reply #52 on: June 13, 2015, 06:42:38 pm »

Hey, I'm getting better.  I actually understood all that in one go.  (At least, understood the explanation, not just from seeing that second one why it was shaped that way...)

I haven't gone back to read this whole thing with a clear mind, but I take it the ring counter doesn't have to produce a result in a consistent time frame, then? (It apparently just has to outwait the bridge cooldown timer...)

Also, if you want 100 steps, and you have a self-resetting count, couldn't you just stack up multiple "digits" of these ten-step ring counters whose "upper digits" have bridges that depend upon a pressure plate on the tenth ring return?  (That is, the first is the "one's digit track", and upon return to the 0 track, it opens up the bridge in the "ten's digit track", which advances a single ring.) 

(It may require a lot of additional boolean ands to get digits to be correctly read, however...)

(Perhaps if the ring counter were 16 slots, and you worked it with a binary memory counter...)
« Last Edit: June 13, 2015, 06:44:11 pm by NW_Kohaku »
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

Larix

  • Bay Watcher
    • View Profile
Re: Need for speed (dwarven computing)
« Reply #53 on: June 14, 2015, 06:11:09 am »

The ring counter as built sends one signal cycle 103-120 steps after it has received an input signal. This reaction delay is consistent. When shooting for optimal speed, you'd want to send your trigger signal ~100 steps before you want to receive the output.

The cart doesn't need to finish its advancement round in a specific time. The only restriction is that it has to take over 100 steps to return, so the bridge has time to reset. The bridge has 100-step reaction times between all state changes, so it can only open every ~200 steps. Even when operating it at maximum cycling frequency, any cart return time between 101 and 180 steps (it has to take into account variance in reaction latency) is just fine.

There are many ways ring counters can be used - "stacking" them is certainly an option. The higher-level rings would have longer reaction delays, but they'd only occur once every time the "root" cycle wraps around, which shouldn't be a huge concern with a ten-position counter as base. The required "decoding" wouldn't be particularly expensive in either mechanical or minecart logic.

The thing that makes ring counters so interesting to me is that they don't need to relate in any way to a memory architecture - there's no need to keep track of "position" in memory when all you want is that a sequence of operations is carried out in proper order. Imagine a fully sequenced obsidian trap: close capture bridges - dump victims to lower chamber - start magma pumps in lower chamber - start water pumps in upper chamber - cut water pumps - shut off magma pumps - drop water on top of magma - open access doors so miners can dig out the obsidian. Those are eight actions; pumps on different levels can normally run at the same time, so it's just six steps. A six-step counter "clocked" by some regular repeater should be just fine to run the whole deal (switch off the repeater as part of the last sequence step). You don't really need any precise position control for this, since you don't really want to skip parts of the sequence: opening miner access without shutting off the magma pumps might not be such a great idea. (NB - you can make magma traps without a regular counter, as well, and that tends to be even more efficient - just trigger each step directly by sensing plates.)
Logged

taptap

  • Bay Watcher
    • View Profile
Re: Need for speed (dwarven computing)
« Reply #54 on: June 14, 2015, 08:14:08 am »

There are many ways ring counters can be used - "stacking" them is certainly an option. The higher-level rings would have longer reaction delays, but they'd only occur once every time the "root" cycle wraps around, which shouldn't be a huge concern with a ten-position counter as base. The required "decoding" wouldn't be particularly expensive in either mechanical or minecart logic.

The thing that makes ring counters so interesting to me is that they don't need to relate in any way to a memory architecture - there's no need to keep track of "position" in memory when all you want is that a sequence of operations is carried out in proper order. Imagine a fully sequenced obsidian trap: close capture bridges - dump victims to lower chamber - start magma pumps in lower chamber - start water pumps in upper chamber - cut water pumps - shut off magma pumps - drop water on top of magma - open access doors so miners can dig out the obsidian. Those are eight actions; pumps on different levels can normally run at the same time, so it's just six steps. A six-step counter "clocked" by some regular repeater should be just fine to run the whole deal (switch off the repeater as part of the last sequence step). You don't really need any precise position control for this, since you don't really want to skip parts of the sequence: opening miner access without shutting off the magma pumps might not be such a great idea. (NB - you can make magma traps without a regular counter, as well, and that tends to be even more efficient - just trigger each step directly by sensing plates.)

Indeed, instant appeal to me. Visiting my old obsidian factory I noticed that I have the "controlling logic / sequencing" all over the place in the wiring so to say, requiring complicated refitting during changes/maintenance, if sequencing is controlled by such a ring counter I could sequence everything neatly and still understand what everything does months later, which isn't so easy with the multiple connections I ended up with in my old design, and have easy access for changes (unlike fluid logic).

The separation of working and sequencing elements should be an obvious design choice, yet so hard to us dwarves. So many clock designs attach repeaters to each other instead of using a single clock signal and proper counting.

taptap

  • Bay Watcher
    • View Profile
Re: Need for speed (dwarven computing)
« Reply #55 on: June 30, 2015, 06:34:58 am »

A better minecart-trap ring counter

Ring counters have many potential uses in dwarven engineering. Basically, they allow turning a uniform series of inputs (e.g. daily pulses from a clock/calendar) into a sequence of outputs (e.g. weekday displays). I mainly became interested in them because i found them the easiest way to regulate programme flow in dwarven computers.

But i decided to go with more ramp bugs instead:




This beauty could be fitted with another bridge (over a double pit entrance, exit or jumping point) that would allow to both increment as usual or only read out the state of the counter depending on the state of that bridge. (Or with a different, multi-z-level-setup make it switch between incrementing and decrementing.) Not sure whether or for what purpose this could be useful... My thinking is too much tied to applications.
Pages: 1 2 3 [4]