\documentclass[UTF8]{ctexart}
\usepackage{tikz,mathpazo}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{calc}
\begin{document}
\thispagestyle{empty}
% 流程图定义基本形状
\tikzstyle{process} = [rectangle, minimum width=4cm, minimum height=1cm, draw=black, fill=pink!30]
\tikzstyle{decision} = [diamond, minimum width=8cm, minimum height=0.5cm, text centered, draw=black, fill=red!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{tikzpicture}[node distance=2cm]
%定义流程图具体形状
\node (M1) [process] {PC $\rightarrow$ AR , PC+1};
\node (M2) [decision,below of= M1,yshift=-2cm] {RAM $\rightarrow$ IR,指令译码};
\node (M3_RET) [process,right of= M2,xshift=2cm,yshift=-5cm] {SP $\rightarrow$ AR};
\node (M4_RET) [process,below of= M3_RET] {RAM $\rightarrow$ PC};
\node (M5_RET) [process,below of= M4_RET] {SP $\rightarrow$ $DA_1$};
\node (M6_RET) [process,below of= M5_RET] {$DA_1$+1 $\rightarrow$ SP};
\node (M3_CALL) [process,left of= M2,xshift=-2cm,yshift=-4cm] {PC $\rightarrow$ AR,PC+1};
\node (M4_CALL) [process,below of= M3_CALL] {RAM $\rightarrow$ $DA_2$};
\node (M5_CALL) [process,below of= M4_CALL] {SP $\rightarrow$ $DA_1$};
\node (M6_CALL) [process,below of= M5_CALL] {$DA_1-1$ $\rightarrow$ SP};
\node (M7_CALL) [process,below of= M6_CALL] {$DA_2$ $\rightarrow$ PC};
%连接具体形状
\draw [arrow](M1) -- (M2);
\draw [arrow](M2) -- node[anchor=west,xshift=4cm] {RET} ($(M2.south)$) -|(M3_RET);
\draw [arrow](M3_RET) -- (M4_RET);
\draw [arrow](M4_RET) -- (M5_RET);
\draw [arrow](M5_RET) -- (M6_RET);
\draw [arrow](M6_RET) -- ($(M6_RET.east) +(1,0)$) |-(M1);
\draw [arrow](M2) -- node[anchor=east,xshift=-4cm] {CALL} ($(M2.south)$) -|(M3_CALL);
\draw [arrow](M3_CALL) -- (M4_CALL);
\draw [arrow](M4_CALL) -- (M5_CALL);
\draw [arrow](M5_CALL) -- (M6_CALL);
\draw [arrow](M6_CALL) -- (M7_CALL);
\draw [arrow](M7_CALL) -- ($(M7_CALL.west) +(-1,0)$) |-(M1);
% \draw [arrow](M) -- (M2);
\end{tikzpicture}
\end{document}
latex 流程图
最新推荐文章于 2024-05-03 22:53:26 发布