sim_cpu.html 2.75 KB
<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 &gt 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&lt&ltPI_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>