Code Walkthrough
The chapter describes the code that was generated to produce the model created in the example Example: Creating a Multi-Coupled Line".
The source shape definition for the model is a rectangle with two ports and two control lines.

Three controls specify the model:
- A stretch control for length that acts on the rectangle and both pins.
- A stretch control for width that acts only on the rectangle.
- A repeat control for the number of lines to create that acts on the rectangle and both pins.
The actual defined controls, as seen in the Detail list from the Viewer dialog box, look like:
| Control: | Stretch |
| Direction: Both | |
| Distance: length | |
| Offset: 100.0 mil | |
| Control: | Stretch |
| Direction: Both | |
| Distance: width | |
| Offset: 50.0 mil | |
| Control: | Repeat |
| Direction: In X | |
| X Number: number | |
| X Distance: width+space |
The Generated Code
The model header.

This statement makes sure that the model is loaded into the proper AEL vocabulary. Since AEL code in the ~/networks directory is by default loaded into a different vocabulary, this statement makes sure that existing models and new models being developed all reside in the same vocabulary.
#voc(CmdOp)
Some comments to help identify what the different variable types are.
/* Datatypes: */ /* l_ primitive list from repeat */ /* p_ primitive to modify */ /* i_ initial primitive definition */ /* r_ primitive rotation */ /* w_ primitive width */
The declarations of the variables for each shape. The comments help indicate what the shape is and what layer it came from.
/* Polygon (from a Rectangle) on mask 1 */ decl l_4127E1E8; decl p_4127E1E8; decl i_4127E1E8; /* Port */ decl l_412BBD20; decl p_412BBD20; decl i_412BBD20; decl r_412BBD20; /* Port */ decl l_412BB7E8; decl p_412BB7E8; decl i_412BB7E8; decl r_412BB7E8;
This section initializes the above variables with the actual shape data.
/********************************************************/
/********************************************************/
defun pam_init_couple()
{
/* Polygon (from a Rectangle) on mask 1 */
i_4127E1E8 = {
{-0.00127, -0.000635},
{0.00127, -0.000635},
{0.00127, 0.000635},
{-0.00127, 0.000635},
{-0.00127, -0.000635} };
/* Port */
i_412BBD20 = {
{-0.00127, 0} };
r_412BBD20 = 90;
/* Port */
i_412BB7E8 = {
{0.00127, 0} };
r_412BB7E8 = -90;
The variable initialization is completed. A test is done to verify that the data is of type real, and the initial data is copied into the primitive structure, which is where actual modifications will take place.
l_4127E1E8 = list(); if (array_type(i_4127E1E8, "integer")) i_4127E1E8 = convert_array(i_4127E1E8, "real"); p_4127E1E8 = i_4127E1E8; p_4127E1E8[0,0] = p_4127E1E8[0,0]; /* Force array copy */ l_412BBD20 = list(); if (array_type(i_412BBD20, "integer")) i_412BBD20 = convert_array(i_412BBD20, "real"); p_412BBD20 = i_412BBD20; p_412BBD20[0,0] = p_412BBD20[0,0]; /* Force array copy */ l_412BB7E8 = list(); if (array_type(i_412BB7E8, "integer")) i_412BB7E8 = convert_array(i_412BB7E8, "real"); p_412BB7E8 = i_412BB7E8; p_412BB7E8[0,0] = p_412BB7E8[0,0]; /* Force array copy */ }
The actual control operations are performed on the data. For each control, several steps are done:
- Load construction line information. If the control uses a construction line as a reference, the data for that line is sent to the control.
- Evaluate equation. For each control, user-defined equations for each parameter are evaluated to generate a single real value.
- Call control. For each shape acted on, the control is called with that shape's data, and all control parameters.
All data is passed as name/value pairs, so that specific parameter order is not required. This also makes the program very flexible.
/********************************************************/
/********************************************************/
defun pam_process_couple(length,width,number,space)
{
decl pam_rep;
decl pam_var;
pam_set_cline_info(
PAM_LINE_X1, 0,
PAM_LINE_Y1, -0.001814322,
PAM_LINE_X2, 0,
PAM_LINE_Y2, 0.001814322,
PAM_LINE_DX, 0,
PAM_LINE_DY, 1,
PAM_LINE_SLOPE, 9000000000);
decl p_length_1 = length;
decl p_offset_1 = 100.0 mil;
pam_do_stretch(
PAM_COMMON_INIT, i_4127E1E8,
PAM_COMMON_DATA, p_4127E1E8,
PAM_COMMON_PRIM, PAM_POLYGON_TYPE,
PAM_STRETCH_DIRECTION, 3,
PAM_STRETCH_LENGTH, p_length_1,
PAM_STRETCH_OFFSET, p_offset_1);
pam_do_stretch(
PAM_COMMON_INIT, i_412BBD20,
PAM_COMMON_DATA, p_412BBD20,
PAM_COMMON_PRIM, PAM_PORT_TYPE,
PAM_STRETCH_DIRECTION, 3,
PAM_STRETCH_LENGTH, p_length_1,
PAM_STRETCH_OFFSET, p_offset_1);
pam_do_stretch(
PAM_COMMON_INIT, i_412BB7E8,
PAM_COMMON_DATA, p_412BB7E8,
PAM_COMMON_PRIM, PAM_PORT_TYPE,
PAM_STRETCH_DIRECTION, 3,
PAM_STRETCH_LENGTH, p_length_1,
PAM_STRETCH_OFFSET, p_offset_1);
pam_set_cline_info(
PAM_LINE_X1, -0.002561844,
PAM_LINE_Y1, 0,
PAM_LINE_X2, 0.005102352,
PAM_LINE_Y2, 0,
PAM_LINE_DX, 1,
PAM_LINE_DY, 0,
PAM_LINE_SLOPE, 0);
decl p_length_2 = width;
decl p_offset_2 = 50.0 mil;
pam_do_stretch(
PAM_COMMON_INIT, i_4127E1E8,
PAM_COMMON_DATA, p_4127E1E8,
PAM_COMMON_PRIM, PAM_POLYGON_TYPE,
PAM_STRETCH_DIRECTION, 3,
PAM_STRETCH_LENGTH, p_length_2,
PAM_STRETCH_OFFSET, p_offset_2);
This procedure sends the shape data off so the actual graphics can be created in the Layout window. If the shape was copied by a Repeat or Polar control, the list of shapes is sent. If it is still a single shape, only the one shape is created.
/********************************************************/
/********************************************************/
defun pam_output_couple()
{
de_set_layer(1);
if (is_list(l_4127E1E8))
depam_output_polygon_list(l_4127E1E8);
else
depam_output_polygon(p_4127E1E8);
de_set_layer(3);
de_set_layer(1);
if (is_list(l_412BBD20))
depam_output_port_list(l_412BBD20, r_412BBD20);
else
depam_output_port(p_412BBD20, r_412BBD20);
if (is_list(l_412BB7E8))
depam_output_port_list(l_412BB7E8, r_412BB7E8);
else
depam_output_port(p_412BB7E8, r_412BB7E8); }
This short procedure is called by the Advanced Design System to get the list of user-defined parameter names for this model.
/********************************************************/
/********************************************************/
defun pam_couple_parm_info()
{ decl parms;
parms = "length,width,number,space";
return(parms); }
This is the start of the main entry-point for the model. The first thing it does is check all the parameters and make sure they are actual values, not strings.
/********************************************************/
/********************************************************/
defun pam_couple(length,width,number,space)
{
if (is_string(length))
length = evaluate(length);
if (is_string(width))
width = evaluate(width);
if (is_string(number))
number = evaluate(number);
if (is_string(space))
space = evaluate(space);
de_set_global_db_factor();
This checks the version of this compiled model with the current version of the Graphical Cell Compiler. This is a check to identify macros that were created with previous versions. If there is any reason why the old macro will not work with the current version a message will be issued telling the user to re-compile the macro.
if (\!pam_verify_model(3)) return;
The actual work gets done here.
pam_init_couple(); pam_process_couple(length,width,number,space); pam_output_couple(); }
A comment ends the file.
/\* end of file \*/
Privacy
Statement
|
Terms of Use
|
Legal |
Contact Us
|
© Agilent 2000-2008 ![]()