dual rail logic

In the last tutorial, we encountered a problem with representing 1 as marble and 0 as hole — if we want to transform 0 into marble, we have to source a marble from somewhere. This can make our circuits messy.

revisiting representations

How did we end up here, anyway?

Ages ago, we chose to label marble with 1s and hole with 0s:

00/0000/00
loading…

1s and 0s

This was our reasoning:

  • treats all marbles identically
  • So we have to write the same value (1) on each marble
  • Because we need 2 values, the only other place to write 0 is on each hole

It turns out this isn’t actually true. doesn’t treat all marbles identically. If it did, none of our patterns would work in the first place.

Consider this pattern:

00/0000/00
loading…

distributor pedantry

Did the distributor distributor treat A and B identically?

Put on your pedantry hats. A and B are not identical, because they are in different places.

This means we can trick the universe into encoding data in the positions of the marbles.

00/0000/00
loading…

lateral encoding

In circuit design, this is known as dual-rail logic. Instead of a single wire (“rail”) carrying a signal, the wires are paired up. Exactly one of them carries a signal; and it’s the choice of wire that determines whether the value is a 1 or a 0.

Applying this to : for each pair of paths paths above, we always have exactly one marble and one hole, and it’s the position of the marble that determines whether we have a 1 or a 0.

By contrast, our previous approach is called single-rail logic, as the bitstream is carried on a single “rail” (i.e. sequence of paths).

For short, let’s call these R1 (single-rail) and R2 (dual-rail).

definition

single-rail logic (R1) means 0 = hole and 1 = marble.
dual-rail logic (R2) means 0 = l and 1 = r

note

We originally called these lateral encoding and presence encoding, as we didn’t know there were existing terms for them! You might still see these old phrases around the website.

We’re exploiting the arbitrariness of representations yet again — there was nothing special about our original scheme, so it’s perfectly fine to create another one when it’s convenient.

why dual rail logic?

R2 has some nice features. The main one is that it gives us a consistent marble supply — whether we get l or r, we always receive 1 marble and 1 hole.

This is very convenient for building a NOT gate:

00/0000/00
loading…

not gate le

This makes sense — we’re representing our data as l and r, and a crossing crossing swaps l and r. Under R2 our NOT gate doesn’t need a reservoir; it’s just a single common .

So why don’t we use R2 for everything? In the next tutorial we’ll look at the tradeoffs.

continue