Alpha Branch/Word width

From Turing Complete
Revision as of 11:02, 19 February 2025 by Altrag (talk | contribs)

Turing Complete allows for components and wires of any size from 1 through 64 bits, primarily for the sake of convenience (eg: placing a single 64-bit word AND rather than 64 individual 1-bit AND gates). Not exclusively however - some word components (such as DIV or LESS) do not have a corresponding 1-bit equivalent.

In prior iterations of the game, there were individual components with fixed 1, 8, 16, 32 or 64 bit widths. In the modern version however, all but the 1-bit components have been combined into a single set of "word" components with configurable widths:

File:Word Component AND.png

The little bubble on the top left corner (in default orientation) is the component bit width - 8 in the AND example image. Clicking on that bubble brings up the width editor:

File:Bit width editor.png

Most components accept values between 2 and 64 (inclusive). The corresponding bit components are required for 1-bit "words".

Width Inference

Many components also accept the value x. This value tells the component to chose its width based on the width of the values on its input wires. For example:

File:Bit width inference

In this example, NOT is explicitly set to 13 bits, while the switch after it is set to x and infers the width from the NOT. The width bubble on the switch has a darker background to indicate that it is being inferred.

Bit width inference is especially useful when creating custom components, as the Input Pin is one of the components that allows x width. For example, if we wanted the opposite of a MUX (demultiplexer or DEMUX), we could build a custom component similar to the following:

File:Bit width demux

Static Values

There are several components in the game dedicated to working with bit widths rather than data. The values these components produce and utilize are compiled into the circuit and function as constant values during circuit operation. They are once again primarily for the sake of convenience. The simplest of these is the Static Indexer||alpha. Along with a width bubble (allowing you to narrow or widen wire widths when needed), it can also perform a constant shift by setting it's Shift value, a task that would previously have taken a splitter and a maker (or many splitters and makers if you were working with larger bit widths).

The Static Value||alpha component is unique in that, when included in a custom component, it adds a width bubble to your custom component that can be set externally. You can then use that value with the static value components to create extremely flexible and reusable custom components.

Blue pins and wires

Retrieving the value from the Static Value||alpha leads us to the next concept: Blue pins (also known as "size pins"). A wire connected to a blue pin will also turn a similar shade of blue. Such wires can only connect to other blue pins. Additionally, if you connect two blue wires with different values, you will not get a wire conflict as you do with normal wires. Instead, the game will take the maximum of any values attached to the wire.