# HDB3

`三阶高密度双极性码`是一种适用于基带传输的编码方式，应用于电信领域。它是为了克服AMI码的缺点而出现的，具有能量分散，抗破坏性强等特点。

HDB3码基于AMI码。

## AMI (Alternative Mark Inversion)

编码原则： `1`与`-1`交替出现

source: 1 0 1 1 0 1

encoded: 1 0 -1 1 0 -1

## HDB3编码流程

1. 碰到`0000`，替换为`B00V`
2. 第一个 `B` 为 `0`，第一个`1`为`-1`
3. `B`与前面`非零数的极性`相反（比如前面为`1`或`V`，后面应为`-B`）； `V`与你刚刚(之前)判断的`B的正负性`一致（比如前面为`-B`，后面应为`-V`）(如果前面的`B=0`，`V`与之前最近的一个`1` `正负性一致`)
4. 在重复`3`步骤的过程中，如果遇到其他的`1 or -1`，要严格按照`AWI`原则，再次做交替变化
5. B = 1 , -B = -1 , V = 1 , -V = -1

![](/files/-Lf5hgoyrSkFjttecqUW)

## 例题

1010000000011000011

to

101B00VB00V11B00V11

to

-101000VB00V11B00V11

to

-101000V-B00-V1-1B00V-11

to

-1010001-100-11-11001-11

## 手动解码

1. 如果`3个连零`前后`非零的数`极性相同，将`后一个非零数`变为0
2. 如果`2个连零`前后`非零数`极性相同，全都变为0


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yingshaoxo.gitbook.io/university-notes/principles-of-communications/hdb3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
