---
# System prepended metadata

title: Idea to reduce the reset rate of transceiver
tags: [TechReport, DeWei]

---

# Idea to reduce the reset rate of transceiver

## 1. Background

### 1.1 Transceiver has 2 state

* Initialization
* Normal run time

### 1.2 Our problems present

* Initialization
  * too long
* Normal run time
  * Go to init. state when a error occured

Thus,

we need a **strategy** to handle when **error occured**

### 1.3 Summery

* Cost(time) is very high when error occured.
* *error occured* is a binary problem (0 or 1, Toss a coin)
* I have a strategy which inspired by *Saturating counter*

## 2. Saturating counter of branch predictor

### 2.1 Branch 

One of branch :

![image alt](https://i.imgur.com/MI7ewED.png)

There are many branch in our code we've written.

#### please note:

`if/else` and `conditon of while/for loop` 
can be expression as **Binary branch** in low level of machine finally (asm-lang)

### 2.2 (Binary) Branch predictor


Many CS/EE student could listen branch predictor in the course *CPU Architecture* .

:::info
To improve efficiency of CPU, 
we predict which branch will appear,
and **pre-execute** this branch,
finally save result into pipleline for executing.
:::


So, 

how many probability about correct prediction in Branch predictor(Saturating counter)?

[This Paper](https://dl.acm.org/doi/10.1145/123465.123475) mentioned

![](https://i.imgur.com/rlNhJTN.png)

and this algorithm applied in Intel Pentium CPU in 1993

Whattttttttttttttttttttttttttt?

Worst 80%, best 99.4%.

Considering there is a *Toss problem*, 

minimum probility of correct prediction should > 50%

in the same paper, 

also shows probility without branch predictor

![](https://i.imgur.com/kHYRTqH.png)

Note
::: warning
Thinking what happens if prediction is incorrect?
:::

### 2.3 Saturating counter

![](https://i.imgur.com/LyfAcgU.png)

白話文:
```
錯一次給你機會，錯到第n+1次之後才轉態
```

#### High probability could correctly predict

```
While (!stuff)
  ...
...
While (!stuff)
  ...
...
While (!stuff)
  ...
...

# stuff and !stuff almost does not change 
```

#### Low probability could correctly predict

```
While (stuff)
  ...
...
While (!stuff)
  ...
...
While (!stuff)
  ...
...
While (!stuff)
  ...
...

# stuff and !stuff change very random
```
:::info
Thank to we spent a lot of commands(time) to execute 
```
While (stuff)
  ...
```
in almost of programs.

*Saturating counter* always has high probability to predict correctly
:::

## 3. My strategy for reduce the reset rate of transceiver

* Error occured is very low probility when run-time

* Last chapter case:
```
While (stuff)
  ...
```
is similar to

```
While (error)
  ...
```

## 4. n-bis Saturating counter

```graphviz
digraph hierarchy {

}
```

## Reference

[1]  [CPU 的分支預測器是怎樣工作的？](https://www.zhihu.com/question/23973128)


###### tags: `TechReport` `DeWei`