%   es_state.tikz
%   2020-06-26  Markku-Juhani O. Saarinen <mjos@pqshield.com>
%	CONTRIBUTED TO PUBLIC DOMAIN

\begin{tikzpicture}[>=latex,scale=1.4]
\tikzset{every state/.append style={rectangle, thick, rounded corners}};


\node[align=center] (reset) at (0,-0.5) {reset};
\node[state,fill=cyan!10] (bist) at (0,-1.5) {BIST};

\node[state,fill=yellow!20] (wait) at (-0.9,-3) {WAIT};
\draw[->] (wait) .. controls ++(0.2,-0.85) and ++(-0.2,-0.85) .. (wait);

\node[state,fill=green!20] (es16) at (0.9,-3) {ES16};
\draw[->] (es16) .. controls ++(0.2,-0.85) and ++(-0.2,-0.85) .. (es16);

\node[align=left] (entropy) at (1.85,-3) {{entropy}\\{valid!}};

\node[state,fill=red!20] (dead) at (0,-4.5) {DEAD};

\node[color=red,align=left] (dead2) at (0.85,-5.05) {\em stays dead};

\node[color=blue,align=center] at (1.25,-2.0) {{\it non-fatal}\\{\it alarm}};

\draw[->] (reset) to (bist);
\draw[->] (bist) to (wait);
\draw[->] (bist) to (es16);

\draw[->, bend left] (wait) to (es16);
\draw[->, bend left] (es16) to (wait);

\draw[color=red,dashed,->] (bist) .. controls (-2.0,-2.5) and (-2.0,-3.5) .. (dead);

\draw[color=red,dashed,->] (wait) to (dead);
\draw[color=red,dashed,->] (es16) to (dead);

\draw[color=red,->] (dead) .. controls ++(0.2,-0.85) and ++(-0.2,-0.85) .. (dead);

\node[color=red,align=right] at (-1.0,-4.5) {{\it fatal}\\{\it error}};

\draw[color=blue,densely dotted,->] (wait) .. controls (-1.0,-2.7)
    and (-1.0,-2.2) .. (bist);

\draw[color=blue,densely dotted,->] (es16) .. controls (1.0,-2.7)
    and (1.0,-2.2) .. (bist);

\draw[color=blue,densely dotted,->] (bist) .. controls ++(-0.85,-0.2)
    and ++(-0.85,0.2) .. (bist);

%\draw[->] (wait) .. controls ++(-0.85,-0.2) and ++(-0.85,0.2) .. (wait);
%\draw[->] (es16) .. controls ++(0.85,0.2) and ++(0.85,-0.2) .. (es16);

\end{tikzpicture}

