|
12 | 12 | // See the License for the specific language governing permissions and
|
13 | 13 | // limitations under the License.
|
14 | 14 |
|
15 |
| -// This file implements a parametric RLE encoder |
| 15 | +// This file implements a parametric multisymbol RLE encoder |
16 | 16 | //
|
17 | 17 | // The encoder uses Run Length Encoding (RLE) to compress the input stream of
|
18 | 18 | // repeating symbols to the output stream that contains the symbols and
|
19 |
| -// the number of its consequect occurrences in the input stream. |
| 19 | +// the number of its consecutive occurrences in the input stream. |
20 | 20 | // Both the input and the output channels use additional `last` flag
|
21 | 21 | // that indicates whether the packet ends the transmission. After sending
|
22 | 22 | // the last packet encoder dumps all the data to the output stream.
|
23 | 23 | // The behavior of the encoder is presented on the waveform below:
|
24 |
| -// ──────╥─────╥─────╥─────╥─────╥─────╥─────╥─────╥──── |
25 |
| -// next evaluation XXXXXX║ 0 ║ 1 ║ 2 ║ 3 ║ 4 ║ 5 ║ 6 ║ ... |
26 |
| -// ──────╨─────╨─────╨─────╨─────╨─────╨─────╨─────╨──── |
27 |
| -// ──────╥───────────╥─────╥─────╥─────╥─────╥────────── |
28 |
| -// symbol XXXXXX║ A ║ B ║XXXXX║ B ║ C ║XXXXXXXXXX |
29 |
| -// (input channel) ──────╨───────────╨─────╨─────╨─────╨─────╨────────── |
30 |
| -// last ┌─────┐ ┌─────┐ |
31 |
| -// (input channel) ──────────────────┘ └───────────┘ └────────── |
32 |
| -// ╥─────╥─────╥─────╥─────╥─────╥─────╥─────╥────────── |
33 |
| -// state.prev_symbol ║ 0 ║ A ║ A ║ B ║ 0 ║ B ║ C ║ 0 |
34 |
| -// (set state value) ╨─────╨─────╨─────╨─────╨─────╨─────╨─────╨────────── |
35 |
| -// ╥─────╥─────╥─────╥─────╥─────╥─────╥─────╥────────── |
36 |
| -// state.prev_count ║ 0 ║ 1 ║ 2 ║ 1 ║ 0 ║ 1 ║ 1 ║ 0 |
37 |
| -// (set state value) ╨─────╨─────╨─────╨─────╨─────╨─────╨─────╨────────── |
38 |
| -// |
39 |
| -// do_send ┌───────────┐ ┌───────────┐ |
40 |
| -// ──────────────────┘ └─────┘ └──── |
41 |
| -// ──────────────────╥─────╥─────╥─────╥─────╥─────╥──── |
42 |
| -// symbol, count XXXXXXXXXXXXXXXXXX║ A,2 ║ B,1 ║XXXXX║ B,1 ║ C,1 ║XXXX |
43 |
| -// (output channel) ──────────────────╨─────╨─────╨─────╨─────╨─────╨──── |
44 |
| -// last ┌─────┐ ┌─────┐ |
45 |
| -// (output channel) ────────────────────────┘ └───────────┘ └──── |
| 24 | + |
| 25 | +// This encoder is implemented as a net of 4 processes. |
| 26 | +// 1. Reduce stage - this process takes incoming symbols and symbol_valid |
| 27 | +// and reduces them into symbol count pairs. This stage is stateless. |
| 28 | +// 2. Realign stage - this process moves pairs emitted from previous stage |
| 29 | +// so that they are align to the left, it also calculates propagation distance |
| 30 | +// for the first pair. |
| 31 | +// 3. Core stage - this stage is stateful. It takes align pairs, |
| 32 | +// and combines them with its state.It outputs multiple symbol/count pairs. |
| 33 | +// 4 - Adjust Width stage - this stage takes output from the core stage. |
| 34 | +// If output can handle more or equal number of pairs as |
| 35 | +// input number of symbols. This stage does nothing. |
| 36 | +// If the output is narrower than the input, |
| 37 | +// this stage will serialize symbol counter pairs. |
| 38 | + |
46 | 39 |
|
47 | 40 | import std
|
48 | 41 | import xls.modules.rle.rle_common as rle_common
|
|
0 commit comments