Modified Frequency Modulation - Coding

Coding

As is standard when discussing hard drive encoding schemes, FM and MFM encodings produce a bit stream which is NRZI encoded when written to disk. A 1 bit represents a magnetic transition, and a 0 bit no transition. Data encoding has to balance two factors:

  • there are limits on the minimum and maximum number of 0 bits that the hardware can detect between consecutive 1 bits, and the encoding must not exceed this limit;
  • there are limits on the maximum number of 1 bits that the hardware can detect in a given amount of time. If a disk is encoded with a higher (average) number of magnetic transitions per bit, the bits will have to be "wider" and fewer sectors will fit each track;

Both FM and MFM encodings can also be thought of as having data bits separated by clock bits, but with different rules for encoding the bits. Still, both formats encode each data bit as two bits on disk (because of delimiters that are required at the beginning and end of a sequence, the actual density is slightly lower).

The basic encoding rule for FM is that all clock bits are 1: zeros are encoded as 10, ones are encoded as 11. The number of magnetic transitions per bit is on average 1.5 (50%*1 + 50%*2).

The basic encoding rule for MFM is that (x, y, z, ...) encodes to (x, x NOR y, y, y NOR z, z, z NOR...). A zero is encoded as 10 if preceded by a zero, and 00 if preceded by a one (each of these cases occurs 25% of the time); a one is always encoded as 01 (which happens 50% of the time); thus the number of magnetic transitions is on average 0.75 (25%*1 + 25%*0 + 50%*1).

Data ... 0 0 ... ... 0 1 ... ... 1 0 ... ... 1 1 ...
MFM clock bits ...? 1 ?... ...? 0 0... ...0 0 ?... ...0 0 0...
MFM encoding ...?010?... ...?0010... ...0100?... ...01010...

Note that the surrounding clock bits are sometimes known, but sometimes require knowledge of the adjacent data bits. A longer example:

Data: 0 0 0 1 1 0 1 1 ... FM encoded: 10101011111011111... MFM clock: ? 1 1 0 0 0 0 0 0... MFM encoded: ?0101001010001010...

(The bold bits are the data bits, the others are the clock bits.)

In FM encoding, the number of 0 bits that may appear between consecutive 1 bits is either 0 or 1. In MFM encoding there is a minimum of 1 zero bit between adjacent ones (there are never two adjacent one bits), and the maximum number of zeros in a row is 3. Thus, FM is a (0,1) RLL code, while MFM is a (1,3) code.

A special “sync mark” is used to allow the disk controller to figure out where the data starts. This sync mark must follow the RLL code so that the controller can recognize it, but it does not follow the FM and MFM rules for clock bits. This way, it will never occur in any bit position in any encoded data stream. The shortest possible sync bit pattern, which follows the (1,3) RLL coding rules but cannot be produced by normal MFM coding, is 100010010001. In fact, the sync mark that is commonly used in MFM encoding starts with these twelve bits; it is called an “A1 sync” since the data bits form the hexadecimal value A1 (10100001), but the fifth clock bit is different from the normal encoding of the A1 byte.

Data: 1 0 1 0 0 0 0 1 Clock: 0 0 0 1 1 1 0 Encoded: 100010010101001 Sync clock: 0 0 0 1 0 1 0 Sync Mark: 100010010001001 ^ Missing clock bit

Read more about this topic:  Modified Frequency Modulation