Cell Simulator

NOT DONE YET

So far all the programs we have run are under "Linux mode". When you click the 'Go' buton the simulator loads up a basic Linux environment and then you run your program. In this tutorial we will go over how to run a program without loading up a Linux environment.

In the directory where you run '../run_gui' if you open up '.system.tcl' you will see the startup TCL script for Mambo. Luckily that script is nicely commented, but for completeness I'll post it here:

#------------------------------------------------------------------------
#
#   IBM Software
#   Licensed Material - Property of IBM
#   (C) Copyright International Business Machines Corp. 2004
#   All Rights Reserved.
#
#   U.S. Government Users Restricted Rights - Use, duplication or
#   disclosure restricted by GSA ADP Schedule Contract with
#   IBM Corp.
#
#------------------------------------------------------------------------
#  .systemsim.tcl
#
#  This is the default toplevel script that is run when using the CLI.
#------------------------------------------------------------------------

set IMAGES $env(IMAGES_DIR)/cell

# Initialize the systemsim tcl environment
source $env(LIB_DIR)/cell/mambo_init.tcl

# Configure and create the simulated machine
define dup cell myconf

# mode is bogus
myconf config cider be_mode 6
# bridge is none
myconf config cider bridge_type 0

# Call the config_hook proc if it is defined to modify the config
if {[string length [info procs config_hook]] > 0} {
    config_hook myconf
}

define machine myconf mysim

# Uncomment this to enable automatic starting of the default emitter readers
#EmitterReaders::init_default mysim linux_boot

# Start the GUI if -g option was given
MamboInit::gui $env(LIB_DIR)/cell/gui/gui.tcl

# Find the sysroot_disk to use
if {[file exists ./sysroot_disk]} {
   set sysrootfile ./sysroot_disk
}  elseif {[file exists $IMAGES/sysroot_disk]} {
   set sysrootfile $IMAGES/sysroot_disk
} else {
   puts "could not find sysroot_disk file"
   exit
}

# Find the OS image
if {[file exists ./vmlinux]} {
   set imagefile ./vmlinux
}  elseif {[file exists $IMAGES/vmlinux]} {
   set imagefile $IMAGES/vmlinux
} else {
   puts "could not find linux image file"
   exit
}

# Construct the emulated device tree
build_firmware_tree

# Uncomment the line below to enable bogus network support
#bogusnet::init 172.20.0

# Set boot parameters if desired
of::set_bootargs "lpj=8000000 console=hvc0 root=/dev/mambobd0 rw"

# Load the OS
mysim load vmlinux $imagefile 0x1000000

# Setup the bogus disk that Linux will use
mysim bogus disk init 0 $sysrootfile newcow sysroot_disk.cow 1024

# Back to the prompt

Notice that the linux kernel and system are already set up for you. Just so you know you are looking at the proper script, add mysim go at the end and see what happens when you run the simulator.

The simulator should atomatically load up the Linux environment, as if you actually pressed the 'Go' button from the GUI. Be sure to remove your addition before continueing.

Your current directory should be something like: '(MAMABO_DIR)/systemsim-cell/run/cell/linux' change to '(MAMABO_DIR)/systemsim-cell/run/cell/standalone'. If you run the program '../run_gui' then the program will come up, but hitting 'Go' will have simulator simulate essentually nothing. Anyways stop the program. To run a program the simulator must load an SPU with a simple SPU program. Luckily the helloworld example provides these. At the command prompt (in the terminal where you started Mambo, type in 'mysim spu 0 load (MAMBO_DIR)/Code/helloworld/spu/hello_spu'. Now type in the command 'mysim go'. The simulator will pause for awhile then come back with something like 'WARNING: 19740800000000: No processor activity for 3 seconds
WARNING: 19740800000000: ... Stopping simulation
19740800000000: ** Execution stopped: No activity in 3 secs, **

If you remember, the hello world program actually put "hello World onto the screen". Unfortunately, the simulator is can't do that in standalone mode. So how do you check it worked? Well, in in the GUI, expand the SPE0 tree, then double click on 'SPU Core'. UP come the register values. Notice they aren't 0 (whihc is the default). Unfortunately, this is all you know for right now. Basically, that something did work. The next tutorial will go more in depth about the GUI TCL scripts and working with standalones.