Hints and kinks for USB decoding
Bert Erickson, Fayetteville, NY - February 7, 2002
The USB is a serial data-transmission system that uses cables to connect peripheral equipment to PCs. All new computers have two or more USB receptacles, and the predictions are that they will replace most of the legacy receptacles on older PCs. The 1.0 and 1.1 standards for USB were for 1.5 and 12 Mbps at low- and full-speed rates, respectively. These standards targeted low- and medium-speed peripherals. The latest 2.0 standard is for a 480-Mbps rate that will accommodate many high-speed devices along with the previous low- and full-speed rates. At the PC-accessible USB receptacle and at the peripheral, if it has a receptacle, the signal has the format of differential-NRZI (nonreturn-to-zero-inverted) code. After conversion (with a simple circuit or test probes) of this differential to single-ended signal, the signal becomes a waveform that assumes the voltage levels used to recognize ones and zeros in computer code.
In this NRZI waveform, a transition between the d(n–1) and d(n) bits decodes to a binary b(n)=0 data bit. No transition decodes to a binary b(n)=1 bit. However, when you display the d(n) waveform on an oscilloscope of a logic analyzer, it is difficult for an observer to decode it back to the originating binary waveform, or vice versa. In this situation, you may doubt your judgment and turn to dedicated test equipment to make the conversion. Much of the human problem occurs because NRZI decoding depends on knowledge of the previous and current input bits to determine a value for the current output bit. In the encoding descriptions in most textbooks and technical articles, the transitions receive passing mention, and the material presents a pair of waveforms with little or no elaboration. The following suggestions involve some computer statements and logic circuits that provide a different way to effect the conversion.
Table 1 shows all the combinations that can exist in NRZI encoding. For the differential-NRZI-d(n)-to-binary-b(n) code conversion, the following observations apply:
The conversion is independent of b(n–1).
If d(n–1)≠d(n), then b(n)=0.
If d(n–1)=d(n), then b(n)=1.
Or, simply, b(n)=d(n) XOR NOT d(n–1).
You can perform the conversion by using an XOR gate and a 74LS74 D-type, positive-edge-triggered flip-flop (Figure 1a). The flip-flop's Set and Clear terminals connect to VCC, and you do not need to reset either one. For the binary b(n) to differential NRZI d(n) conversion, we offer the following observations:
The conversion is not independent of d(n–1).
b(n–1)=0 AND b(n)=0, then d(n)=NOT d(n–1), or
b(n–1)=1 AND b(n)=0, then d(n)=NOT d(n–1).
You can perform the conversion by using an XOR gate and a 74LS74 D-type positive-edge-triggered flip-flop (Figure 1b). The flip-flop's Set and Clear terminals connect to VCCafter you use them to set d(n) to its proper initial value. For all input-data sequences that keep repeating, you must select the last and first bits to produce the first output bit. Click here to download a computer program that confirms the decoding.
Is this the best Design Idea in this issue? Select at www.ednmag.com.