An Asynchronous Multiplexing system (CSMA/CD on a Factorio Wire!)
Posted: Mon Apr 01, 2019 10:19 am
I have designed a transmitter which is able to share a single circuit network with an arbitrary number of other transmitters of the same design. The transmitter is clockless (doesn't use time slots, opting instead to attempt immediate transmission and use collision detection and resolution). It sends complete signals (all channels from the input signal but a few reserved ones are sent).
The transmitters make use of Wube's high-tech circuit networks to omit a lot of checks that would otherwise be required to implement CSMA/CD (signals which are instantaneously transmitted, additive, perfectly synchronized, and absurdly parallel are *extremely* useful).
Symbols:
[local] I - Identifier - a Unique number assigned to each transmitter
[wire] I - sum of all active transmitter identifiers
C - Contend - Total number of transmitters currently in contention for the wire (used to lock out subsequent transmitters until all currently contending transmitters transmit)
T - Transmit - Number of transmitters currently transmitting (used for collision detection)
A - AverageID - Mathematical average of all active transmitter IDs from the preceding tick. (used to resolve collisions)
Transmitter IDs should be unique. Due to the use of integer math and not wanting to add extra combinators to compensate, all IDs should be set up in increments of at least 2.
Transmitter:
The transmitter expects a pulsed command to initiate transmission. It expects the signal to be a held value (it may also be continuously updated while the transmitter is working).
Conceptually, the transmitter is designed as something resembling a simple state machine.
Receiver
The receiver watches the network for valid transmissions (indicated by 'T=1') and converts it into a single-tick pulse.
Basically, somewhere on the network, you'll need an arithmetic combinator which computes I/T and outputs it to A. Here is a blueprint that does that:
This design is a major improvement over an earlier unpublished design, which used random backoff, was a lot more complex and less efficient, and didn't work.
Update: I have re-arranged the transmitter combinators to be semi-rotationally-symmetric and put together a blueprint book:
The transmitters make use of Wube's high-tech circuit networks to omit a lot of checks that would otherwise be required to implement CSMA/CD (signals which are instantaneously transmitted, additive, perfectly synchronized, and absurdly parallel are *extremely* useful).
Symbols:
[local] I - Identifier - a Unique number assigned to each transmitter
[wire] I - sum of all active transmitter identifiers
C - Contend - Total number of transmitters currently in contention for the wire (used to lock out subsequent transmitters until all currently contending transmitters transmit)
T - Transmit - Number of transmitters currently transmitting (used for collision detection)
A - AverageID - Mathematical average of all active transmitter IDs from the preceding tick. (used to resolve collisions)
Transmitter IDs should be unique. Due to the use of integer math and not wanting to add extra combinators to compensate, all IDs should be set up in increments of at least 2.
Transmitter:
The transmitter expects a pulsed command to initiate transmission. It expects the signal to be a held value (it may also be continuously updated while the transmitter is working).
Conceptually, the transmitter is designed as something resembling a simple state machine.
Code: Select all
IDLE: Wait for a "Send" command, then set state to "WAIT"
WAIT: Wait for C=0 then set state to "SEND"
SEND: Send [I C=1 T=1 SIGNAL]
Set state to "CHECK"
CHECK: Send [I C=1 T=1 SIGNAL]
If C=1 set state to "IDLE"
If I>=A and A>0 set state to "YIELD"
YIELD: Send [C=1]
If T=0 set state to "SEND"
Transmitter Blueprint
Note: The transmitter blueprint is set up to trigger from the "dot" signal (see the screenshot below)Receiver
The receiver watches the network for valid transmissions (indicated by 'T=1') and converts it into a single-tick pulse.
Receiver Blueprint
"Central" ControllerBasically, somewhere on the network, you'll need an arithmetic combinator which computes I/T and outputs it to A. Here is a blueprint that does that:
Central Controller Blueprint
The test build (with testing apparatus disconnected) is laid out like this:
This design has not been extensively tested or used in any practical setup, but since it did successfully resolve 8-way collisions, correctly handled inputs received with one tick difference, and has a pretty simple design, it probably will be alright to immediately and impulsively tear down your entire existing system use my design exclusively for dispatching ambulances and fending off invaders.This design is a major improvement over an earlier unpublished design, which used random backoff, was a lot more complex and less efficient, and didn't work.
Update: I have re-arranged the transmitter combinators to be semi-rotationally-symmetric and put together a blueprint book: