dipl/vhdl_intro/vhdl_intro.tex

53 lines
1.6 KiB
TeX

\documentclass[../Diplomschrift.tex]{subfiles}
\begin{document}
\part{A short introduction to VHDL}
Designing a processor is a big task, and it's easiest to start very small. With software projects, this is usually in the form of a ``Hello World'' program - we will be designing a hardware equivalent of this.
\section{Prerequisites}
Other than a text editor, the following Free Software packages have to be installed:
\begin{savenotes}
\begin{description}
\item[\texttt{ghdl}\footnote{\url{https://github.com/ghdl/ghdl}}] to compile and simulate the design
\item[\texttt{gtkwave}\footnote{\url{http://gtkwave.sourceforge.net/}}] to view the generated waveform files
\item[GNU \texttt{make}] to coordinate simulating designs, compiling firmware and generating images
\item[python] for helper scripts
\end{description}
\end{savenotes}
\section{Creating a design}
A simple starting design is a D flip flop:
\def\svgwidth{2cm}
\input{d_flip_flop.pdf_tex}
The following VHDL code describes the device:
\lstinputlisting[title=\texttt{flipflop.vhd}]{vhdl/flipflop.vhd}
In order to test this design, a test bench has to be created:
\lstinputlisting[title=\texttt{flipflop\_tb.vhd}]{vhdl/flipflop_tb.vhd}
\section{Simulating a design}
\begin{lstlisting}[style=default,language=sh]
# analyze the design files
ghdl -a *.vhd
# elaborate the test bench entity
ghdl -e flipflop_tb
# run the test bench, saving the signal trace to a GHW file
ghdl -r flipflop_tb --wave=flipflop_tb.ghw
# open the trace with gtkwave
gtkwave flipflop_tb.ghw
\end{lstlisting}
\begin{center}
\includegraphics[width=\textwidth]{flipflop_gtkwave.png}
\end{center}
\end{document}