1 |
210 |
ja_rd |
\chapter{Code samples}
|
2 |
|
|
\label{samples}
|
3 |
|
|
|
4 |
|
|
Directory /src directory contains a few test applications that can be
|
5 |
|
|
simulated and run on real hardware, except for the opcode test which can
|
6 |
|
|
only be simulated. See the readme file and the makefile for each program.\\
|
7 |
|
|
|
8 |
|
|
Please read the /src/reame.txt file for information that will probably be
|
9 |
|
|
more up-to-date than this doc.\\
|
10 |
|
|
|
11 |
|
|
The makefiles have been tested with the CodeSourcery toolchain for windows
|
12 |
|
|
(that can be downloaded from www.codesourcery.com) and with the Buildroot
|
13 |
|
|
toolchain for GNU/Linux.\\
|
14 |
|
|
|
15 |
|
|
Most makefiles have two targets, to create a simulation test bench and a
|
16 |
|
|
synthesizable demo.\\
|
17 |
|
|
|
18 |
|
|
Target 'sim' will build the simulation test bench package files as described
|
19 |
|
|
in section~\ref{logic_simulation}.
|
20 |
|
|
|
21 |
|
|
Target 'demo' will build a synthesizable demo; it will compile the sample
|
22 |
|
|
sources and place the resulting object code in file
|
23 |
|
|
'/vhdl/demo/code\_rom\_pkg.vhdl' (note that the 'sim' target has to do this
|
24 |
|
|
too).\\
|
25 |
|
|
|
26 |
|
|
The build process will produce two or more binary files ('*.code' and
|
27 |
|
|
'*.data', or '*.bin') that can be run on the software simulator, plus a
|
28 |
|
|
listing file (*.lst) handy for debugging.\\
|
29 |
|
|
|
30 |
|
|
All projects include a DOS batch file 'swsim.bat' that invokes the
|
31 |
|
|
software simulator with the proper parameters. As an example, these are the
|
32 |
|
|
contents of the 'swsim.bat' file for the 'hello' demo:
|
33 |
|
|
|
34 |
|
|
\begin{verbatim}
|
35 |
|
|
@rem Run software simulator in hands-off mode
|
36 |
|
|
..\..\tools\slite\slite\bin\Debug\slite.exe ^
|
37 |
|
|
--bram=hello.code ^
|
38 |
|
|
--trigger=bfc00000 ^
|
39 |
|
|
--noprompt ^
|
40 |
|
|
--nomips32 ^
|
41 |
|
|
--map=hello.map ^
|
42 |
|
|
--trace_log=trace_log.txt
|
43 |
|
|
\end{verbatim}\\
|
44 |
|
|
|
45 |
|
|
As you can see, the simulator is invoked in 'batch' or 'hands-off' mode, so
|
46 |
|
|
the simulated program will be run to completion, generating a simulation
|
47 |
|
|
log. The point of this is comparing that log to the log generated by the
|
48 |
|
|
Modelsim simulation of the same program, as has already been explained.
|
49 |
|
|
|
50 |
|
|
The python script 'bin2hdl.py' is used to insert binary data on vhdl
|
51 |
|
|
templates.
|
52 |
|
|
Assuming you have Python 2.5 or later in your machine, call the script with:
|
53 |
|
|
|
54 |
|
|
\begin{verbatim}
|
55 |
|
|
python bin2hdl.py --help
|
56 |
|
|
\end{verbatim}\\
|
57 |
|
|
|
58 |
|
|
to get a short description (see section~\ref{python_script}).
|
59 |
|
|
|