can you determine the distinct variable bit packets from within this bitstream?

68 Views Asked by At

11001101111011000011000111001011010011010111011011100011100111101011 the above bit stream should break up into these variable bit packets 11 0011 0111 1011 000011 000111 001011 010011 010111 011011 100011 100111 101011 basically it is a base 3 number represented in base 2 as 2 bits base 2 number of variable length, with a 11 as a stop pattern, as long as you are looking at this 2 bits at a time, can you determine the second list of values from the bit stream I gave at the top part?

1

There are 1 best solutions below

10
On

If you're allowed to remember some state between the processing steps, then yes.

Just do the following, assuming that the state bit is $s$ and the current input bits are $b_0$, $b_1$

  1. Append $b_0$ to the output
  2. If $s \land b_0$
    1. Append space to the output
  3. Append $b_1$ to the output
  4. If $\lnot s \land b_0 \land b_1$
    1. Append space to the output
    2. Set $s \leftarrow 0$
  5. Otherwise
    1. Set $s \leftarrow b_1$

Thus, $s = 1$ if the last bist of the previous 2-bit chunk might be the first (but not the second!) bit of a stop pattern. By comparing $s$ and $b_0$, stop pattern which are split between two such chunks are detected and handled appropriately. By comparing $b_0$ and $b_1$, stop patterns within a chunk are detected, and the additional check for $s=0$ ensures that $0111$ isn't decoded to "011 1 " but rather to "011 1". Setting $s$ to $0$ in 4.2 prevents "1110" from being decoded to "11 1 0".

Here's an example. Say the input is $$ 011110001110100110 \text{.} $$ The processing then does this $$ \begin{array}{cc|ll|ll|ll|ll|ll|ll|ll|ll|ll} b_0 &b_1 & 0&1 & 1&1 & 1&0 & 0&0 & 1&1 & 1&0 & 1&0 & 0&1 & 1&0 \\ s_{\textrm{in}} &s_{\textrm{out}} & 0&1 & 1&1 & 1&0 & 0&0 & 0&0 & 0&0 & 0&0 & 0&1 & 1&0 \\ \hline && 0&1 & 1.&1& 1.&0& 0&0 & 1&1.& 1&0 & 1&0 & 0&1 & 1.&0 \end{array} $$ where the last line is the output, and dots represent spaces.

Notation-wise, $\lnot$ means logical not, i.e. $\lnot x$ is true if $x=0$, and $\land$ means logical and, i.e. $x \land y$ is true if $x=1$ and $y=1$. Logical or (which isn't used here) would be written as $x \lor y$ and would be true if $x=1$ or $y=1$.