How to create following block diagram structure in LaTeX

enter image description here

\documentclass{article}



\begin{document}
\lineskip0pt

\framebox[3cm]{\strut Text1}

\makebox[3cm]{\strut\vrule}

\framebox[3cm]{\strut Text2}

\makebox[3cm]{\strut\vrule}

\framebox[3cm]{\strut Text3}




\end{document}

Here you can specify the width of the boxes (it will be adjusted to fit if too short) and the separation between the boxes.

\documentclass{article}
\usepackage{keyval}

\makeatletter
\define@key{cascading}{width}{\cascading@wd=#1}
\define@key{cascading}{sep}{\def\cascading@sep{#1}}
\newdimen\cascading@wd

\newcommand{\cascadingblocks}[2][]{%
  \setkeys{cascading}{sep=2ex,#1}%
  \leavevmode\vbox{\offinterlineskip
    \@for\next:=#2\do{%
      \settowidth{\dimen@}{\next}%
      \ifdim\dimen@>\cascading@wd
        \cascading@wd=\dimen@
      \fi
    }%
    \@for\next:=#2\do{%
      \cascading@rule
      \hbox{\fbox{\hb@xt@\cascading@wd{\hss\next\hss}}}%
    }
  }
}
\def\cascading@rule{%
  \def\cascading@rule{%
    \hb@xt@\dimexpr\cascading@wd+2\fboxsep+2\fboxrule\relax
      {\hss\vrule\@height\cascading@sep\hss}%
  }%
}
\makeatother

\begin{document}
% natural width, default sep
\cascadingblocks{foo,bar,foobar,foobazzzz}
% 3cm width, 3pt sep
\cascadingblocks[width=3cm,sep=3pt]{foo,bar,foobar,foobazzzz}
% 1cm width (automatically increased), default sep
\cascadingblocks[width=1cm]{foo,bar,foobar,foobazzzz}

\end{document}

enter image description here


Another option, using TikZ and chains:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains}

\begin{document}

\begin{tikzpicture}[
start chain=going below,
node distance=3mm,
every node/.style={on chain,join},
every join/.style={-},
block/.style={draw, text width=3cm,align=center}
]
\foreach \i in {1,...,5}
  \node[block] {Text \i};
\end{tikzpicture}

\end{document}

enter image description here