diff --git a/coder.lua b/coder.lua index 682647e..79f7f51 100644 --- a/coder.lua +++ b/coder.lua @@ -9,7 +9,7 @@ function m2s(a, b) end end -function coder(input_code, verbose) +function coder(input_code) register = {0, 0, 0} result = {} states = {} @@ -17,9 +17,6 @@ function coder(input_code, verbose) for i, code_digit in ipairs(input_code) do register[#register+1] = code_digit state = register[#register-1]..register[#register-2] - if verbose then - print(i..'-ое состояние - '..state) - end states[#states + 1] = state result1 = m2s(m2s(register[#register], register[#register-1]), register[#register-2]) diff --git a/term_paper.pdf b/term_paper.pdf index 47dbde2..f1cf1b4 100644 Binary files a/term_paper.pdf and b/term_paper.pdf differ diff --git a/term_paper.tex b/term_paper.tex index 0e0e8c5..aec43da 100644 --- a/term_paper.tex +++ b/term_paper.tex @@ -23,6 +23,7 @@ \tikzstyle{inputBit}=[rectangle,fill=red, text=white] \tikzstyle{outputBit}=[rectangle,fill=blue, text=white] \tikzstyle{pointer}=[orange,->,dashed] +\tikzstyle{highlight}=[circle,fill=blue,text=white,scale=0.7] \newcounter{ctra} \newcommand{\trellisEdges}[2]{ @@ -150,9 +151,7 @@ \subsection{Диаграмма декодера} -\begin{tikzpicture}[x=1.2cm, y=-1cm, - highlight/.style={circle,fill=blue,text=white,scale=0.7} - ] +\begin{tikzpicture}[x=1.2cm, y=-1cm] \node at (-0.5,0) [left] {$s_1=00$}; \node at (-0.5,1) [left] {$s_2=10$}; @@ -222,7 +221,7 @@ } % Inputs - \node at (-0.5,4) [left] {Входная пара}; + \node at (-0.5,4) [left, align=right] {Входная\\пара}; \trellisIn{0}{11} \trellisIn{1}{00} @@ -235,33 +234,43 @@ \trellisIn{8}{11} \end{tikzpicture} -\begin{tikzpicture}[x=1.2cm, y=-1cm, - highlight/.style={circle,fill=blue,text=white,scale=0.7} - ] +Сегмент решетки декодера от $t=0$, до $t=3$. + +\begin{tikzpicture}[x=2cm, y=-1cm] \node at (-0.5,0) [left] {$s_1=00$}; \node at (-0.5,1) [left] {$s_2=10$}; \node at (-0.5,2) [left] {$s_3=01$}; \node at (-0.5,3) [left] {$s_4=11$}; - % Edges - \trellisEdges{0}{0} - \trellisEdges{1}{0} - \trellisEdges{1}{1} - \foreach \x in {2,...,8} { - \foreach \y in {0,...,3} { - \trellisEdges{\x}{\y} - } - } - % Nodes - \foreach \x in {0,...,9} { + \foreach \x in {0,...,3} { \node at (\x,-.7) {$\x$}; \foreach \y in {0,...,3} { \node (s\x\y) at (\x,\y) [circle,fill=black,scale=0.7] {}; } } + % Edges + \trellisEdges{0}{0} + \trellisEdges{1}{0} + \trellisEdges{1}{1} + \foreach \x in {2,...,2} { + \foreach \y in {0,...,3} { + \trellisEdges{\x}{\y} + } + } + + \draw[activeedge] (s00) -- (s10); + \draw[activeedge] (s00) -- (s11); + \draw[activeedge] (s10) -- (s20); + \draw[activeedge] (s11) -- (s22); + \draw[activeedge] (s20) -- (s30); + \draw[activeedge] (s22) -- (s31); + \draw[activeedge] (s11) -- (s23); + \draw[activeedge] (s23) -- (s32); + \draw[activeedge] (s23) -- (s33); + \node at (0,0) [highlight] {}; \node at (1,0) [highlight,label=left:{$2$}] {}; \node at (1,1) [highlight,label=left:{$0$}] {}; @@ -282,48 +291,299 @@ \node at (2.5,2) [text=red] {$\times$}; \node at (1.5,0.5) [text=red] {$\times$}; - \draw[activeedge] (s00) -- (s10); + % Inputs and Outputs + \node at (-0.5,4) [left, align=right] {Входная\\пара}; + + \trellisIn{0}{11} + \trellisIn{1}{00} + \trellisIn{2}{00} +\end{tikzpicture} + +Сегмент решетки декодера от $t=0$, до $t=4$. + +\begin{tikzpicture}[x=2cm, y=-1cm] + + \node at (-0.5,0) [left] {$s_1=00$}; + \node at (-0.5,1) [left] {$s_2=10$}; + \node at (-0.5,2) [left] {$s_3=01$}; + \node at (-0.5,3) [left] {$s_4=11$}; + + % Nodes + \foreach \x in {0,...,4} { + \node at (\x,-.7) {$\x$}; + \foreach \y in {0,...,3} { + \node (s\x\y) at (\x,\y) [circle,fill=black,scale=0.7] {}; + } + } + + % Edges + \trellisEdges{0}{0} + \trellisEdges{1}{0} + \trellisEdges{1}{1} + \foreach \x in {2,...,3} { + \foreach \y in {0,...,3} { + \trellisEdges{\x}{\y} + } + } + + \draw[activeedge] (s00) -- (s11); - \draw[activeedge] (s10) -- (s20); \draw[activeedge] (s11) -- (s22); - \draw[activeedge] (s20) -- (s30); \draw[activeedge] (s22) -- (s31); \draw[activeedge] (s11) -- (s23); \draw[activeedge] (s23) -- (s32); \draw[activeedge] (s23) -- (s33); + \draw[activeedge] (s31) -- (s43); + \draw[activeedge] (s32) -- (s41); + \draw[activeedge] (s32) -- (s40); + \draw[activeedge] (s33) -- (s42); + + \node at (0,0) [highlight] {}; + \node at (1,0) [highlight,label=left:{$2$}] {}; + \node at (1,1) [highlight,label=left:{$0$}] {}; + + \node at (2,0) [highlight,label=left:{$0$}] {}; + \node at (2,1) [highlight,label=left:{$2$}] {}; + \node at (2,2) [highlight,label=left:{$1$}] {}; + \node at (2,3) [highlight,label=left:{$1$}] {}; + + \node at (3,0) [highlight,label=left:{$\frac{0}{2}$}] {}; + \node at (3,1) [highlight,label=left:{$\frac{2}{0}$}] {}; + \node at (3,2) [highlight,label=left:{$\frac{1}{1}$}] {}; + \node at (3,3) [highlight,label=left:{$\frac{1}{1}$}] {}; + + \node at (2.5,1) [text=red] {$\times$}; + \node at (2.5,0.5) [text=red] {$\times$}; + \node at (2.5,1.5) [text=red] {$\times$}; + \node at (2.5,2) [text=red] {$\times$}; + \node at (1.5,0.5) [text=red] {$\times$}; + \node at (1.5,0) [text=red] {$\times$}; + \node at (0.5,0) [text=red] {$\times$}; + + \node at (4,0) [highlight,label=left:{$\frac{1}{1}$}] {$\frac33$}; + \node at (4,1) [highlight,label=left:{$\frac{1}{1}$}] {$\frac33$}; + \node at (4,2) [highlight,label=left:{$\frac{2}{0}$}] {$\frac32$}; + \node at (4,3) [highlight,label=left:{$\frac{0}{2}$}] {$\frac14$}; + + \node at (3.5,0) [text=red] {$\times$}; + \node at (3.5,0.5) [text=red] {$\times$}; + \node at (3.5,1.5) [text=red] {$\times$}; + \node at (3.5,3) [text=red] {$\times$}; + \node at (2.5,0) [text=red] {$\times$}; + + % Inputs and Outputs + \node at (-0.5,4) [left, align=right] {Входная\\пара}; + + \trellisIn{0}{11} + \trellisIn{1}{00} + \trellisIn{2}{00} + \trellisIn{3}{01} +\end{tikzpicture} + +Сегмент решетки декодера от $t=0$, до $t=5$. + +\begin{tikzpicture}[x=2cm, y=-1cm] + + \node at (-0.5,0) [left] {$s_1=00$}; + \node at (-0.5,1) [left] {$s_2=10$}; + \node at (-0.5,2) [left] {$s_3=01$}; + \node at (-0.5,3) [left] {$s_4=11$}; + + % Nodes + \foreach \x in {0,...,5} { + \node at (\x,-.7) {$\x$}; + \foreach \y in {0,...,3} { + \node (s\x\y) at (\x,\y) [circle,fill=black,scale=0.7] {}; + } + } + + % Edges + \trellisEdges{0}{0} + \trellisEdges{1}{0} + \trellisEdges{1}{1} + \foreach \x in {2,...,4} { + \foreach \y in {0,...,3} { + \trellisEdges{\x}{\y} + } + } + + + \draw[activeedge] (s00) -- (s11); + \draw[activeedge] (s11) -- (s22); + \draw[activeedge] (s22) -- (s31); + \draw[activeedge] (s11) -- (s23); + \draw[activeedge] (s23) -- (s32); + \draw[activeedge] (s23) -- (s33); + + \draw[activeedge] (s31) -- (s43); + \draw[activeedge] (s32) -- (s41); + \draw[activeedge] (s33) -- (s42); + + \draw[activeedge] (s41) -- (s52); + \draw[activeedge] (s42) -- (s50); + \draw[activeedge] (s42) -- (s51); + \draw[activeedge] (s43) -- (s53); + + \node at (0,0) [highlight] {}; + \node at (1,0) [highlight,label=left:{$2$}] {}; + \node at (1,1) [highlight,label=left:{$0$}] {}; + + \node at (2,0) [highlight,label=left:{$0$}] {}; + \node at (2,1) [highlight,label=left:{$2$}] {}; + \node at (2,2) [highlight,label=left:{$1$}] {}; + \node at (2,3) [highlight,label=left:{$1$}] {}; + + \node at (3,0) [highlight,label=left:{$\frac{0}{2}$}] {}; + \node at (3,1) [highlight,label=left:{$\frac{2}{0}$}] {}; + \node at (3,2) [highlight,label=left:{$\frac{1}{1}$}] {}; + \node at (3,3) [highlight,label=left:{$\frac{1}{1}$}] {}; + + \node at (2.5,1) [text=red] {$\times$}; + \node at (2.5,0.5) [text=red] {$\times$}; + \node at (2.5,1.5) [text=red] {$\times$}; + \node at (2.5,2) [text=red] {$\times$}; + \node at (1.5,0.5) [text=red] {$\times$}; + \node at (1.5,0) [text=red] {$\times$}; + \node at (0.5,0) [text=red] {$\times$}; + \node at (4,0) [highlight,label=left:{$\frac{1}{1}$}] {}; \node at (4,1) [highlight,label=left:{$\frac{1}{1}$}] {}; \node at (4,2) [highlight,label=left:{$\frac{2}{0}$}] {}; \node at (4,3) [highlight,label=left:{$\frac{0}{2}$}] {}; + \node at (3.5,0) [text=red] {$\times$}; + \node at (3.5,0.5) [text=red] {$\times$}; + \node at (3.5,1.5) [text=red] {$\times$}; + \node at (3.5,3) [text=red] {$\times$}; + \node at (2.5,0) [text=red] {$\times$}; + + \node at (5,0) [highlight,label=left:{$\frac{1}{1}$}] {$\frac43$}; + \node at (5,1) [highlight,label=left:{$\frac{1}{1}$}] {$\frac43$}; + \node at (5,2) [highlight,label=left:{$\frac{0}{2}$}] {$\frac33$}; + \node at (5,3) [highlight,label=left:{$\frac{2}{0}$}] {$\frac51$}; + + \node at (4.5,0) [text=red] {$\times$}; + \node at (4.5,0.5) [text=red] {$\times$}; + \node at (4.5,2.5) [text=red] {$\times$}; + \node at (4.5,2) [text=red] {$\times$}; + \node at (3.5,1) [text=red] {$\times$}; + + % Inputs and Outputs + \node at (-0.5,4) [left, align=right] {Входная\\пара}; + + \trellisIn{0}{11} + \trellisIn{1}{00} + \trellisIn{2}{00} + \trellisIn{3}{01} + \trellisIn{4}{10} +\end{tikzpicture} + +Сегмент решетки декодера от $t=0$, до $t=6$. + +\begin{tikzpicture}[x=1.8cm, y=-1cm] + + \node at (-0.5,0) [left] {$s_1=00$}; + \node at (-0.5,1) [left] {$s_2=10$}; + \node at (-0.5,2) [left] {$s_3=01$}; + \node at (-0.5,3) [left] {$s_4=11$}; + + % Nodes + \foreach \x in {0,...,6} { + \node at (\x,-.7) {$\x$}; + \foreach \y in {0,...,3} { + \node (s\x\y) at (\x,\y) [circle,fill=black,scale=0.7] {}; + } + } + + % Edges + \trellisEdges{0}{0} + \trellisEdges{1}{0} + \trellisEdges{1}{1} + \foreach \x in {2,...,5} { + \foreach \y in {0,...,3} { + \trellisEdges{\x}{\y} + } + } + + + \draw[activeedge] (s00) -- (s11); + \draw[activeedge] (s11) -- (s22); + \draw[activeedge] (s22) -- (s31); + \draw[activeedge] (s11) -- (s23); + \draw[activeedge] (s23) -- (s32); + \draw[activeedge] (s23) -- (s33); + + \draw[activeedge] (s31) -- (s43); + \draw[activeedge] (s32) -- (s41); + \draw[activeedge] (s33) -- (s42); + + \draw[activeedge] (s41) -- (s52); + \draw[activeedge] (s42) -- (s51); + \draw[activeedge] (s43) -- (s53); + + \draw[activeedge] (s51) -- (s62); + \draw[activeedge] (s52) -- (s61); + \draw[activeedge] (s52) -- (s60); + \draw[activeedge] (s53) -- (s63); + + \node at (0,0) [highlight] {}; + \node at (1,0) [highlight,label=left:{$2$}] {}; + \node at (1,1) [highlight,label=left:{$0$}] {}; + + \node at (2,0) [highlight,label=left:{$0$}] {}; + \node at (2,1) [highlight,label=left:{$2$}] {}; + \node at (2,2) [highlight,label=left:{$1$}] {}; + \node at (2,3) [highlight,label=left:{$1$}] {}; + + \node at (3,0) [highlight,label=left:{$\frac{0}{2}$}] {}; + \node at (3,1) [highlight,label=left:{$\frac{2}{0}$}] {}; + \node at (3,2) [highlight,label=left:{$\frac{1}{1}$}] {}; + \node at (3,3) [highlight,label=left:{$\frac{1}{1}$}] {}; + + \node at (2.5,1) [text=red] {$\times$}; + \node at (2.5,0.5) [text=red] {$\times$}; + \node at (2.5,1.5) [text=red] {$\times$}; + \node at (2.5,2) [text=red] {$\times$}; + \node at (1.5,0.5) [text=red] {$\times$}; + \node at (1.5,0) [text=red] {$\times$}; + \node at (0.5,0) [text=red] {$\times$}; + + \node at (4,0) [highlight,label=left:{$\frac{1}{1}$}] {}; + \node at (4,1) [highlight,label=left:{$\frac{1}{1}$}] {}; + \node at (4,2) [highlight,label=left:{$\frac{2}{0}$}] {}; + \node at (4,3) [highlight,label=left:{$\frac{0}{2}$}] {}; + + \node at (3.5,0) [text=red] {$\times$}; + \node at (3.5,0.5) [text=red] {$\times$}; + \node at (3.5,1.5) [text=red] {$\times$}; + \node at (3.5,3) [text=red] {$\times$}; + \node at (2.5,0) [text=red] {$\times$}; + \node at (5,0) [highlight,label=left:{$\frac{1}{1}$}] {}; \node at (5,1) [highlight,label=left:{$\frac{1}{1}$}] {}; \node at (5,2) [highlight,label=left:{$\frac{0}{2}$}] {}; \node at (5,3) [highlight,label=left:{$\frac{2}{0}$}] {}; - \node at (6,0) [highlight,label=left:{$\frac{1}{1}$}] {}; - \node at (6,1) [highlight,label=left:{$\frac{1}{1}$}] {}; - \node at (6,2) [highlight,label=left:{$\frac{0}{2}$}] {}; - \node at (6,3) [highlight,label=left:{$\frac{2}{0}$}] {}; + \node at (4.5,0) [text=red] {$\times$}; + \node at (4.5,0.5) [text=red] {$\times$}; + \node at (4.5,2.5) [text=red] {$\times$}; + \node at (4.5,2) [text=red] {$\times$}; + \node at (3.5,1) [text=red] {$\times$}; - \node at (7,0) [highlight,label=left:{$\frac{1}{1}$}] {}; - \node at (7,1) [highlight,label=left:{$\frac{1}{1}$}] {}; - \node at (7,2) [highlight,label=left:{$\frac{2}{0}$}] {}; - \node at (7,3) [highlight,label=left:{$\frac{0}{2}$}] {}; + \node at (6,0) [highlight,label=left:{$\frac{1}{1}$}] {$\frac44$}; + \node at (6,1) [highlight,label=left:{$\frac{1}{1}$}] {$\frac44$}; + \node at (6,2) [highlight,label=left:{$\frac{0}{2}$}] {$\frac33$}; + \node at (6,3) [highlight,label=left:{$\frac{2}{0}$}] {$\frac51$}; - \node at (8,0) [highlight,label=left:{$\frac{2}{0}$}] {}; - \node at (8,1) [highlight,label=left:{$\frac{0}{2}$}] {}; - \node at (8,2) [highlight,label=left:{$\frac{1}{1}$}] {}; - \node at (8,3) [highlight,label=left:{$\frac{1}{1}$}] {}; - - \node at (9,0) [highlight,label=left:{$\frac{2}{0}$}] {}; - \node at (9,1) [highlight,label=left:{$\frac{0}{2}$}] {}; - \node at (9,2) [highlight,label=left:{$\frac{1}{1}$}] {}; - \node at (9,3) [highlight,label=left:{$\frac{1}{1}$}] {}; + \node at (5.5,0) [text=red] {$\times$}; + \node at (5.5,0.5) [text=red] {$\times$}; + \node at (5.5,2.5) [text=red] {$\times$}; + \node at (5.5,2) [text=red] {$\times$}; + \node at (4.5,1) [text=red] {$\times$}; % Inputs and Outputs - \node at (-0.5,4) [left] {Входная пара}; + \node at (-0.5,4) [left, align=right] {Входная\\пара}; \trellisIn{0}{11} \trellisIn{1}{00} @@ -331,9 +591,6 @@ \trellisIn{3}{01} \trellisIn{4}{10} \trellisIn{5}{10} - \trellisIn{6}{01} - \trellisIn{7}{11} - \trellisIn{8}{11} \end{tikzpicture} \end{document}