Close

4B4T: An extended ternary Manchester code and its implications

A project log for miniPHY

the thing you need to plug to a miniMAC

yann-guidon-ygdesYann Guidon / YGDES 06/04/2025 at 23:560 Comments

So the last log re-emphasised the importance of BaseLine Wander on the design of the AFE.

Modern designs have sophisticated hyper-fast ADCs and perform complex DSP to compensate for many line effects including droop and BLW. This is totally out of the realm of possibility, the miniPHY must be very simple.

On the other end of the spectrum, 10Mbps Ethernet uses Manchester code which is very inefficient: 2baud/bit, the bit value is followed by its inverse. However is has a wonderful property: there is no space for BLW, as each code is "neutral" by definition.

Hybrid_ternary_code has an intriguing and very simple encoding scheme with 1bit/baud. Not great, not bad, it's a baseline.

The 3B2T code (9 symbols) is pretty efficient (density/packing=1,5bit/baud) but the balance/neutrality is data dependent. Trying to preprocess the data to prevent unwanted patterns is hard, expensive, ... The hardware overhead is significant (it adds latency and bloats the circuit) and the packing density is still unclear: adding one bitrit worth of information (8 symbols) to 7 bitrits would reduce BLW to "a certain amount" but it's still too data-dependent and has insufficient effect/leverage. 1/7th overhead (14%) can not ensure DC balance in all cases.

4B3T has a slightly worse density (1.3b/baud) but can ensure DC balance, using a 3-bit running disparity counter, a reasonably-sized LUT and a pretty simple decoder. It links consecutive words/nibbles but it looks like it's the smallest such scheme, simpler than the 2-LUT 8b/10b system.

Some interesting analysis can be found at Block_Coding_with_4B3T_Codes

Let's say "it's interesting"...

...

But what if we don't want to link nibbles ? We end up with needing a scheme where all the codes are DC balanced, just like Manchester. HTC (see above) also has to link consecutive bits to work. In ternary, we can also get the equivalent of Manchester with a triplet of codes : +- / -+ / 00 But then the long runs of 0s must be prevented. So it's basically Manchester (2baud/bit), with S code.

Going to 3 trits, we get 6 non-null codes: +0- / -0+ / 0+- / 0-+ / +-0 / -+0 which amounts to 2,5b/3T. Not great.

Four trits gets interesting though : 9 non-zero invertible codes (18 total) gives something like 4B/4T:

00+-  +00-  +-00  /  00-+  -00+  -+00
0+0-  0+-0  +0-0  /  0-0+  0-+0  -0+0
++--  +--+  +-+-  /  --++  -++-  -+-+

This gives 16 data codes, 2 control codes and one "quite/silent/same" marker. This almost looks like something!

Packing-wise, it has 33% overhead compared to 4B3T so the data bandwidth drops by 25%. It is stateless though and the LUT is smaller.

But compared to HTC, the density is almost the same: 1b/baud ! The control codes are nice but not a significant bandwidth concern and HTC is way simpler.

I intend the miniPHY to have various (incompatible) versions so it is good to start with the simplest possible code. HTC does not have a "Same/Silence" code though that helps with the signalling and protocol so let's skip it.

So the development course would be :

  1. Start with 4B4T, simple/easy/low bandwidth which can be implemented in either 2send/2receive or 1send/3receive if bandwidth matters, and see how it works in practice.
  2. Increase the bandwidth usage with 4B3T, as a simple upgrade on the FPGA side
  3. Meanwhile, see if I can figure out a balancing scheme to retrofit into 3B2T with a smaller overhead than 4B3T.

This whole analysis has brought a lower bound of coding overhead to bring DC balance. Looking at 8B6T, it does not look like this packing ratio can be easily improved.

From there, if a line frequency of 30MHz can not be exceeded, and 1MHz=2baud,

  1. 4B4T will bring about 60Mbits per lane (hypothetically and unlikely, let's say 20Mbps)
  2. 4B3T increases to 75Mbps (ok let's say 25 or 30Mbps)
  3. 3B2T could reach 80 (25 to 33Mbps in good conditions)

The cool thing with a custom miniPHY is that the clock frequency could be adjusted according to the line's characteristics (length, capacitance...) and we could add lanes as needed...

Discussions