2019-12-10 15:32:02 +01:00
\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}
2020-03-01 17:13:51 +01:00
\item [\icode{ghdl}\footnote{\url{https://github.com/ghdl/ghdl}}] to compile and simulate the design
\item [\icode{gtkwave}\footnote{\url{http://gtkwave.sourceforge.net/}}] to view the generated waveform files
\item [GNU \icode{make}] to coordinate simulating designs, compiling firmware and generating images
\item [\icode{python}] for helper scripts
2019-12-10 15:32:02 +01:00
\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}