aboutsummaryrefslogtreecommitdiffstats
path: root/tex/samples.tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex/samples.tex')
-rw-r--r--tex/samples.tex77
1 files changed, 77 insertions, 0 deletions
diff --git a/tex/samples.tex b/tex/samples.tex
new file mode 100644
index 0000000..0e335d2
--- /dev/null
+++ b/tex/samples.tex
@@ -0,0 +1,77 @@
+\section{Samples / Templates}
+
+Below is a template for a simple VHDL file.
+
+\begin{lstlisting}[language=vhdl]
+library ieee;
+use ieee.std_logic_1164.all;
+-- declare entities (`\S\ref{sec:vhdl:entities-arch}`)
+entity `\reqph{name}` is
+ port(`\optionalph{pins}`);
+end entity `\reqph{name}`;
+-- declare architectures (`\S\ref{sec:vhdl:entities-arch}`)
+architecture `\reqph{name}` of `\reqph{entity name}` is
+ -- internal signals (`\S\ref{sec:vhdl:declarations}`)
+ -- other components (`\S\ref{sec:vhdl:components}`)
+ -- declare custom types (`\S\ref{sec:fsm:encode}`)
+ -- variables of custom type (`\S\ref{sec:fsm:encode}`)
+begin
+ -- assignments and processes (`\S\ref{sec:vhdl:concurrent}`)
+end architecture `\reqph{name}`;
+\end{lstlisting}
+And for a test bench
+\begin{lstlisting}[language=vhdl]
+library ieee;
+use ieee.std_logic_1164.all;
+
+-- declare entities (`\S\ref{sec:vhdl:entities-arch}`)
+entity `\reqph{name}`_tb is
+ -- nothing here
+end entity `\reqph{name}`_tb;
+
+architecture tb of `\reqph{name}`_tb is
+ -- simulator settings
+ constant freq : natural := `\reqph{frequency}`;
+ constant time : time := 1 sec / freq;
+
+ -- component of DUT
+ component `\reqph{name}` is
+ port(
+ clk : in std_ulogic;
+ `\optionalph{other I/O}`
+ );
+ end component `\reqph{name}`;
+
+ signal clk_tb : std_ulogic;
+ -- more signals for inputs and outputs
+begin
+
+ dut: component `\reqph{name}`
+ port map(
+ clk => clk_tb;
+ `\reqph{other I/O}`);
+
+ clk_generator: process
+ -- generate clock (`\S\ref{sec:stimuli}`)
+ clk_tb <= '1'; wait for (T/2);
+ clk_tb <= '0'; wait for (T/2);
+ end process;
+
+ stimuli: process
+ begin
+ -- generate stimuli (`\S\ref{sec:stimuli}`)
+ -- for loops, after, etc.
+ end;
+
+ response: process
+ -- constants for expected outputs
+ begin
+ wait for 0.9 * T;
+ -- assertions (`\S\ref{sec:assertions}`)
+ wait for T;
+ end process;
+
+end architecture tb;
+
+\end{lstlisting}
+% vim:ts=2 sw=2 et: