A list,

To understand the coding rules of HDB3 code, it is necessary to know the constitution rules of AMI code first. AMI code is to change the adjacent “1” codes (positive pulses) in the unipolar pulse sequence into positive and negative pulses with alternating polarity. Keep the “0” code unchanged, and change the “1” code into an alternate pulse represented by +1, -1 half-occupied space to zero code. Such as:

NRZ code: 100001000011000011 AMI code: -10000+1 0000-1 +1 0000-1 +1

HDB3 code is an improved form of AMI code, and its encoding principle can be summarized as follows: (1) When the number of consecutive “0” codes is not more than 3, HDB3 code is the same as AMI code, that is, “1” code becomes “+1” and “-1” alternating pulses; (2) When there are four consecutive “0” codes or more than four consecutive “0” codes in the code sequence, divide the consecutive “0” segment into four “0” sections, namely “0000”, and make the fourth “0” code into “1” code, which is represented by V pulse. This can eliminate the long “0” phenomenon. To facilitate the identification of the V pulse, the polarity of the V pulse is the same as that of the previous “1” pulse. In this way, the alternating polarity of AMI codes is broken, so the V pulse is the failure pulse, and the V pulse and the first three consecutive “0” are called the failure node “000V”. (3) In order to make the pulse train still does not contain dc component, it is necessary to make the polarity of the adjacent failure point V pulse alternate; (4) In order to ensure the first two conditions, there must be an odd number of “1” codes between adjacent failure points. If the “1” code between the failure points in the original sequence is even, it must be supplemented with an odd number, that is, the first “0” code in the failure section becomes “1”, which is represented by B pulse. At this point, the destruction node changes to the “B00V” form. The polarity of the B pulse is opposite to that of the previous “1” pulse, while the polarity of the B pulse is the same as that of the V pulse.

For example: NRZ code: 100001000011000011 AMI code: -10000+1 0000-1 +1 0000-1 +1 HDB3 code: -1000 -V +1 000 + V-1 +1 – B 00 -V +1 -1

Although the coding rules of HDB3 code are complicated, the decoding is relatively simple. From the above principle, it can be seen that each destruction symbol V is always homopolar with the previous non-zero symbol (including B). That is to say, the damage point V can be easily found from the received symbol sequence, so it is also determined that the V symbol and the three symbols before it must be a continuous zero symbol, so as to restore the four continuous zero code, and then change all -1 into +1 to get the original message code. HDB3, HDBn is pushed the same way. The main reason is that the length of the destruction section is different. Here I record a small concept of my own understanding: for example, both represent “1”, like this, the level stays constant during the whole symbol period is not returning to zero. Like this, the level changes during a symbol period, such as low first and then high, or high first and then low is zero

Ii. Source code

x=[1 0 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 0]; % Input source code y=x; Y initializes num=0; % counter initializedfor k=1:length(x)
   if x(k)==1
      num=num+1;                % "1"counterif num/2 == fix(num/2) % An odd number1When the output- 1, perform polarity alternation y(k)=1;
         else
              y(k)=- 1; End End end % HDB3 Num =0; % even zero counter initialization yh=y; % output initialization sign=0; % polarity flag is initialized to0
V=zeros(1,length(y)); % V Pulse position recording variable B=zeros(1,length(y)); % B pulse position record variablefor k=1:length(y)
   if y(k)==0
       num=num+1; % even"0Number countingif num==4% if4Even the"0Num ="0; % counter zero yh(k)=1*yh(k4 -); Let %0000The last one0Change to the symbol V(k)=yh(k) of the same polarity as the previous non-zero symbol; % V pulse position recordingif yh(k)==sign % If the current V symbol has the same polarity as the previous V symbol yh(k)=- 1*yh(k); % reverses the polarity of the current V symbols to meet the requirements of polarity reversal between V symbols yh(k- 3)=yh(k); % add B symbol, with V symbol polar B(k- 3)=yh(k); % B pulse position record V(k)=yh(k); The pulse position was recorded1:length(y))=- 1*yh(k+1:length(y)); End sign=yh(k); % Records the polarity end of the previous V symbolelse
      num=0; % The current input is"1"Even"0"Counter zero end end % encoding complete % re=[x',y',yh',V',B']; % result output: x AMI HDB3 V&B symbol % HDB3 decodeCopy the code

3. Operation results

Fourth, note

Version: 2014 a