1 |
210 |
ja_rd |
|
2 |
|
|
\chapter{Tools}
|
3 |
|
|
\label{tools}
|
4 |
|
|
|
5 |
|
|
\section{MIPS Software Simulator}
|
6 |
|
|
\label{sw_simulator}
|
7 |
|
|
|
8 |
|
|
Plasma project includes a MIPS-I simulator made by Steve Rhoads, called
|
9 |
|
|
'mlite.c'. According the the author, it was used as a golden model for the
|
10 |
|
|
construction of the cpu, the same as I have done.\\
|
11 |
|
|
I have made some modifications on Rhoads' code, mostly for logging, and
|
12 |
|
|
called the new program 'slite' ('/tools/slite/src/slite.c').\\
|
13 |
|
|
|
14 |
|
|
The most salient features are:
|
15 |
|
|
|
16 |
|
|
\begin{itemize}
|
17 |
|
|
\item Logs CPU state to a text file.
|
18 |
|
|
The format is identical to that of the vhdl test bench log.
|
19 |
|
|
You can select the code address that triggers the logging.
|
20 |
|
|
\item Echoes CPU UART output to the host console or to a log file.
|
21 |
|
|
\item Can be run in interactive mode (like a monitor).\\
|
22 |
|
|
Step by step execution, breakpoints, that kind of thing.
|
23 |
|
|
\item Can be run in batch (unattended) mode.\\
|
24 |
|
|
So that you can easily run a program to compare logs with the
|
25 |
|
|
vhdl test bench.
|
26 |
|
|
\item Does not simulate the cache at all.
|
27 |
|
|
\end{itemize}
|
28 |
|
|
|
29 |
|
|
Each code sample includes a DOS batch file named 'swsim.bat' that runs the
|
30 |
|
|
simulator in batch mode.\\
|
31 |
|
|
|
32 |
|
|
The program includes usage help (a short description of the command line
|
33 |
|
|
parameters). The source code (very simple and straighforward) is includef in
|
34 |
|
|
the project. The BAT files provide an usage example. And anyone who is
|
35 |
|
|
interested and finds trouble can always contact me.
|
36 |
|
|
|
37 |
|
|
For all these reasons I think it is not necessary to explain the simulator
|
38 |
|
|
in detail. Nothing to do with laziness, as you can see.\\
|
39 |
|
|
|
40 |
|
|
Many system parameters are hardcoded, including the log file name, the
|
41 |
|
|
simulated memory sizes and the code and data addresses.\\
|
42 |
|
|
|
43 |
|
|
The hardcoded log file name is "sw\_sim\_log.txt" and it is generated in the
|
44 |
|
|
same directory from which the simulator is run.\\
|
45 |
|
|
|
46 |
|
|
\section{Conversion Script bin2hdl.py}
|
47 |
|
|
\label{python_script}
|
48 |
|
|
|
49 |
|
|
This Python script reads one or more binary files and 'inserts' them in a
|
50 |
|
|
vhdl template. It makes the
|
51 |
|
|
conversion from binary to vhdl strings and slices the data in byte columns,
|
52 |
|
|
as required by the RAM implementation (in which each byte in a word is
|
53 |
|
|
stored in a different RAM with a separate WE, 4 blocks in all).\\
|
54 |
|
|
|
55 |
|
|
The 3 binary files the script can read are the object code image, the
|
56 |
|
|
data image (initialized data sections) and a FLASH image.
|
57 |
|
|
|
58 |
|
|
The script inserts a number of simulation parameters in the template file,
|
59 |
|
|
as illustrated by the makefiles.\\
|
60 |
|
|
|
61 |
|
|
The makefiles of the code samples can be used as an example. The script code
|
62 |
|
|
is a bit convoluted but it is understandable if you do know Python,
|
63 |
|
|
and includes some usage instructions.\\
|
64 |
|
|
|
65 |
|
|
The vhdl templates (/src/*\_template.vhdl) have placeholder 'tags' that are
|
66 |
|
|
replaced with real application data by this script.
|
67 |
|
|
|
68 |
|
|
Some of the tags are these:
|
69 |
|
|
|
70 |
|
|
\begin{tabular}{ l l }
|
71 |
|
|
"@code0@" & : Contents of RAM block for slice 0 (lsb) of code\\
|
72 |
|
|
...\\
|
73 |
|
|
"@code3@" & : Contents of RAM block for slice 3 (msb) of code\\
|
74 |
|
|
"@code31@" & : Contents of RAM block for slices 3 \& 1 (odd) of code\\
|
75 |
|
|
"@code20@" & : Contents of RAM block for slices 2 \& 0 (odd) of code\\
|
76 |
|
|
"@data0@" & : Contents of RAM block for slice 0 (lsb) of data\\
|
77 |
|
|
...\\
|
78 |
|
|
"@data3@" & : Contents of RAM block for slice 3 (msb) of data\\
|
79 |
|
|
"@data31@" & : Contents of RAM block for slices 3 \& 1 (odd) of data\\
|
80 |
|
|
"@data20@" & : Contents of RAM block for slices 2 \& 0 (odd) of data\\
|
81 |
|
|
"@flash@" & : Contents of simulated FLASH\\
|
82 |
|
|
"@data-32bit@" & : Contents of 32-bit-wide RAM block of data\\
|
83 |
|
|
"@entity\_name@" & : Name of entity in target vhdl file\\
|
84 |
|
|
"@arch\_name@" & : Name of architecture in target vhdl file\\
|
85 |
|
|
"@code\_table\_size@" & : Size of RAM block to be used for code, in words\\
|
86 |
|
|
"@code\_addr\_size@" & : ceil(log2(@code\_table\_size@))\\
|
87 |
|
|
"@data\_table\_size@" & : Size of RAM block to be used for data, in words\\
|
88 |
|
|
"@data\_addr\_size@" & : ceil(log2(@data\_table\_size@))\\
|
89 |
|
|
\end{tabular}\\
|
90 |
|
|
|
91 |
|
|
There's a few more tags; they are described in the script source and the
|
92 |
|
|
usage help.\\
|
93 |
|
|
|
94 |
|
|
These placeholders will be replaced with object code or with data values
|
95 |
|
|
provided by the script command line (see makefiles).\\
|
96 |
|
|
|
97 |
|
|
The script has been used with Python 2.6.2. It should work with earlier
|
98 |
|
|
or later versions but I haven't tested.\\
|
99 |
|
|
|
100 |
|
|
Note: all of the above info is in the script itself, and can be shown
|
101 |
|
|
with command line option --h. Since it will be more up to date than this
|
102 |
|
|
doc, you're advised to read the script.\\
|
103 |
|
|
|