Hints for using General Block Library


1. How to connect more that two boxes together?

Use Junction box. (Found under Miscellaneous.) This connects any number of lines in and/or out. (Previously, there were the Split and Join boxes, but these were obsoleted by Junction which is general-purpose, and supports any number of connections. Also, with Junction, the port-names can be anything, as long as they are unique.)

Another hint - Simplify your diagrams by shrinking the Junction boxes so they almost disappear.

2. Multiple Math Expressions?

Using 5-input_expression, if I have several instances of this type, how do I specify a separate mathematical expression for each? It seems that if I change the code for one, all of the instances reflect the change.
Good question.  You are correct, that changing the code which all point at
will change all of them.  Two methods come to mind.

1.) The first method is to generate a variant model definition for each function.
For example, make a copy of the model for 5-input_expression,
but change the name of the definition to something else, and define
your first function there.  Then set your box to that new type.
Repeat for each of your other functions.

    Here are some hints on the button-pushing to do it:
     1. Add a new box.  Make it's type be "5-input_expression".
     2. Open the box's Properties and select "Edit Text".
        a. In the text editor, change:
                DEFINE_DEVICE_TYPE:  5-input_expression
           to:
                DEFINE_DEVICE_TYPE:  My_ExpressionA
        b. Edit the expression to be your function.
        c. Save to a new file, like myexp.sim, and exit the text editor.
	     (In Vi, :wq myexp.sim)
        d. Answer Do Not Modify.
     3. Import your new file by: File / Import / By Reference - myexp.sim.
     4. In the box's Properties dialog, set the Type to My_ExpressionA.
     5. Repeat from (1) for your other functions.

Note that with this method, you do not change the original model,
but rather, create new box-models; one for each function.

2.) The second method would be to create only one new model, in which 
you "switch" on an instance-attribute to any of your custom functions.
Example:
    1. Create a variant model as above, say "My_Expressions".
    2. Within the function area, place:
       {
        int funct_num;
        char value[50];
        CSIM_GET_ATTRIBUTE("function_number", value, 50);
        funct_num = atoi(value);
        switch (funct_num)
         {
          case 1:   out = a+b*c;  /* expression 1 */
           break;
          case 2:   out = 2 * a;  /* expression 2 */
           break;
          case 3:   out = a*b/c;  /* expression 3 */
           break;
          default: CSIM_POPUP("Undefined function number.");
         }
       }
    3. Add your function boxes to your diagram, and set their type 
        to be "My_Expressions", but for each set the "function_number" 
        attribute to be 1, 2, ... as appropriate.