CSIM Examples Directory:

Included in all CSIM installations are sets of examples which are a good starting point for learning to use the tools and develop new models. The examples are located in the csim/demo_examples directory.

Under the demo_examples directory are several CSIM example/demonstration models.

Sub-Directories:

	demo0 - A simplest example.  Two boxes of the same type
		send messages to each other.  (Does not use ATL's
		PM-Lib, just basic CSIM capabilities.)
		This model merely illustrates basic concepts and does not model 
		any real system.

	demo1 - Actual performance model of 72-processor system.
		This model uses an old (simple) version of ATL's
		PM-lib models.  The application is the RASSP
		Benchmark-4, SAR Highclass processing system.

	demo2 - Purely algorithmic model example.  This example
		shows how vector-lib models can be used under CSIM 
		to do purely algorithmic simulation.
		(It does not use ATL's PM-Lib.)  It shows how to
		use some of the graphing and image-display gadgets.

	demo2_slider - A variant of demo2 that includes interactive
		push-buttons and slider-controls in the models.

	demo3 - An example performance model of a 72 processor
		mesh-connected system, with a hierarchical
		application flow-graph.  This model uses an old (simple) 
		version of ATL's PM-lib models.

	demo4 - Another example performance model.  This models a 
		system containing 200 processors through a Raceway
		backplane.  Uses same software application flow-graph as demo3.

	demo6 - "Heat-bugs" biologically motivated computing
		example.  Simple agents interact and move about the screen.

	demo7 - Student examples from the CSIM course.
		Simple queuing modeling library.

	Example_bundles - Four simple examples showing how to use 
		bundle-links.
	
The examples are not necessarily numbered in the best viewing order,
but rather in the order they were created.  They will someday be renumbered.
For now, the recommended sequence is:

	demo0,  demo2_slider,  demo4,  demo1

The demo2 and demo3 are now less important.
Most recently, demo6 and demo7 were added.
The former being fun to watch, the latter being useful for learning the tools.


General Instructions:

All the demos generally fall into the following basic pattern.
Please see the specific instructions for each demo further below.

In general, to explore the examples, do the following:

 1. Perform the necessary setup for your system.
    This sets the needed environment variables for your current 
    session that tells where the CSIM tools are.
    (Usually the person who installed CSIM at your site will
     either set this up to happen automatically in your login file,
     or tell you how to do it, as specified in step four (4) of
     the install proceedure.)

    For Sun's, or anyone using the C-shell:
	Source CSIM's setup file.  The setup file is 
	in the "csim/tools" directory.
		source csim/tools/setup
	(Replace "csim/" with installation directory.)

 2. Copy the respective demo directory to your own area.
	This contains the ".sim" and perhaps ".dfg" files for the
	respective demo model.
	(For example, you could make a copy of all the demo's by:
		  mkdir /tmp/test
		  cp -r $CSIM_ROOT/demo_examples/demo* /tmp/test
         Then move to each respective demo directory:
		  cd /tmp/test/demo0
	)

 3. Move to the respective simulation directory.
	Example:	cd demo2_slider
       For the examples, you generally need to be in the directory where the models are.

 4. Invoke the GUI and open the model.
	Either:		gui model.sim
	Or:		gui
			(then use file/open/open-new-file to open model.sim)
	Where "model.sim" is whatever the model is called. See specifics below.

 5. Peruse or edit the model.  (First time, best to do nothing.)

 6. Build the simulation, by clicking  Tools/Build Simulation  under the Tools menu.

    For demo's 1, 3, and 4, which use the ATL PM-Lib and have software applications:
	Build the routing table:
	  5b. Select  Tools / Build-Routing-Table.
	Schedule the DFG by:
	  5c. Open the DFG under the  File/Open  menu.
	  5d. Build the software under the  Tools/Build-SW  menu.

 7. Run the simulation, by clicking  Tools/Run  under the Tools menu.
      	A simulation control panel will appear, and you can run the
	simulation, change viewing options, etc.

    For demo's 1, 3, and 4, which use the ATL PM-Lib, time-line histories
	will be produced, and you can view them by selecting: 
	Tools/Proc-Timeline and Tools/Proc+Comm-Timeline.


Specific instructions for each demo:


 Demo0 - The model is called: "test.sim".  It is a very simple two-box model.
	 Move to the Demo0 directory:		cd /xx/yy/demo0
	 Build it:
		- Invoke GUI on test-file:      gui  test.sim
		- Select under the menu:        Tools / Build Simulation
	 Run it.  
		- Select under the menu:	Tools / Run Simulation

	 The simulation control panel will appear.  

	 Click  RUN/Continue.

	 You will see the boxes and links flash as the simulation runs.
	 Text printouts from the models will appear in your text window.  
	 (This model does not produce timelines.)



 Demo1 - This is a model of an actual system containing hardware and software.
	 The main hardware model is called:  "arch4.sim".
	 (It includes the pm-lib.)
	 The application DFG is called: "hiclass4.dfg".
	 (This DFG is very simple and contains no hierarchy.)

	 Move to the Demo1 directory:	cd ../demo1
	 To Build:
		Invoke GUI:	gui arch4.sim
		Select:		Tools / Build Simulation
		Select:         Tools / Build Routing Table
		Open DFG:	File / Open / Open New File
		Select:			hiclass4.dfg
		Select:		Tools / Build DFG SW
		(Optional:	Tools / Plot Ideal Timeline )

	   (Subsequent builds need re-do only changed section (HW or SW)).

	  To Run:
		Select: 	Tools / Run Simulation

	 The simulation will be invoked and the control panel will appear.
	 Press Run.

	 While the simulation is running, you can navigate the box hierarchy 
	 to see what activities are happening down inside hierarchical boxes.
	 However, we recommend flattening the hierarchy of some or all of 
	 the boxes by selecting boxes (clicking or dragging a rubber-band 
	 around them so they are selected with tick-marks), and then clicking 
	 menu:  View / Flatten-Selected-Subgraphs  or  ^f. 

	 To speed-up the animation, you can reduce the update of the
	 time-display by selecting:
	  Animation / Time-Display / Update-Once-Every-1,000-Time-Advances
	 Or turn the animations off completely.

	 After running the simulation (or even during), you can view the
	 resulting processing-activity timeline by:
		Select:		Tools / Plot Proc Timeline
	 Or, to see communication events superimposed:
		Select:		Tools / Plot Com+Proc Timeline



 Demo2 - This is a purely functional model (no-hardware/software distinction).
	 The main model is called: "demo2.sim".
	 (It includes library files for the math and vector library
	  elements.)  Build the simulation and run it.  You can navigate
	 the hierarchy as it runs.

	 Move to the Demo2 directory:	cd ../demo2
	 To Build:
                Invoke GUI:     gui demo2.sim
		Select:		Tools / Build Simulation
	 To Run:
		Select: 	Tools / Run Simulation

	 The simulation will be invoked and the control panel will appear.
		Click:		RUN/Continue

	 You may wish to turn animation options on, to see processing
	 activity in the diagram. 

	 Select:  Animation / Animation-Types / 1.Nodes-Individual-Events
	 and:     Animation / Animation-Types / 1.Links-Individual-Events

	 (This model does not produce timelines.)



 Demo2_slider - This is a highly interactive purely functional model.
	 (It contains no distinction between hardware or software elements.)
	 The main model is called: demo2_slider.sim.
	 (It includes library files for the math and vector library
	  elements.)  Build the simulation and run it.  You can navigate
	 the hierarchy as it runs.

	 Move to the Demo2_slider directory:	cd ../demo2_slider
	 To Build:
                Invoke GUI:     gui demo2_slider.sim
		Select:		Tools / Build Simulation
	 To Run:
		Select: 	Tools / Run Simulation

	 The simulation will be invoked and the control panel will appear.
		Click:		RUN/Continue

	 You can interact with the model as it runs by moving the slider
	 controls.  These will vary the frequencies of the waveform generators.
	 You will see this reflected in the oscilloscope displays.

	 (This model does not produce timelines.)



 Demo3 - The hardware model is called:  "demo3.sim".
	 (It contains topology and behavior descriptions all in one file.)
	 The application DFG is called: "demo3.dfg".
	 (This DFG contains hierarchy.)

	 Move to the Demo3 directory:	cd ../demo3
	 To Build:
		Invoke GUI:	gui demo3.sim
		Select:		Tools / Build Simulation
		Select:         Tools / Build Routing Table
		Open DFG:	File / Open / Open New File
		Select:			demo3.dfg
		Select:		Tools / Build DFG SW
		(Optional:	Tools / Plot Ideal Timeline )
	   (Subsequent builds need re-do only changed section (HW or SW)).

	 Alternate variations of the basic DFG are included in files:
	 "demo3b.dfg" and "demo3c.dfg".  These basically have more
	 iterations of data and produce more interesting visualizations
	 because the simulations driven by them run longer.  But the basic
	 "demo3.dfg" is good for producing a simple time-line graph.

	 To Run:
		Select: 	Tools / Run Simulation

	 The simulation will be invoked and the control panel will appear.
		Click:		RUN/Continue

	 After running the simulation (or even during), you can view the
	 resulting processing-activity timeline by:
		Select:		Tools / Plot Proc Timeline
	 Or, to see communication events superimposed:
		Select:		Tools / Plot Com+Proc Timeline



 Demo4 - The main hardware model is called:  "arch.sim".
	 (It includes various PM-Lib models, such as bus.sim and pe.sim
	  that are kept in separate files, which is actually the more
	  traditional way it is done on real projects).
	 The application DFG is called: "app1.dfg".

	 Move to the Demo4 directory:	cd ../demo4
	 To Build:
		Invoke GUI:	gui arch.sim
		Select:		Tools / Build Simulation
		Select:         Tools / Build Routing Table
		Open DFG:	File / Open / Open New File
		Select:			app1.dfg
		Select:		Tools / Build DFG SW
		(Optional:	Tools / Plot Ideal Timeline )
	   (Subsequent builds need re-do only changed section (HW or SW)).

	  To Run:
		Select: 	Tools / Run Simulation

	 The simulation will be invoked and the control panel will appear.
		Click:		RUN/Continue

	 This model contains special calls to animate special events on
	 the links and in the boxes.  So you do not have to change the
	 animation modes.  The architecture was pre-flattened for 
	 demonstration purposes, so you do not have to flatten this one.

	 Because of the crowdedness of the architecture, you will want to
	 turn-off the port-names.  Select:  View / Show-Port-Names.

	 Explanation of link animation:
	  In this model of a Mercury Raceway network, the modeler 
	  chose to show new attempts for connections through the network
	  by lighting links along a requested path in yellow.  (They are
	  normally violet when unused.)  If the requested path is successfully
	  granted, the links are turned green to indicate the presence of
	  data flowing through them.  If the requested path cannot be
	  granted because of contention with another ongoing communication
	  on a link, the contented link will be high-lighted red to indicate
	  contention, the requested path will be returned to violet until
	  the next re-try.  

	  As the simulation model runs, you will see the links blinking, 
	  changing colors, data flowing, and occasional red flashes as 
	  contentions occur.  If you stop the simulation, or step through it
	  by a small amount, perhaps 10 or 20 time-units at a step, you can
	  catch individual communications being made, contented, and broken
	  as they complete.

	 After running the simulation (or even during), you can view the
	 resulting processing-activity timeline by:
		Select:		Tools / Plot Proc Timeline
	 Or, to see communication events superimposed:
		Select:		Tools / Plot Com+Proc Timeline


 Demo6 - The main model is called:  "heat_bugs.sim".
	 This is a simple example model of the SWARM-inspired "heat-bug".
	 It is an artificial-life experiment motivated by Univ. Santafe.
	 The heat-bugs operate independently according to their own rule-set.
	 When placed in a population with other heat-bugs, they interact so
	 as to optimize their own individual goals.
	
	 The "heat-bug" is an independent agent that "desires" a specific
	 temperature set_point, for example, 10-degrees.  Each heat-bug
	 generates a small amount of heat.  To reach the desired temperature,
	 the heat-bugs need to cluster near each other to gain heat from
	 their neighbors.  However, if they get too close, they get too
	 warm.  So they must achieve a proper distance to regulate their
	 heat.  
 
	 Their initial rule-set is simple.  If too cold or warm, i.e.
	 if satisfaction is low, then move in a random direction.
	 If the move resulted in a satisfaction improvement, then keep
	 it.  Otherwise, reverse the move.

	To use this model:
	        1. Copy it to your own directory.
	        2. Follow comm-line or GUI instructions below.

	From Command-line:
	        To Build Sim:
	                csim heat_bugs.sim
	        To Run:
	                sim.exe

	From GUI:
	        First, go into GUI:
	                gui heat_bugs.sim
	        To Build Sim:
	                Click: Tools / Build Sim
	        To Run:
	                Click: Tools / Run Sim


 Demo7 - Student example models from the CSIM course.
	This document: Instructions, takes you
	through a series of steps to building some simple models.


 Example_bundles - Four examples of using bundles.
	Use as:
	        gui bundle_example1.sim
	         /Tools/Build
	         /Tools/Run
	etc.

	When looking at these examples in the GUI, try double-clicking on 
	the bundle to see inside it.

	Note:  These are super-simple examples, having only a
	few bundles, and making use of really only one strand within
	the bundle.  It'd be nice to have better examples someday.  
	But this basically shows how to do it.


Further:

The above examples show how to run previously created models (I.E. canned demonstrations). For help in learning how to create your own models from scratch, using the Performance Model Library for Hardware/Software modeling, as shown in demos 1, 3, and 4, please see: Learning to use Perf. Mod. Lib - A New User's Guide to Creating a Model

Short-Cuts
You don't have to use the GUI to do everything. Some find it easier to build and run simulations from the command-line or from a script-file. See Quick Textual Short-cuts to find how to do the same thing from your keyboard.