Add initial outline of DS
This commit is contained in:
parent
3b360e3237
commit
387e9d61c6
10 changed files with 435 additions and 0 deletions
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
*.log
|
||||
*.aux
|
||||
*.synctex.gz
|
||||
*.pdf
|
||||
*.out
|
||||
|
||||
*.o
|
||||
*.ghw
|
||||
*.gtkw
|
||||
work-*.cf
|
15
Diplomschrift.tex
Normal file
15
Diplomschrift.tex
Normal file
|
@ -0,0 +1,15 @@
|
|||
\documentclass[a4paper,10pt]{article}
|
||||
|
||||
\input{preamble.tex}
|
||||
|
||||
\usepackage{subfiles}
|
||||
\begin{document}
|
||||
|
||||
\tableofcontents
|
||||
\let\tableofcontents\relax
|
||||
|
||||
\newpage
|
||||
|
||||
\subfile{vhdl_intro/vhdl_intro.tex}
|
||||
|
||||
\end{document}
|
62
preamble.tex
Normal file
62
preamble.tex
Normal file
|
@ -0,0 +1,62 @@
|
|||
\usepackage[utf8]{inputenc}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{url}
|
||||
\usepackage{listings}
|
||||
|
||||
\lstdefinelanguage{customvhdl}[]{VHDL}{
|
||||
morekeywords=[2]{std_logic, std_logic_vector, natural, integer, bit, string},
|
||||
}
|
||||
|
||||
\lstdefinestyle{default}{
|
||||
showstringspaces=false,
|
||||
tabsize=4,
|
||||
belowcaptionskip=1\baselineskip,
|
||||
basicstyle=\footnotesize\ttfamily,
|
||||
keywordstyle=\bfseries\color{green!40!black},
|
||||
commentstyle=\itshape\color{purple},
|
||||
stringstyle=\color{orange},
|
||||
breaklines=true,
|
||||
xleftmargin=\parindent,
|
||||
numbers=left,
|
||||
title=\lstname,
|
||||
}
|
||||
|
||||
\lstdefinestyle{vhdlstyle}{
|
||||
style=default,
|
||||
language=customvhdl,
|
||||
keywordstyle=[2]\bfseries\color{blue!80!white},
|
||||
backgroundcolor=\color{lightgray!20},
|
||||
frame=lrtb,
|
||||
}
|
||||
|
||||
\lstset{
|
||||
style=vhdlstyle,
|
||||
}
|
||||
|
||||
\usepackage{titling}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{lastpage}
|
||||
\usepackage{datetime}
|
||||
\yyyymmdddate
|
||||
\renewcommand{\dateseparator}{-}
|
||||
|
||||
\usepackage{fancyhdr}
|
||||
|
||||
\usepackage{pst-uml}
|
||||
\setlength{\hoffset}{30mm-1in}
|
||||
\setlength{\oddsidemargin}{0pt}
|
||||
\setlength{\textwidth}{\paperwidth-60mm}
|
||||
\addtolength{\textheight}{5em}
|
||||
|
||||
\setlength{\headwidth}{\textwidth}
|
||||
|
||||
\setlength{\topmargin}{0pt}
|
||||
\addtolength{\voffset}{-1em}
|
||||
|
||||
\setlength{\parindent}{0px}
|
||||
\setlength{\parskip}{1em}
|
||||
|
||||
\usepackage{footnote}
|
||||
|
||||
% loaded last
|
||||
\usepackage{hyperref}
|
62
vhdl_intro/d_flip_flop.pdf_tex
Normal file
62
vhdl_intro/d_flip_flop.pdf_tex
Normal file
|
@ -0,0 +1,62 @@
|
|||
%% Creator: Inkscape inkscape 0.92.4, www.inkscape.org
|
||||
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
|
||||
%% Accompanies image file 'd_flip_flop.pdf' (pdf, eps, ps)
|
||||
%%
|
||||
%% To include the image in your LaTeX document, write
|
||||
%% \input{<filename>.pdf_tex}
|
||||
%% instead of
|
||||
%% \includegraphics{<filename>.pdf}
|
||||
%% To scale the image, write
|
||||
%% \def\svgwidth{<desired width>}
|
||||
%% \input{<filename>.pdf_tex}
|
||||
%% instead of
|
||||
%% \includegraphics[width=<desired width>]{<filename>.pdf}
|
||||
%%
|
||||
%% Images with a different path to the parent latex file can
|
||||
%% be accessed with the `import' package (which may need to be
|
||||
%% installed) using
|
||||
%% \usepackage{import}
|
||||
%% in the preamble, and then including the image with
|
||||
%% \import{<path to file>}{<filename>.pdf_tex}
|
||||
%% Alternatively, one can specify
|
||||
%% \graphicspath{{<path to file>/}}
|
||||
%%
|
||||
%% For more information, please see info/svg-inkscape on CTAN:
|
||||
%% http://tug.ctan.org/tex-archive/info/svg-inkscape
|
||||
%%
|
||||
\begingroup%
|
||||
\makeatletter%
|
||||
\providecommand\color[2][]{%
|
||||
\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
|
||||
\renewcommand\color[2][]{}%
|
||||
}%
|
||||
\providecommand\transparent[1]{%
|
||||
\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
|
||||
\renewcommand\transparent[1]{}%
|
||||
}%
|
||||
\providecommand\rotatebox[2]{#2}%
|
||||
\newcommand*\fsize{\dimexpr\f@size pt\relax}%
|
||||
\newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}%
|
||||
\ifx\svgwidth\undefined%
|
||||
\setlength{\unitlength}{67.5bp}%
|
||||
\ifx\svgscale\undefined%
|
||||
\relax%
|
||||
\else%
|
||||
\setlength{\unitlength}{\unitlength * \real{\svgscale}}%
|
||||
\fi%
|
||||
\else%
|
||||
\setlength{\unitlength}{\svgwidth}%
|
||||
\fi%
|
||||
\global\let\svgwidth\undefined%
|
||||
\global\let\svgscale\undefined%
|
||||
\makeatother%
|
||||
\begin{picture}(1,0.88888888)%
|
||||
\lineheight{1}%
|
||||
\setlength\tabcolsep{0pt}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=1]{d_flip_flop.pdf}}%
|
||||
\put(0.24113854,0.61362848){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{0}\smash{\begin{tabular}[t]{l}D\end{tabular}}}}%
|
||||
\put(0.76564026,0.61111112){\color[rgb]{0,0,0}\makebox(0,0)[rt]{\lineheight{0}\smash{\begin{tabular}[t]{r}Q\end{tabular}}}}%
|
||||
\put(0.76472863,0.16666667){\color[rgb]{0,0,0}\makebox(0,0)[rt]{\lineheight{0}\smash{\begin{tabular}[t]{r}Q\end{tabular}}}}%
|
||||
\put(0.24113854,0.16666667){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{0}\smash{\begin{tabular}[t]{l}E\end{tabular}}}}%
|
||||
\end{picture}%
|
||||
\endgroup%
|
165
vhdl_intro/d_flip_flop.svg
Normal file
165
vhdl_intro/d_flip_flop.svg
Normal file
|
@ -0,0 +1,165 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="100"
|
||||
height="100"
|
||||
id="svg2"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.46"
|
||||
version="1.0"
|
||||
sodipodi:docbase="C:\Program Files\Inkscape"
|
||||
sodipodi:docname="Transparent Latch Symbol.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape">
|
||||
<defs
|
||||
id="defs4">
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="0 : 50 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="100 : 50 : 1"
|
||||
inkscape:persp3d-origin="50 : 33.333333 : 1"
|
||||
id="perspective3848" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="2"
|
||||
inkscape:cx="69.170212"
|
||||
inkscape:cy="11.088566"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
inkscape:grid-bbox="true"
|
||||
inkscape:grid-points="true"
|
||||
showguides="true"
|
||||
inkscape:guide-bbox="true"
|
||||
gridtolerance="5px"
|
||||
inkscape:window-width="1024"
|
||||
inkscape:window-height="712"
|
||||
inkscape:window-x="94"
|
||||
inkscape:window-y="107"
|
||||
inkscape:snap-bbox="true"
|
||||
objecttolerance="11">
|
||||
<inkscape:grid
|
||||
id="GridFromPre046Settings"
|
||||
type="xygrid"
|
||||
originx="0px"
|
||||
originy="0px"
|
||||
spacingx="5px"
|
||||
spacingy="5px"
|
||||
color="#0000ff"
|
||||
empcolor="#0000ff"
|
||||
opacity="0.2"
|
||||
empopacity="0.4"
|
||||
empspacing="5"
|
||||
visible="true"
|
||||
enabled="true" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<g
|
||||
id="g4867"
|
||||
style="fill:none">
|
||||
<rect
|
||||
y="11.500001"
|
||||
x="21.499998"
|
||||
height="77"
|
||||
width="56.999996"
|
||||
id="rect1311"
|
||||
style="opacity:1;fill:none;fill-opacity:0.03703703;stroke:#000000;stroke-width:2.99999952;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<path
|
||||
id="path3085"
|
||||
d="M 21,30 L 5,30"
|
||||
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
id="path3087"
|
||||
d="M 21,70 L 5,70"
|
||||
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
id="path3089"
|
||||
d="M 79,70 L 95,70"
|
||||
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
id="path3091"
|
||||
d="M 79,30 L 95,30"
|
||||
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:nodetypes="cc" />
|
||||
</g>
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="M 63.806565,62 L 73.306565,62"
|
||||
id="path3081" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans"
|
||||
x="26.702469"
|
||||
y="34.773438"
|
||||
id="text3850"
|
||||
sodipodi:linespacing="100%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3852"
|
||||
x="26.702469"
|
||||
y="34.773438">D</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:end;line-height:100%;writing-mode:lr-tb;text-anchor:end;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans"
|
||||
x="73.907623"
|
||||
y="35"
|
||||
id="text3858"
|
||||
sodipodi:linespacing="100%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3860"
|
||||
x="73.907623"
|
||||
y="35">Q</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:end;line-height:100%;writing-mode:lr-tb;text-anchor:end;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans"
|
||||
x="73.825577"
|
||||
y="75"
|
||||
id="text3863"
|
||||
sodipodi:linespacing="100%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3865"
|
||||
x="73.825577"
|
||||
y="75">Q</tspan></text>
|
||||
<text
|
||||
sodipodi:linespacing="100%"
|
||||
id="text4661"
|
||||
y="75"
|
||||
x="26.702469"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans"
|
||||
xml:space="preserve"><tspan
|
||||
y="75"
|
||||
x="26.702469"
|
||||
id="tspan4663"
|
||||
sodipodi:role="line">E</tspan></text>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 6.5 KiB |
BIN
vhdl_intro/flipflop_gtkwave.png
Normal file
BIN
vhdl_intro/flipflop_gtkwave.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
25
vhdl_intro/vhdl/flipflop.vhd
Normal file
25
vhdl_intro/vhdl/flipflop.vhd
Normal file
|
@ -0,0 +1,25 @@
|
|||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
|
||||
entity flipflop is
|
||||
port (
|
||||
d : in std_logic;
|
||||
e : in std_logic;
|
||||
q : out std_logic;
|
||||
q_n : out std_logic
|
||||
);
|
||||
end entity;
|
||||
|
||||
architecture rtl of flipflop is
|
||||
signal state : std_logic;
|
||||
begin
|
||||
store: process(e)
|
||||
begin
|
||||
if rising_edge(e) then
|
||||
state <= d;
|
||||
end if;
|
||||
end process;
|
||||
|
||||
q <= state;
|
||||
q_n <= not state;
|
||||
end architecture;
|
BIN
vhdl_intro/vhdl/flipflop_tb
Executable file
BIN
vhdl_intro/vhdl/flipflop_tb
Executable file
Binary file not shown.
44
vhdl_intro/vhdl/flipflop_tb.vhd
Normal file
44
vhdl_intro/vhdl/flipflop_tb.vhd
Normal file
|
@ -0,0 +1,44 @@
|
|||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
|
||||
entity flipflop_tb is
|
||||
end entity;
|
||||
|
||||
architecture test of flipflop_tb is
|
||||
signal s_d, s_e, s_q : std_logic;
|
||||
begin
|
||||
uut: entity work.flipflop
|
||||
port map (
|
||||
d => s_d,
|
||||
e => s_e,
|
||||
q => s_q
|
||||
);
|
||||
|
||||
simulate: process
|
||||
begin
|
||||
s_d <= '0';
|
||||
s_e <= '0';
|
||||
|
||||
wait for 100 ns;
|
||||
|
||||
s_e <= '1';
|
||||
wait for 10 ns;
|
||||
s_e <= '0';
|
||||
|
||||
assert s_q = '0';
|
||||
|
||||
wait for 50 ns;
|
||||
s_d <= '1';
|
||||
wait for 50 ns;
|
||||
|
||||
assert s_q = '0';
|
||||
|
||||
s_e <= '1';
|
||||
wait for 10 ns;
|
||||
s_e <= '0';
|
||||
assert s_q = '1';
|
||||
|
||||
wait for 100 ns;
|
||||
wait;
|
||||
end process;
|
||||
end architecture;
|
52
vhdl_intro/vhdl_intro.tex
Normal file
52
vhdl_intro/vhdl_intro.tex
Normal file
|
@ -0,0 +1,52 @@
|
|||
\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}
|
Loading…
Reference in a new issue