sim_cpu.html
2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<html>
<head>
<title>Running CPU-based Simulation</title>
</head>
<body>
<h1>
<p align="center">
Running CPU-based Simulation
</p>
</h1>
<p>
First build the simulator: assuming you have done everything required
to build sim.ipc (hw/chip/vsim/sim.ipc), you can build sim.cpu using<br>
<blockquote>
make sim.cpu
</blockquote>
<p>
Setup initialization files: <br>
<blockquote>
Boot-rom: the code is read from the ascii-encoded binary
file hw/chip/vsim/tests/brom.dat. The file format is one big-endian 32-bit
word, which represents a cpu instruction, per line. On simulator startup
this file is loaded into boot-rom. The means the code must be linked to
0xbfc00000.
</blockquote>
<blockquote>
Virage flash: likewise, the virage flash initialization
files reside in hw/chip/vsim/v[012].dat. The file v2.dat is auto-loaded
to it's associated sram (i.e., the RECALL operation is automatic).
</blockquote>
<blockquote>
External Flash: external flash is initialized according to the contents of
hw/chip/vsim/External_File.txt (I think it's actually from where the simulator
is run, so this is assuming the simulator is run from where it is built).
This file contains consecutive bytes of ascii-encode binary, seperated by
spaces and newlines. The full 528B are required to initialize a flash page,
which contains the 512B directly addressable data and 16B OOB data. Comments
in the style "// comment text" are admissable on separate lines, so this file
commonly looks like: <br><br>
<blockquote>
// page 0 <br>
nn nn nn nn nn nn nn nn nn nn nn nn nn nn nn nn <br>
nn nn nn nn nn nn nn nn nn nn nn nn nn nn nn nn <br>
... <br>
nn nn nn nn nn nn nn nn nn nn nn nn nn nn nn nn <br>
<br>
// page 1 <br>
... <br>
</blockquote>
where the "nn" are a hex byte, and there would be 33 lines, each containing
16 "nn" numbers, to initialize each page.
This file is read into all devices, so they all hold the same data.
</blockquote>
Running the simulator: <br>
sim.cpu +cbus_mon +cpu_mon > cpu.log
<p>
Only i/o is output into cpu.log (sysad bus requests), so to debug
you need to output info to some known port.
<p>
To keep the simulator from immediately powering down you must write
to the GPIO register accordingly. An assembly code snippet to do this
is:
<blockquote>
li t0, (1<<PI_GPIO_ENABLE_SHIFT)|1 <br>
sw t0, PHYS_TO_K1(PI_GPIO_REG) <br>
</blockquote>
<p>
In addition, the simulator will exit when the GPIOs are written to
power-down, as in:
<blockquote>
lw t0, PHYS_TO_K1(PI_GPIO_REG) <br>
and t0, t0, 0xfffffffe <br>
sw t0, PHYS_TO_K1(PI_GPIO_REG) <br>
</blockquote>
<p>
It may be useful to look in the boot-code directory makefile to
see how the brom.dat file can be generated
(sw/bbplayer/lib/bbboot/Gnumakefile).
</body>