MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise,...

20

Transcript of MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise,...

Page 1: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided
Page 2: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

MBP

MBP Script Programming Manual

Page 3: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

2 MBP Script Programming Manual

Copyright Notice and Proprietary Information Copyright © Agilent Technologies, Inc. 2004, 2011. All rights reserved. This software and documentation contain confidential and proprietary information that is the property of Agilent Technologies, Inc. The software and documentation are furnished under a l icense agreement and may be used or copied only in accordance with the terms of the license agreement. No part of the software and documentation may be reproduced, transmitted, or translated, in any form or by any means, electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided by the license agreement.

Right to Copy Documentation

The license agreement with Agilent Technologies permits licensee to make copies of the documentation for its internal use only. Each copy shall include all copyrights, trademarks, service marks, and proprietary rights notices, if any. Licensee must assign sequential numbers to all copies.

Disclaimer

AGILENT TECHNOLOGIES, INC. AND ITS LICENSORS MAKE NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

Registered Trademarks (®)

Agilent, Model Builder Program, MBP, Model Quality Assurance, MQA, Advanced Model Analysis, AMA, Proximity Quality Assurance, PQA are registered trademarks of Agilent Technologies, Inc.

Page 4: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

3 MBP Script Programming Manual

Overview ................................................................................................... 4 Data Definition .......................................................................................... 7 Optimize ................................................................................................. 15 API for Model Parameter ........................................................................ 16 Build Extraction Flow .............................................................................. 17 Appendix ................................................................................................. 18

Page 5: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

4 MBP Script Programming Manual

Overview MBP Script is based on Java, and supports most of the Java expressions

(jdk1.4), except class definition. With the script, you can transform data, define plots, do optimization, and build extraction flow.

Script Editor MBP provides an editor for script. Click ScriptScript Project to start the

editor.

Script in MBP is organized by project. On the left of MBP script project window, the project pane has a

hierarchical tree structure. On different nodes, you can create script file for different kinds of usability.

Menu bar Project pane Menu bar Edit pane

Page 6: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

5 MBP Script Programming Manual

Steps to create a new script file: 1. Select the node: “prog”. 2. Right click the node and select NewFile on the pop-up menu. 3. Input a name to define a script file. 4. Select the newly created file. 5. Write the following code on the edit pane.

.

6. Click and view the message window in MBP. “Hello world” is

printed.

System.out.println(“Hello world”);

Page 7: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

6 MBP Script Programming Manual

Function Definition You can define a script function. Here is an example: Line 1-7: Define a function called “sum”. It returns the sum of values. Line 8: Create an array:1,2,3,4,5 Line 9: Print the result of 1+2+3+4+5 You can also pass a function to another function as a variable, and use “sfunc” as the type of the variable. Line 1-3: Define a function “sqr”: sqr(v) = v2 Line 4-6: Define a function “sqrt”:sqrt(v) =√v

Line 7-14: Define a function “sum”: sum(v,f) = � f(v[i])𝑛𝑖=0

Line 15: Create an array:1,2,3,4,5

Line 16: Print the result of � sqr(v[i])𝑛𝑖=0

double sqr(double v){ return v*v; } double sqrt(double v){ return Math.sqrt(v); } double sum(double[] values,sfunc f){ double s = 0; for(int i = 0;i<values.length;i++){ double v = f(values[i]); s += v; } return s; } double[] v = new double[]{1,2,3,4,5}; System.out.println(sum(v,sqr));

double sum(double[] values){ double s = 0; for(int i = 0;i<values.length;i++){ s += values[i]; } return s; } double[] v = new double[]{1,2,3,4,5}; System.out.println(sum(v));

1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8 9

10 11 12 131415 16

Page 8: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

7 MBP Script Programming Manual

Data Definition After defining data, you can perform the following tasks: 1. Define plots 2. Re-organize or transfer other data 3. Define the cost function to do optimization

Quick Start To create a data file and a plot file, follow these steps: 1. Select a bsim3v3 model, and load the demo measurement data. 2. Select the node “data” and click NewData on the pop-up menu to

create a data script file. 3. Replace the code with the following: 4. Select the data file you created and click Show Data Table on the

pop-up menu. You get a table that lists the data of “ids_vgs_vbs”.

5. Select the data file and click NewGraph on the pop-up menu to

create a graph script file. 6. Click View to receive the plots of “ids_vgs_vbs”.

DATA load(sfunc select){ DATA m = select("ids_vgs_vbs"); return m; }

1 2 3 4

Page 9: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

8 MBP Script Programming Manual

Data Organization

Data as Table

There are many kinds of data in MBP. You can describe all MBP data in a table. For example, the following table lists the data for “ids_vgs_vbs”.

A table consists of lines. Each line has: 1. Input columns (W,L,T,Vds,Vbs,Vgs) 2. Output columns (Ids) Each line is called a “POINT”, because you can display it as a point on the graph.

Data as Tree

Each table can be divided into several sub tables with some rules. Each sub table can be further divided. Thus, a table can be transformed to a tree.

Output Input W L T Vds Vbs Vgs Ids

10u 2u 25 0.05 -1.125 1.6 6.5965E-5

10u 2u 25 0.05 -1.125 1.65 6.8524E-5

10u 2u 25 0.05 -1.5 0 6.72E-12

10u 2u 25 0.05 -1.5 0.05 6.92E-12

10u 2u 25 0.05 -1.5 0.1 7.17E-12

POINT

Page 10: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

9 MBP Script Programming Manual

How to organize a table to a tree

There are three kinds of functions to do the organization: 1. splitBy(exp1,exp2,exp3…)

Divide to several tables. Points in each table have same value of exp1,exp2,exp3…

2. splitIgnore(var1,var2,var3…) Divide to several tables. Points in each table have same inputs, except var1,var2,var3…

3. selectBy(expression) Select the points in each table whose expression value is not 0.

4. sortBy(exp1,exp2,exp3…) Sort each sub table with exp1,exp2,exp3…

Here is an example: Click Show Data Table to see the results.

Table

Sub Table

Sub Table

Sub Table

Sub Table

Sub Table

Sub Table

Sub Table

DATA load(sfunc select){ DATA m = select("ids_vgs_vbs"); m = m.build("splitBy(vgs*vbs,vds)"); return m; }

1 2 3 4 5

Page 11: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

10 MBP Script Programming Manual

Examples:

DATA load(sfunc select){ DATA m = select("ids_vgs_vbs"); m = m.build("splitIgnore(vgs,vbs).splitBy(vbs)"); return m; }

1 2 3 4 5

DATA load(sfunc select){ DATA m = select("ids_vgs_vbs"); m = m.build("splitIgnore(vgs).splitBy(vgs>1)"); return m; }

1 2 3 4 5

DATA load(sfunc select){ DATA m = select("ids_vgs_vbs"); m = m.build("splitIgnore(vgs).splitBy(vgs>1).selectBy(vgs==max(vgs))"); return m; }

1 2 3 4 5

Page 12: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

11 MBP Script Programming Manual

Example of sparse vgs

With this script, you get a new data with fewer vgs points, as shown in the graph. How does it work? 1. splitIgnore(vgs)

Divide the data to several curves.

2. splitBy(int(vgs/0.5))

Divide each curve to several groups: int(vgs/0.5)=0, int(vgs/0.5)=1, int(vgs/0.5)=2, int(vgs/0.5)=3…

DATA load(sfunc select){ DATA m = select("ids_vgs_vbs"); m = m.build("splitIgnore(vgs) .splitBy(int(vgs/0.5)) .selectBy(vgs==max(vgs))"); return m; }

1 2 3 4 5 6 7

Page 13: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

12 MBP Script Programming Manual

3. selectBy(vgs==max(vgs)) For each group, only one point is selected.

Plot Definition After data has been defined in the script, you can easily create a plot for it using the following steps:

1. Select the data. 2. Right click and select New->Graph on the pop-up menu. 3. Select the graph type and set the properties. 4. Click Viewto get the plots.

Sweep1 and Sweep2

Sweep1 and Sweep2 are important concepts in plot definition. They are defined as follows: 1. All points in a curve differ from each other by “Sweep1” only. 2. All curves in a page differ from each other by “Sweep2” only. For XY(Cartesian) graphs, “Sweep1” is X and “Sweep2” is P if not defined otherwise. For Smith Chart graphs and Polar graphs, sweep1 must be defined, whereas “Sweep2” is p if not defined otherwise.

Page 14: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

13 MBP Script Programming Manual

Data Transformation

POINT to POINT Example: It creates a new data with an output called “ids_mul_vds”. The output of “newTable” is updated by the function “transFunc”. In the function: “transFunc”(POINT to, POINT from) “from” is a point in “originalTable”, and “to” is a point in “newTable”. In this case, the function gets the ids value and vds value of “from”, and sets their multiple values to the “ids_mul_vds” in “to”.

Original Data

Outputs for new

data

Transform Function New Data

DATA load(sfunc select){ DATA originalTable = select("ids_vgs_vbs"); DATA newTable = originalTable.trans(transFunc,"ids_mul_vds"); return newTable; } void transFunc(POINT to, POINT from){ to->"ids_mul_vds" = from->"ids"* from->"vds"; }

1 2 3 4 5 6 7 8

Page 15: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

14 MBP Script Programming Manual

TABLE to POINT Example: will a new data with an output called “maxids” In line 3, “originalTable” is divided to several groups, and in each group, only vgs is different.

Each group of “originalTable” is transformed to a POINT of “newTable”. The output of “newTable” is updated by the function “transFunc”. In the function: “transFunc”(POINT to, DATA from) “from” is a group in “originalTable”, and “to” is a point in “newTable”. In this case, the function gets the ids values of “from”, and sets the max value to the “maxids” in “to”.

DATA load(sfunc select){ DATA originalTable = select("ids_vgs_vbs"); originalTable = originalTable.build("splitIgnore (vgs)"); DATA newTable = originalTable.transSubToPointIt create (transFunc,"maxids "); return newTable; } void transFunc(POINT to, DATA from){ double[] ids = from->"ids"; to->"maxids" = ids.max();

1 2 3 4 5 6 7 8

Page 16: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

15 MBP Script Programming Manual

Optimization

Objective function returns a double value. Optimizer tries to find out the parameter values to get the minimal value of objective function. Example (Assuming that you have already defined a data “example”): Line 2: Do optimization.

”vth0,u0,k1” is parameter ”error” is the objective function.

Line 6: Simulate the data. Line 7: Return the rms value.

.

Parameters Objective Function Optimization

DATA dat = data.example::get(); MBPOPT.optimize("vth0,u0,k1",error); MBPGUI.update(); dat = null; double error(){ dat.doSimulation(MBP); return dat.getRMS("ids"); }

1 2 3 4 5 6 7 8

Page 17: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

16 MBP Script Programming Manual

API for Model Parameter You can get a model param by name. Here is an example. “vth0” is the name of parameter. As you get the param, you can do the following operations:

Param param = MBP.getParam(“vth0”);

double value = p.getValue();// get the value of vth0 p.setValue(0.7);//set vth0 = 0.7 p.setBoundary(0.5,1.5);//set soft boundary = [0.5,1.5] p.setHardBoundary(0,10);//set hard boundary = [0,10] double lower = p.getLower();//get the lower value of soft boundary double upper = p.getUpper();//get the upper value of soft boundary double lower = p.getHardLower();//get the lower value of hard boundary double upper = p.getHardUpper();//get the upper value of hard boundary

Page 18: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

17 MBP Script Programming Manual

Build Extraction Flow In MBP, you can define some tasks and organize them in a flow. 1. Select the node “flow” and click NewTask on the pop-up menu to create

a task file. You can find the task code.

2. Write the code you want the task to do, for example, see the following:

3. Click the node “flow” and drag the task to the flow.

4. Create more tasks and add them to flow, and then press <ctrl> to link them.

task()(){ } TASK.start();

task()(){ System.out.println("Hello task"); } TASK.start();

Page 19: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

18 MBP Script Programming Manual

5. Click to run the flow. You can see the task execute one by one.

Appendix Array Calculation Method Describe double[] der = y.derivative(x); return dy/dx double[] p = y.linefit(x,n); Get a line to fit (x,y)

If n = 1, y = p[0] + p[1] * x If n = 2, y = p[0] + p[1] * x + p[2] * x2

double min = y.min(); Get the minimal value of y double max = y.max(); Get the maximal value of y double sum = y.sum(); Get the sum of y

Build-in Expression Expression Describe x+y add x-y sub x*y mul x/y Div x%y mod x<y return 1 if x y, otherwise return 0 x>y return 1 if x > y, otherwise return 0 x<=y return 1 if x = y, otherwise return 0 x>=y return 1 if x >= y, otherwise return 0 x==y return 1 if x and y are equal, otherwise return 0 x!=y return 0 if x and y are equal, otherwise return 1 x && y return 1 if both x and y are not 0, otherwise return 0 x || y return 0 if both x and y are 0, otherwise return 1 cond?x:y return y if cond is 0, otherwise return x max(x) return the max value of x in data (only valid in “selectBy” command) min(x) return the min value of x in data (only valid in “selectBy” command) sum(x) return the sum of x in data group (only valid in “selectBy” command) avg(x) return the average value of x in data (only valid in select command) abs(x) return the absolute value of x:|x| sqrt(x) return the square root of absolute value of x: sqrt(-x) = -sqrt(|x|) pow(x) return the value of x raised to integer part of y

Page 20: MBP Script Programming Manual€¦ · electronic, mechanical, manual, optical, or otherwise, without prior written permission of Agilent Technologies, Inc., or as expressly provided

19 MBP Script Programming Manual

pwr(x) return the absolute value of x, raised to integer part of y power, with the sign of x

log(x) return the natural logarithm of the absolute value of x, with the sign of x exp(x) return e raise to the power x db(x) return base 10 logarithm of the absolute value of x, multiplied by 20, with

the sign of x int(x) return the integer portion of x. The factional portion of the number is lost nint(x) rounds x up or down, to the nearest integer sin(x) return the sine of x(radians) cos(x) return the cosine of x(radians) tan(x) return the tangent of x(radians) asin(x) return the inverse sine of x(radians) acos(x) return the inverse cosine of x(radians) atan(x) return the inverse tangent of x(radians) sin(x) return the hyperbolic sine of x(radians) cos(x) return the hyperbolic cosine of x(radians) tan(x) return the hyperbolic tangent of x(radians)