Note: This is a general Getting Started. Please refer to the User Guides and Installation for each platform.
For 64 Bit MSYS click here.
Download CapsimTMK from here. You can run CapsimTMK from the BIN directory, $CAPSIM/BIN/capsim. Example topologies are included the APPLICATIONS directory. Each application has a README file. To start capsim in the interative mode type:
Set the environment variable CAPSIM to the directory where CapsimTMK resides.
Creating Capsim and Adding Models
CAPSIM provides the utility to add blocks(stars) to the library through the use of the bash shell program precapsim.sh. This is a separate program from CAPSIM and is run from the UNIX/LINUX shell not from inside CAPSIM. Another program, blockmaint.pl, is also available for library maintenance.
the bash shell script precapsim.sh provides all the functionality necessary to create your own personalized version of CAPSIM.
Create a new directory any where on your system. For example WORK. You will be creating blocks and subroutines to incorporate into Capsim in this directory.
Suppose that CapsimTMK is installed in the following directory:
Then setup the environment variable CAPSIM as follows:
Next make the directory you just created the current directory and execute the following:
bash $CAPSIM/TOOLS/precapsim.sh -l
(-l is l as in link).
The precapsim.sh shell command will create all the necessary directories and copy all files including Makefiles and scripts from the $CAPSIM directory. It will also create the capsim executable in the current directory.
Following the precapsim.sh execution type:
To execute capsim type:
You will be in the Capsim TMK interactive environment. Go ahead and quit.
The shell command creates the directories BLOCKS, SUBS, and include. A dummy subroutine and block(star) are also created.
A key point is that the precapsim.sh also copies a Makefile into the current directory. With this Makefile it is very easy to build capsim using your blocks(stars) and subroutines. All you need to do is place a block in the BLOCKS directory and, in the main directory (WORK), type make (twice if first time block is added).
View the Makefile to see how this happens. The BLOCKS directory has a file called blocks.mak . This Makefile has all the necessary dependencies to create the C code from the Block ".s" code. It adds the block to the block database blockdatabase.dat and creates the file krn_libblock.c and the library libblock.a with the object files for the blocks. This is all done automatically. The file blocks.mak itself is created by a perl script blockmake.pl in the $CAPSIM/TOOLS directory. This perl script, given the name of the blocks or *.s, creates a make file for the blocks: blocks.mak.
For more info on the block database and block maintenance see the CapsimTMK document on adding blocks.
The subroutine directory SUBS also has a Makefile and any C subroutine will be compiled and added to the libsubs.a library and linked to capsim.
The include directory is where common include files to the blocks in the BLOCKS and C code in the SUBS directory should be placed. The Makefiles use this directory to search for include files when compiling the blocks and subroutines.
So in a nutshell it is real easy to get started. For the first time just execute precapsim.sh followed by make. Afterwords just type make to update. Just place blocks in the BLOCKS directory and the subroutine C code in the SUBS directory.
When running make, check for errors and correct them. For block compile errors, refer to the C code. Make sure you fix the corresponding .s code.
You can use gdb and ddd to debug the block source code.
To setup CAPSIM in order to add your own blocks see the CAPSIM Tutorial.
Here is a quick guide:
- Create a working directory anywhere. For example call it WORK.
- Change directory to WORK
- Type ( Do this once!)
bash $CAPSIM/TOOLS/precapsim.sh -l
That is "l" as in link. (If using MSYS use "source" instead of "bash").
- The precapsim.sh bash shell will do all the work. It will create
the BLOCKS dierctory and copy a dummy block to this directroy.
It will create the SUBS directroy. It will copy a Makefile
to the WORK directory. The Makefile will be used to maintain and
add Blocks and Subroutines to your custom CAPSIM.
- You must type "make"
- A CAPSIM executable "capsim" will be created in the WORK directory (With MSYS "capsim.exe").
- To run CAPSIM type
- To run CAPSIM with TCL command interpretor active type:
- To run Capsim in text mode type:
Creating Blocks Using the Block Generation Tool
To create a block and add it to Capsim do the following (detailed and step by step):
- Change directory to the BLOCKS directory in the WORK directory:
- Type the following to bring up the Block Generation Graphical Tool:
wish $CAPSIM/TOOLS/blockgen.tcl &
This will also send it to the background so we can edit
the generated block.
- Select Source Block and set a name (for example xsource).
- Click on Generate Block.
- The block is generated. View the file:
Or using the name you provided.
- Change directory to WORK
- Type make TWICE!
This is only necessary when you add a block or multiple blocsk.
Once a block is added type make once when you change a blocks
source code or asubroutines source code.
- Bring up CAPSIM
block xsource block prfile connect xsource0 prfile0 store test
- Run the simulation.
- You should see a print out of a constant DC source.
- Save your topology.
- Now lets change the source code for "xsource.s".
- Change directory to BLOCKS.
- Edit "xsource.s" or your block name. Change the following in the MAIN_CODE section:
* output the sample
- This will output a parabola.
- Save the block.
- Change directory to WORK and type make.
- Run capsim. Open the saved topology. Run the simulation.
You should see a print of a parabola.
Store in a file and plot.
- If you run into any errors make sure you check all the
messages for compilation errors.
One thing you can do is go to the BLOCKS directory and type
make -f blocks.mak
Check for errors. Correct. Then type make again. When all
errors have been corrected type:
See the CAPSIM Tutorial on using the Block Generation tool.
Its easy to create new blocks and add them to CAPSIM.
Adding C code and calling libraries and subroutines is straight forward.
Finally, if you plan on linking to additional libraries you have to:
1- create a copy of precapsim.sh
2- Add the library to the link path (see the last line in precapsim.sh)
3- Edit your Makefile to use the modified precapsim.sh file.