==An Overview of [[File:rfspice_banner.png|right|640px]][[Image:Back_icon.png|40px]] '''[[RF.Spice_A/D | Back to RF.Spice A/D Parts & Devices== Wiki Gateway]]'''
[[FileImage:b2MAN_Fig42Tutorial_icon.png|thumb|400px| RF.Spice A/D Device Editor.40px]]Your '''[[RF.Spice ASpice_A/D]] circuit is made up of one or more parts that are connected to one another using wires#RF. Resistors, capacitors, transistors, voltage and current sources, etcSpice_A. are all [[2FD_Tutorials | RF.Spice A/DTutorial Gateway]] parts. A part consists of a simulation model and a symbol. The simulation model determines the circuit behavior of the part. Simulation models usually have the standard SPICE "Netlist" format. The part's symbol, on the other hand, is used to include it into your circuit's schematic. The part's symbol may have one or more pins. These pins are mapped onto the terminals or nodes of the part's simulation model. A part's pins are also used to connect it to the other parts in your schematic. ==Importing a New Simulation Model==
[[RF.Spice A/D]] comes Both process models and subcircuit models can be imported from simple plain text files with a very large "Parts Database" containing thousands of passive, active .TXT' file extension. Importing a simulation model from a text file is a very simple and virtual devicesstraightforward procedure. Some Under the File Menu of these parts are generic SPICE or XPICE parts such as the Resistor (R)Device Manager, choose "Import Simulation Model from Text File...". An "Open" dialog box will appear for you to locate the Capacitor (C) or model text file. Locate the Generic NPN-Type Bipolar Junction Transistor (Q)file and click OK. Many of Follow the database's parts are actual devices from particular semiconductor device manufacturersprogram prompts to choose a category, such as enter a description and keyword and choose a manufacturer for the switching diode BA582 new model to be imported. These fields may be left blank and filled out later through the Edit Model Dialog. Click OK when you are done. A message will indicate that you have loaded your (subcircuit or process) model file, and that a simulation model was created assuming that it was successfully loaded. The program will then fix the NPN-Type BJTpolynomial controlled sources, BFR193if any, both manufactured by Siemensand notify you of encountered problems. Click OK after each message box. When your model is loaded successfully, the program will notify you of the completion of the import process.
The new [[RFIf your file does not load, make sure the source file is not open in another application.Spice A/D]] has adopted a terminology that differentiates between Your model text file can contain the terms "Part" and "Device.model"lines or Netlist subcircuit codes for several different models. In this terminology, a "Part" is an instance All of a "Device" that you insert in your circuit. Devices are stored in [[RF.Spice]]'s Parts Database. They have certain simulation these models and symbols with a set of [[parameters]], which may have default values. Devices are saved can be imported together in the database and remain unchanged unless you alter them using B2.Spice's Device Editor. When you place a new part like a resistor R1 in your schematic, [[RF.Spice A/D]] indeed pulls the device type from the database and creates an instance of it with a default name and default parameter value(s)single process. In this that case, you have resistor R1 with a default value of 1K. You can change the name of your resistor or change its value to anything else. Now if program will guide you place a second resistor in your schematic, it will appear with the default name R2 and a default value of 1K. Your two resistors have through the same device type, but they are two instances of the "Resistor" device given two different names and possibly two different values. You can change the names and values of your parts at any time and save them with your circuit projectprocess for each individual model.
==Three Types of Device ModelsResolving SPICE Language Incompatibilities==
[[RF.Spice A/D]] features three different types of simulation models: ===Polynomial-Controlled Sources===
* Process (Technology) Models [[RF.Spice A/D]] does not support polynomial controlled sources within subcircuits. When you edit a subcircuit model in the Device Editor, you can check for incompatible polynomial sources using the button labeled "Check Controlled Sources". In addition, there is a button you can use to fix these sources wherever possible within the subcircuit.
* Subcircuit Simulation ModelsThe polynomial sources are lines of the form:
* S(E|F|G|H)xxx node node POLY(n) inputs coefficient-Parameter Modelslist
Many of B2.Spice's generic devices have process models, also known as technology models. These are standard SPICE or XSPICE models that have been hard-coded into [[RF.Spice A/D]]. A process models has a fixed preset number of [[parameters]]. Some examples include Resistor, Capacitor, Inductor, Diode, BJT, JFET, MOSFET, MESFET, Voltage- or Current-Controlled Switch, to name a few. When you open the property dialog of a part with a process model, you usually see a list An example of this is the device [[parameters]] with their default values as well as edit fields for changing their values. following:
Subcircuit simulation models are usually in the form of a standard Netlist code starting with the ".SUBCKT" command and ending with the ".ENDS" command. The Netlist subcircuit determines the number of the device's terminals or pins. Some simulation models may not have editable [[parameters]]. Their simulation model simply executes the given Netlist code during a simulation. On the other handE1 1 2 poly(3) (3, [[RF.Spice A/D]] offers "Parameterized Subcircuit Models". These models can have an arbitrary number of [[parameters]], which appear in the device's property dialog very similar to the process models. You can change the values of these [[parameters]] at any time and save their values with your circuit project. 0) 1 0 0 3
The third model type SPICE line above means a voltage-controlled voltage source where the voltage across nodes 1 and 2 is in determined by the form of a table of scattering function: v(S1,2) = 1 + 0 + 0 + 3* v(3)^3. SPICE 3, on which [[parametersRF.Spice A/D]], and is typically used for high frequency devices such based , supports a more general form of controlled source which includes polynomial controlled sources as RF diodes and transistorsa subset.This new "device" is the nonlinear dependent source with the following general Form:
Bxxx N+ N- < I=EXPR > < V= Working with the Device Manager ==EXPR >
[[RF.Spice]]'s Device Manager An example of this is a separate, independent application that is installed on your computer at the time of [[installation]] of [[RF.Spice A/D]]. You can use the Device Editor for the following purposes:
* Changing the name, simulation model, symbol, default parameter values, or other editable attributes of an existing database deviceB1 0 1 I=cos(v(1)) + sin(v(2)) + v(1)^2
* Creating a new device With the SPICE 2 example given above, a new simulation model or a new symboli.e.
* Importing simulation models from text filesE1 1 2 poly(3) (3,0) 1 0 0 3
* Deleting a devicethe corresponding SPICE 3 (and [[RF.Spice A/D]]) implementation is:
BE1 1 2 V= 1 + 3 * Emptying the current database or merging an external database with itV(3)^3
* Creating a database patch file from existing devices and applying a patch to the current database
[[File:b2MAN_Fig44.png|thumb|400px| Edit Device DialogRF.Spice A/D]]To open has the capability to convert from SPICE 2 polynomial-controlled syntax to SPICE 3 nonlinear source syntax when they are embedded in subcircuit models. Using the Device Editor, go to create the simulation model from the text file containing the subcircuit model. Depending on how you do this, the File Menu of [[Schematic Editor]] and select "Open Device Editormay automatically convert the polynomials for you..."If not, or simply use choose the keyboard shortcut button labeled "Ctrl+DFix Controlled Sources"and the Device Editor will perform the conversion.
{{Note | [[RF.Spice]]'s parts database file The following is called "partsan example of this kind of conversion.mdb" and The first line is located in the "Documents > b2spice" folder on your C Hard Drive. A copy of your original parts database is also supplied in the [[B2.Spice A/D]] [[installation]] directory for future references. Sometimes, when trying to open up the Device Editor, you may get a message asking you to locate the parts database. Please make sure you set the correct path in commented out because it was the "Documents" folderold polynomial controlled source.}}
Device Editor has a simple [[User Interface|user interface]] with a menu at the top of the screen and a side panel with the following items:* egnd 99 0 poly(2) (3,0) (4,0) 0 .5 .5
begnd 99 0 v =0 + .5 * Devicesv(3,0) + .5 * v(4,0)
* Process Models===Incompatible Model Types===
* Simulation ModelsSome Netlist languages such as that from Pspice use models that are either not in RF.SpiceA/D or are defined with a different set of parameters. When you edit a subcircuit model in the Device Editor, you can check for incompatible models using the appropriate button. In addition, there is a button you can use to fix these models wherever possible within the subcircuit.
* Symbols== Importing RF Device Models ==
* PackagesMultiport Network device, i.e. one-ports, two-ports, three-ports and four-ports, are all modeled based on their frequency-domain S-parameters. Most active and passive RF devices can be modeled as multipart networks. For example, RF diodes can be modeled as one-ports, while RF transistors (BJTs, JFETs, MOSFETs, and MESFETs) can be modeled as two-ports. Many semiconductor manufacturers publish S-parameter data sets for their RF devices. The manufacturer data sheets usually contain S-parameters in Mag/Phase format tabulated as a function of frequency expressed in GHz. On the other hand, you can model many passive devices such as filters, directional couplers, hybrids, etc. as multiport structures using full-wave electromagnetic simulators like [[EM.Cube]]. The port characteristics of such devices are typically written into data files as a function of frequency. A particular case of interest is transmission line components with complex geometries or material composition, for which [[RF.Spice A/D]] does not provide any database models. as an example, consider the case of a "Finline" transmission line. In a finline-based circuit, you may need one of more of the following general transmission line components:
* CategoriesOpen End
* Manufacturers Bend (right-angled or mitered)
The side panel acts as a quick access menu. Double-clicking on each of the above items opens a "Select" dialog that allows you to choose a device, model, symbol, etc. to edit. On the left side of the "Select" dialog there is a list of all the available choices. You can scroll the list and select an item in it. Or you can use the filters in the dialog and search for a particular item, e.g. based on a keyword or partial name. Once you select an item from the list, a device, a model or a symbol, you can edit it or delete it. You can edit the contents of the models as well as symbols. * Step Junction
You can use the Device Editor to delete devices* Tee Junction (symmetric or asymmetric, process and simulation models as well as symbols. You can do this from the Edit > Delete Menu, too. If you delete possibly with a device, the Device Editor will assume that you wish to delete every component of that device, including its symbol and process/simulation model. But the program will ask for a confirmation before deleting each component so that you can keep a symbol if you don't wish to delete it. Also, if the component is being used by another device, then you will receive an error message if you try to delete that component. You should make a copy of the database before modifying it just in case you mess up some devices. Also, you could use an empty database as your database for custom parts. In both the workshop and Device Editor, it's easy to set the database back and forth among several different databases as you use the program.notch)
== Editing Models in the Device Manager ==* Cross Junction (symmetric or asymmetric)
[[File:b2MAN_Fig43RF.png|thumb|400px| Edit Model Dialog.]]You can edit the contents and various aspects of both process models and subcircuit simulation Spice currently does not provide any modelsfor finline components. This However, you can be done either from the side panel's quick access menu by opening the "Select Model" dialog, or from the Edit Menu of the Device Editor by selecting "Edit Process Model..." or "Edit Simulation Model...". Browse the model list in either case, select the desired model to be edited and click the "Edit..." button of the dialog. This opens the "Edit Model" dialog. This dialog typically has two tabs. The first "General" tab contains the general attributed of the model including it name, type, category, description, etc. The second tab typically contains a list of the model's use [[parameters]] including their default valuesEM. In case the model does not involve any [[parametersCube]], the second tab is labeled "Simulation Guts". In that case, the tab contains the text of the Netlist subcircuit code. This is displayed in to analyze various finline structures over a text editor, where you can change the contents frequency range of the code as you wishinterest and generate S-parameter data sets for them. A Netlist subcircuit code has the following format:
[[RF.Spice A/D]] allows you to import S-parameter-based models of RF devices from text files. Before describing how to import S-parameter data files, let us first discuss the format of the data files in more detail. S------------------------------------parameter data files must have a ".subckt subcircui_name < list TXT" file extension. These files must start with a ".model", a ".symbol" statement, and a format statement starting with the character "#". The model text file can have any number of pins (terminal nodes) >comment lines at the beginning of the file or elsewhere. Comment lines are preceded by "*" or "!". All the text after these characters on the rest of the line will be ignored.
...Format:
SPICE commands.model <model_name>
...symbol <symbol_name>
.ends#<frequency_units> s <complex_data_format> r <reference_impedance_value>
---------------------------------------freq s11 s21 s31 ... s12 s22 s32 ... s13 s23 s33 ...
If your model has one or more [[parameters]], you can select each parameter individually by clicking the appropriate row in the table. Then you can type a new value in the value field. For logical [[parameters]], you have to choose between True and False values from a drop-down list. If you don't want to specify the field, leave it blank or type in "x", or uncheck the checkbox labeled "Given". If you enter a value in the box, accepting it will automatically make it given. When you are done specifying a parameter, click the "Accept" button to store it and go to the next parameter.Example:
Process models are ! This is an example of an RF BJT model based on the internal and standard models of SPICE or XSPICEmeasured S-parameters. They are typically defined as a text line with the following format:
---------------------------------------.model MyNewRFBJT
.model model_name model_type < list of [[parameters]] and values > symbol bjt_npn
---------------------------------------#ghz s ma r 50
The general tab of a process model's Edit Dialog contains a button labeled "Edit As Text...". Click this button to open a text editor where you can edit the model's text and modify it parameter values.! GHz MAG ANG MAG ANG MAG ANG MAG ANG
==Modifying and Saving Devices from Schematic Editor==0.500 0.6943 -122.1 4.977 105.7 0.0901 33.0 0.6170 -37.8
Instead of opening the Device Editor and changing devices through it, [[RF1.Spice A/D]] provides another convenient way of altering devices right from the Workshop000 0. Select a part in your circuit using the Select (arrow) tool. Right6470 -click to open the contextual menu or go to the Edit Menu of the [[Schematic Editor]] and select "Edit Device169.7 2.820 76." to open the device's property dialog8 0. This is identical to the device property dialog that you would open if you selected the same device type from the Device Editor0975 23. From this property dialog, you can change the device's simulation model by clicking the "Edit Model3 0.4862 -45.." button or you can modify its symbol in [[RF.Spice]]'s integrated Symbol Editor, if you click the "Edit Symbol..." button. Once you complete your edits and changes, you can close the device property dialog and return to your schematic. If you save your circuit projects, all the changes you made to the device, whether to its model or symbol or both, will be saved with your circuit. The next time you open the same circuit project, you will notice your changes, although they were saved locally in the project file and not globally in the database. 5
However, in the right-click contextual menu of the modified part you are presented with three options: 1.500 0.6586 * Store Device to Database162.9 1.959 * Store Simulation Model to Database * Store Symbol to Database57.6 If you choose one of the above three options, your changes to the device model and/or its symbol will be committed and saved to [[RF0.Spice]]'s Part Database permanently0978 25.6 0.4468 -54.5
==Scope of Database Changes==2.000 0.6854 142.0 1.481 41.5 0.1055 32.2 0.4315 -65.1
Any changes you make to the Parts Database using the Device Editor are not retroactive2. This means that any part already in a previously created circuit will not be affected by any changes you might have made to the same device in the database500 0. This also applies to the device's simulation model, process model, symbol, etc7070 128. If you want your changes to apply to a part previously in a circuit, you will have to delete and replace that part in the circuit1 1.246 30.1 0.1175 37.7 0.4261 -75.5
==Adding a New Category==3.000 0.7449 110.9 0.985 15.5 0.1475 41.9 0.4218 -93.3
The model statement specifies the name of your RF device model, in this case, MyNewRFBJT. The symbol statement determines the device type and schematic symbol. The symbol_name can only be one of the choice given in the table below. The frequency units can be hz, khz, mhz or ghz. "s" implies the s-parameters. If the category you want complex_data_format is not on left blank, the list you will need S-parameters are interpreted to run have Mag/Phase format, with the Database Editor magnitude on a linear scale and open the Edit List of categories dialog boxphase expressed in degrees. Double click on The other options for complex_data_format are "ma" for magnitude expressed in dB, or "ri" for Real/Imag format. The last part specifies the Categories quick access itemreference impedance value, which must come after letter "r". You can also open In the Edit List box by choosing New Category from above example, the File Menu or Edit Category from the Edit Menureference impedance is 50 Ohms.
To add a new category, click on the Add... button and the Category Entry dialog box will appear. Type in the name of your new category and then click either the Analog or Digital sub-category and they will appear in the Parent box[[Image:Info_icon. png|40px]] Click OK here to accept the additionsee a '''[[An_Overview_of_RF_Circuit_Simulation#List_of_Standard_Imported_RF_Devices | List of Standard Imported RF Devices]]'''. ==Adding a Manufacturer==
If the name of the manufacturer is not on the list you will need to add it. To add a new manufacturer go to the Edit menu of the Database Editor and select Edit Manufacturer or double click on the Manufacturer quick access. This will open the Edit List of manufacturers. Click Add and typ be in the new manufacturer. ==Repairing the Parts Database and Creating & Merging Database PatchesUsing Device Manager for Importing S-Parameter Data ==
[[File:b2MAN_Fig226.png|thumb|600px| Creating a database patch in RF.Spice A/D The Device Editor.]]There are times when you may inadvertently damage your parts database. The [[of RF.Spice A/D]] [[installation]] folder contains a copy of the original parts database. You can always recover the original database by copying this ".MDB" file from the [[installation]] folder to the "Documents > b2spice" folder and changing its name to the default database file "parts.MDB". Every time lets you install import S-parameter text files in a new version variety of [[B2ways.Spice A/D]], it will also install the newest version of the parts database. This is necessary because lots of new parts There are constantly added to B2.Spice's standard parts database with every new release.three menu items for this purpose:
In the meantime, you may also have added your own devices, models and symbols to the parts database* Import S-Parameter Model from Text File. When you install a new release or try to recover the original parts database, you also want to keep your own device entries to the database. You can do this in two different ways: by merging databases or by creating database patches. In the first method, you can make a copy of your current database and rename it to something different than "parts.mdb". After you install the new release with the new updated parts database, you can merge the new current database with your previously saved database. To do so, go to the Special Menu of the Device Editor and select "Merge External Database into Current Database...". This opens up the standard [[Windows]] Open Dialog, with the file extension set to ".MDB". Browse your folders to find the your previously save old database file and click the Open button to complete the merge process.
{{Note | Merging databases may take a considerable amount of time depending on the their size* Create New Generic Multiport from S-Parameter Text File... * Create New RF Device from S-Parameter Text File... * Create New Generic T-Line Discontinuity from S-Parameter Text File...}} The second method of recovering old devices involves creating database patchesfirst item in the above list simply lets you import an S-parameter ". TXT" file and saves it as a simulation model in [[RF.Spice A /D]]'s parts database patch is . You can use this model later to build a collection of new device or share it among several devices, . The next three items in the above list create new devices complete with simulation models and schematic symbols that . The newly create devices are permanently stored together in a database fileyour [[RF. If you keep track of the devices that you create and add to the Spice A/D]] parts database over time, then you and can bring them together and save them be used as a database patch. Every time you install a new databaseparts in your RF circuits. For example, then you can merge an imported RF BJT device has the database patches into "partssame BJT symbol with the same pin map as the other BJT devices of [[RF.MDB"Spice A/D]]. The main difference is that instead of a technology process models or a Netlist subcircuit model, the RF BJT is modeled by its imported, measured S-parameters. In this waya similar manner, you can preserve your own import Multiport Network devicesor T-Line Discontinuity models from S-parameter text files that are generated at the end of full-wave simulations of such structures using an electromagnetic modeling tool like [[EM. To create Cube]]. ==Creating a database patch, go to New Simulation Model from Scratch== From the Special File Menu of the Device Editor and select choose "Create Database Patch FileNew Simulation Model...". A large You will be presented with the following dialog opens up, which allows you box: Select the appropriate Model type and click OK. The Edit Model window will appear Fill in the Name field to select devicesspecify the simulation mode's name. Specify the category, manufacturer, models and symbols from description. These fields can be left blank. Specify the current parts databaseModel Type by using the scroll arrow button For the Category click on the ellipse button. The SELECT CATEGORY window will appear. Click on each Add button and the respective Select Dialog opens up. Browse the list Category you want and choose and add as many items as you likeclick SELECT. Once your lists are complete Next, click to set the OK button. This opens up simulation guts for the standard [[Windows]] Save Dialogsimulation model, with click on the file extension set to "Simulation Guts tab.PAT". Choose a name for  If your new database patch and save itmodel type is a SUBCIRCUIT the simulation guts will be blank. To merge an existing database patch file You will need to enter the current parts database, go to subcircuit text for this part into the Special Menu of the Device Editor empty text field. If you already have this text in another file, you can copy and select "Apply Patch to Databasepaste the subcircuit text. If your model type is other than a Subcircuit you will need to set parameters for the device..". The standard [[Windows]] Open Dialog opens up, If you need help with this, see the file extension section on entering parameters. Some devices or parts require that a process model be set to ".PAT". Browse your folders to find To set the desired database patch file and process model click on the Open ellipsis button to complete , and then select a process model from the merge list that appears. If the process model for your simulation model is not in the list, then you need to add a new processmodel.
==Creating a New Device from Scratch==
==Setting & Matching Device Pins==
[[File:b2MAN_Fig45.png|thumb|400px| "Connect Symbol Pins to Model Pins" Dialog.]]
When creating a new simulation model as will be discussed later, you can also instruct the Device Editor to create a default (simple and basic) symbol for a it. Normally, if you have already set the simulation model pin or terminal names, the symbol pins will automatically match the model pins. In many other cases, you may create the models and symbols separately and independently. In such cases, you need set and match the symbol pins with the corresponding model pins.
It is important to match up the pins correctly because the simulator will need this information to be correct to simulate the part correctly. Limit pin names to 10 characters or less. For spaces use underscore ( _ ). Dashes are not accepted. Click OK when all the pins have been matched up correctly.
<table>
<tr>
<td>
[[File:b2MAN_Fig45.png|thumb|left|720px| "Connect Symbol Pins to Model Pins" Dialog.]]
</td>
</tr>
</table>
Â
==Creating a New Device from an Existing Simulation Model==
Â
From the File menu of the Database Editor, choose New Device Based on Simulation Model to open the Select Model window. Choose a simulation model from the Model Bin and click the Select Button.
Â
When you select the simulation model, the program automatically creates a new part with this simulation model as its model, and with the same name, category, manufacturer, description, and keywords as those of the simulation model. Next, the program will ask you if you would like to edit the pin names for the simulation model. If you have not set the pin names yet, or would like to edit the pin names, click YES.
Â
All that's left to do is specify the symbol for this part. The program will ask you if you would like to create a new symbol for the part. Click YES, if you would like the program to create a symbol for you. Click NO, if you would like to choose an existing symbol for the part.
Â
NOTE: If you get a warning message that reads Inconsistency between symbol and simulation model. Try another combination or change simulation model or pin names, most likely your pin names do not match with the symbol. Double check your pin names to see if they are consistent with the symbol. For more information, see the section on Setting Model Pins.
Â
==Creating a New Symbol Based on an Existing Simulation Model==
Â
You can create a new symbol once your simulation model is loaded into the library. From the File Menu of the Database Editor choose New Symbol based on Simulation Model to open the Select Model dialog box.
Â
Select the model for which you would like to create a symbol and click Edit to open the Edit Model dialog box. Click on the Create Symbol button the program will automatically create a symbol for you. When you import your simulation model into the database using the New Device from text file feature or the Import Simulation Models feature, the program will automatically ask you if you would like to create a symbol.
Â
Your new symbol will be named the same name as your model name. If you create a new symbol by clicking on the Create Symbol button you will be notified that a symbol has been created successfully.
==Creating a New Part from Your Circuit==
If your circuit contained XSpice parts, you will have to designate whether the pin is digital or analog. If the pin is Digital, then you must also designate whether it is an Input or Output pin. If the pin is Analog, then input and output direction designation do not apply. Click accept when you're done with each pin. Click OK when you're done setting the pins.
For Digital parts, Select and edit the [[Digital Simulation|digital simulation]] model you just created. In the Edit Simulation Model dialog box, click the Edit Pin Properties button to access the list of digital pin. You should set each pin's direction, state, and propagation delay. Click the Accept button to accept changes and move on to the next pin. Refer to the Database Editor Menu's Edit simulation model section for more information.
Once you're done setting the pin properties, close all the dialog boxes. All that remains is to alter the symbol if you want to rearrange the symbol pins and exit the Database Editor. In the Workshop pull up your new part and use it like any other part.
==Importing a New Simulation Model== Both process models and subcircuit models can be imported from simple plain text files with a ".TXT' file extension. Importing a simulation model from a text file is a very simple and straightforward procedure. Under the File Menu of the Device Editor, choose "Import Simulation Model from Text File...". An "Open" dialog box will appear for you to locate the model text file. Locate the file and click OK. Follow the program prompts to choose a category, enter a description and keyword and choose a manufacturer for the new model to be imported. These fields may be left blank and filled out later through the Edit Model Dialog. Click OK when you are done. A message will indicate that you have loaded your (subcircuit or process) model file, and that a simulation model was created assuming that it was successfully loaded. The program will then fix the polynomial controlled sources, if any, and notify you of encountered problems. Click OK after each message box. When your model is loaded successfully, the program will notify you of the completion of the import process. If your file does not load, make sure the source file is not open in another application. Your model text file can contain the ".model" lines or Netlist subcircuit codes for several different models. All of these models can be imported together in a single process. In that case, the program will guide you through the same process for each individual model. ==Creating a New Simulation Model from Scratch== From the File Menu of the Device Editor choose "New Simulation Model...". You will be presented with the following dialog box: Select the appropriate Model type and click OK. The Edit Model window will appear Fill in the Name field to specify the simulation mode's name. Specify the category, manufacturer, and description. These fields can be left blank. Specify the Model Type by using the scroll arrow button For the Category click on the ellipse button. The SELECT CATEGORY window will appear. Click on the Category you want and click SELECT. Next, to set the simulation guts for the simulation model, click on the Simulation Guts tab. If your model type is a SUBCIRCUIT the simulation guts will be blank. You will need to enter the subcircuit text for this part into the empty text field. If you already have this text in another file, you can copy and paste the subcircuit text. If your model type is other than a Parameterized Subcircuit you will need to set [[parameters]] for the device. If you need help with this, see the section on entering [[parameters]]. Some devices or parts require that a process model be set. To set the process model click on the ellipsis button, and then select a process model from the list that appears. If the process model for your simulation model is not in the list, then you need to add a new process model. ==Creating a New Device from an Existing Simulation Model== From the File menu of the Database Editor, choose New Device Based on Simulation Model to open the Select Model window. Choose a simulation model from the Model Bin and click the Select Button. When you select the simulation model, the program automatically creates a new part with this simulation model as its model, and with the same name, category, manufacturer, description, and keywords as those of the simulation model. Next, the program will ask you if you would like to edit the pin names for the simulation model. If you have not set the pin names yet, or would like to edit the pin names, click YES. All that's left to do is specify the symbol for this part. The program will ask you if you would like to create a new symbol for the part. Click YES, if you would like the program to create a symbol for you. Click NO, if you would like to choose an existing symbol for the part. NOTE: If you get a warning message that reads Inconsistency between symbol and simulation model. Try another combination or change simulation model or pin names, most likely your pin names do not match with the symbol. Double check your pin names to see if they are consistent with the symbol. For more information, see the section on Setting Model Pins. ==Creating a New Symbol Based on an Existing Simulation Model== You can create a new symbol once your simulation model is loaded into the library. From the File Menu of the Database Editor choose New Symbol based on Simulation Model to open the Select Model dialog box.  Select the model for which you would like to create a symbol and click Edit to open the Edit Model dialog box. Click on the Create Symbol button the program will automatically create a symbol for you. When you import your simulation model into the database using the New Device from text file feature or the Import Simulation Models feature, the program will automatically ask you if you would like to create a symbol. Your new symbol will be named the same name as your model name. If you create a new symbol by clicking on the Create Symbol button you will be notified that a symbol has been created successfully. ==Creating a Parameterized Subcircuit Part==
Parameterized Subcircuit Parts are parts whose behavior can be modified with one or more [[parameters]]. In some cases, you will want to turn your subcircuit defined parts into parameterized subcircuits.
In this example, we will be creating a battery as a Parameterized Subcircuit Model part.
This should bring up the dialog box shown below. In the Model Type Name, enter the name you would like to identify your new model by, making sure that there are no spaces in the name.
Then click on the [[Parameters]] tab. In the Parameter Name field, enter the name of the 1st parameter that you will be using, in this case, Voltage. In the data type, select the type of data of the parameter. Usually this will be a real or integer. In this example, the Data Type will be Real. Units and defaults are optional. Make sure the Use For Input box is checked. Leaving it unchecked will cause the parameter to not show up in other dialog boxes. The "Is Required" checkbox is for when you want Workshop to specifically use this parameter. If you check the box, then you also must enter a Default Value.
Click Accept when you're finished with the particular parameter. Note that you must click New Parameter to enter and edit a new parameter. Not doing so will overwrite the parameter that happens to be highlighted.
Then click on the Subcircuit Text tab. This is where you will be entering the actual subcircuit that you will be using your [[parameters]] in.
If you know what you're doing, you can start entering your subcircuit starting with the .SUBCKT statement and ending the .ENDS statement. This subcircuit will need to be in Berkeley Spice 3f5 format with XSpice extensions. Otherwise, copy and paste a subcircuit into the window. You can get the subcircuit text for an existing simulation model by editing the simulation model and copying its text.
Now all you have to do is incorporate your own [[parameters]] into the subcircuit. Enter your [[parameters]] in the form of a parameter or formula. All custom [[parameters]] must go in between the curly brackets {}. For example, if you had two [[parameters]] called X and Y and wish to have them added together in a subcircuit, the formula would be {X + Y}. Or getting fancier, you add X and Y and then multiply by 2. The formula would look like this: {(X + Y) * 2}. All standard mathematical operations are supported (+,-,/,*), power of (^), and any other operation supported in the graphing plot expression module of the Workshop. In the example below, note that the {voltage} has replaced the regular voltage number.
Once you're satisfied that everything is correct, click OK and continue to the next step.
the Set Model Pins... button allows you to edit the pins in your simulation model, if wish. The Create Symbol will create a new generic symbol using the pins in your subcircuit for symbol pins and named the same as your Simulation Model
Click on the "[[Parameters]]" tab, you can enter values for the [[parameters]] that you specified earlier. Or you can leave them blank for now and change it once you have the part in the schematic. For this example, we'll enter a default voltage of 10. Enter 10 in the Value box and click Accept. The window should look like the window below. Once you're done editing the simulation model, click OK to accept it.
<b>Step 3 - Create a new Part with the simulation model</b>
Click OK to accept the part.
And that's it. To access your new part in the Workshop, go to Devices->Choose Part by Name and type in the name of your part. Pull your part up in the Workshop and double click on it to change your custom [[parameters]]. The [[parameters]] will be evaluated automatically as you run a simulation.
You can assign packages and pairings by using the drop down box to select a package, typing in how many parts come in a package, and then clicking on the Connect Part Pins to Package Pins button. More information about Packages can be found in the PCB tutorial.
==Resolving SPICE Language Incompatibilities==<p> </p>[[Image:Tutorial_icon.png|40px]] '''[[RF.Spice_A/D#RF.Spice_A.2FD_Tutorials | RF.Spice A/D Tutorial Gateway]]'''
===Polynomial-Controlled Sources===
Â
[[RF.Spice A/D]] does not support polynomial controlled sources within subcircuits. When you edit a subcircuit model in the Device Editor, you can check for incompatible polynomial sources using the button labeled "Check Controlled Sources". In addition, there is a button you can use to fix these sources wherever possible within the subcircuit.
Â
The polynomial sources are lines of the form:
Â
(E|F|G|H)xxx node node POLY(n) inputs coefficient-list
Â
An example of this is the following:
Â
E1 1 2 poly(3) (3,0) 1 0 0 3
Â
The SPICE line above means a voltage-controlled voltage source where the voltage across nodes 1 and 2 is determined by the function: v(1,2) = 1 + 0 + 0 + 3* v(3)^3. SPICE 3, on which [[B2.Spice A/D]] is based , supports a more general form of controlled source which includes polynomial controlled sources as a subset. This new "device" is the nonlinear dependent source with the following general Form:
Â
Bxxx N+ N- < I=EXPR > < V=EXPR >
Â
An example of this is the following:
Â
B1 0 1 I=cos(v(1)) + sin(v(2)) + v(1)^2
Â
With the SPICE 2 example given above, i.e.
Â
E1 1 2 poly(3) (3,0) 1 0 0 3
Â
the corresponding SPICE 3 (and B2.Spice) implementation is:
Â
BE1 1 2 V= 1 + 3 * V(3)^3
Â
Â
[[RF.Spice A/D]] has the capability to convert from SPICE 2 polynomial-controlled syntax to SPICE 3 nonlinear source syntax when they are embedded in subcircuit models. Using the Device Editor, create the simulation model from the text file containing the subcircuit model. Depending on how you do this, the Device Editor may automatically convert the polynomials for you. If not, choose the button labeled "Fix Controlled Sources" and the Device Editor will perform the conversion.
Â
The following is an example of this kind of conversion. The first line is commented out because it was the old polynomial controlled source.
Â
* egnd 99 0 poly(2) (3,0) (4,0) 0 .5 .5
Â
begnd 99 0 v =0 + .5 * v(3,0) + .5 * v(4,0)
Â
===Incompatible Model Types===
Â
Some Netlist languages such as that from Pspice use models that are either not in B2.SpiceA/D or are defined with a different set of [[parameters]]. When you edit a subcircuit model in the Device Editor, you can check for incompatible models using the appropriate button. In addition, there is a button you can use to fix these models wherever possible within the subcircuit.
== Importing RF Device Models ==
Â
Multiport Network device, i.e. one-ports, two-ports, three-ports and four-ports, are all modeled based on their frequency-domain S-[[parameters]]. Most active and passive RF devices can be modeled as multipart networks. For example, RF diodes can be modeled as one-ports, while RF transistors (BJTs, JFETs, MOSFETs, and MESFETs) can be modeled as two-ports. Many semiconductor manufacturers publish S-parameter data sets for their RF devices. The manufacturer data sheets usually contain S-[[parameters]] in Mag/Phase format tabulated as a function of frequency expressed in GHz. On the other hand, you can model many passive devices such as filters, directional couplers, hybrids, etc. as multiport structures using full-wave electromagnetic simulators like [[EM.Cube]]. The port characteristics of such devices are typically written into data files as a function of frequency. A particular case of interest is transmission line components with complex geometries or material composition, for which [[RF.Spice]] does not provide any database models. as an example, consider the case of a "Finline" transmission line. In a finline-based circuit, you may need one of more of the following general transmission line components:
Â
* Open End
Â
* Bend (right-angled or mitered)
Â
* Step Junction
Â
* Tee Junction (symmetric or asymmetric, possibly with a notch)
Â
* Cross Junction (symmetric or asymmetric)
Â
RF. Spice currently does not provide any models for finline components. However, you can use [[EM.Cube]] to analyze various finline structures over a frequency range of interest and generate S-parameter data sets for them.
Â
[[RF.Spice]] allows you to import S-parameter-based models of RF devices from text files. Before describing how to import S-parameter data files, let us first discuss the format of the data files in more detail. S-parameter data files must have a ".TXT" file extension. These files must start with a ".model", a ".symbol" statement, and a format statement starting with the character "#". The model text file can have any number of comment lines at the beginning of the file or elsewhere. Comment lines are preceded by "*" or "!". All the text after these characters on the rest of the line will be ignored.
Â
Format:
Â
.model <model_name>
Â
.symbol <symbol_name>
Â
#<frequency_units> s <complex_data_format> r <reference_impedance_value>
Â
freq s11 s21 s31 ... s12 s22 s32 ... s13 s23 s33 ...
Â
Example:
Â
! This is an example of an RF BJT model based on measured S-[[parameters]].
Â
.model MyNewRFBJT
Â
.symbol bjt_npn
Â
#ghz s ma r 50
Â
! GHz MAG ANG MAG ANG MAG ANG MAG ANG
Â
0.500 0.6943 -122.1 4.977 105.7 0.0901 33.0 0.6170 -37.8
Â
1.000 0.6470 -169.7 2.820 76.8 0.0975 23.3 0.4862 -45.5
Â
1.500 0.6586 162.9 1.959 57.6 0.0978 25.6 0.4468 -54.5
Â
2.000 0.6854 142.0 1.481 41.5 0.1055 32.2 0.4315 -65.1
Â
2.500 0.7070 128.1 1.246 30.1 0.1175 37.7 0.4261 -75.5
Â
3.000 0.7449 110.9 0.985 15.5 0.1475 41.9 0.4218 -93.3
Â
The model statement specifies the name of your RF device model, in this case, MyNewRFBJT. The symbol statement determines the device type and schematic symbol. The symbol_name can only be one of the choice given in the table below. The frequency units can be hz, khz, mhz or ghz. "s" implies the s-[[parameters]]. If the complex_data_format is left blank, the S-[[parameters]] are interpreted to have Mag/Phase format, with the magnitude on a linear scale and phase expressed in degrees. The other options for complex_data_format are "ma" for magnitude expressed in dB, or "ri" for Real/Imag format. The last part specifies the reference impedance value, which must come after letter "r". In the above example, the reference impedance is 50 Ohms.
Â
[[Image:Info_icon.png|40px]] Click here to see a '''[[List of Standard Imported RF Devices]]'''.
Â
== Using Device Manager for Importing S-Parameter Data ==
Â
The Device Editor of RF. Spice A/D lets you import S-parameter text files in a variety of ways. There are three menu items for this purpose:
Â
* Import S-Parameter Model from Text File...
Â
* Create New Generic Multiport from S-Parameter Text File...
Â
* Create New RF Device from S-Parameter Text File...
Â
* Create New Generic T-Line Discontinuity from S-Parameter Text File...
Â
The first item in the above list simply lets you import an S-parameter ".TXT" file and saves it as a simulation model in [[RF.Spice]]'s parts database. You can use this model later to build a new device or share it among several devices. The next three items in the above list create new devices complete with simulation models and schematic symbols. The newly create devices are permanently stored in your [[RF.Spice A/D]] parts database and can be used as new parts in your RF circuits. For example, an imported RF BJT device has the same BJT symbol with the same pin map as the other BJT devices of [[RF.Spice A/D]]. The main difference is that instead of a technology process models or a Netlist subcircuit model, the RF BJT is modeled by its imported, measured S-[[parameters]]. In a similar manner, you can import Multiport Network devices or T-Line Discontinuity models from S-parameter text files that are generated at the end of full-wave simulations of such structures using an electromagnetic modeling tool like [[EM.Cube]]
Â
<p> </p>
[[Image:Back_icon.png|40px]] '''[[RF.Spice_A/D | Back to RF.Spice A/D Wiki Gateway]]'''