New Subcircuits

Since version 0.4.14 there is a new simpler way to create subcircuits.

In order to create subcircuit "chips" we need:
- Package files.
- Subcircuit file.
- Add entry to .xml file.

Place package and subcircuit files in the folder indicated in the xml entry.
Restart SimulIDE and the new subcircuit will appear in the category indicated in the xml file.



Creating Package Files:


There is a component "Package" in "Other" section, at the end of the component list.
When you add it to the circuit there is just a blue box, that's an empty package ready to be configured:



From here you can load an existing package file to edit it or create a new package.
In the component properties you can set the size of the package in circuit cells. default size is 4x8 cells.
There is also a property to set the type of package:  Chip or Logic Symbol.



Creating new Pins:


If you hover the mouse pointer along the package edges whiles pressing "Shift Key" you will see a gray fake pin.
Then by mouse left-Click a dialog appear to set the properties of the pin.
Once you press OK a new pin will be created at that position with the given name and properties.


  • Pin Name: Name that appears in the package.
  • Pin Id: Unique Pin Id.
  • Invert Pin: Pin Shows as inverted.
  • Unused Pin: Inactive Pin
  • Point Pin: Makes Pin Length = 0.






Editing Pins:


You can edit existing pins by right-clicking on the edge of the package at the pin position.
A context menu will appear with pin options:

  • Move: Click and move Pin.
  • Edit: Opens Edit Pin widget.
  • Delete: Remove Pin.



Package types:


There are 2 possible package types: Chip and Logic Symbol.
It is possible to have both options for the same component and switch betwen them:




There are some considerations to have in mind when you create both Chip and Logic Symbol packages for the same component. Both Packages must be Pin-compatible in order to work with the same subcircuit file:

- All active Pins must exist in both packages ( doesn't aply to unused pins).
- Same Pin must have same Id in both packages.

Note that There is an "Id" and a "Label"  for each pin, so a pin can have diferent label in both packages while the Id must be the same.
As an example in the image above, for 74HC74  some pins have slightly different labels: !RD1 vs RD1 for example.

Some of this differences are kind of automated in the package creation, like extra spaces and inverted pins.
For inverted pins you can either use "!" as the first character of the label or set the pin as inverted, in both cases simulide will set the Id as: "!PinName".
It is recomended to use "!PinName" for Chip packages and "PinName"+invert-Pin for Logic Symbol packages, but in some cases you can use "!PinName" for both, for example "!Qn" outputs in 74HC74 package above.


There is a video about creating Logic Symbol Package for 74HC194:
https://youtu.be/E40qK870Df4





Creating Subcircuit File:


To create subcircuits just connect your circuit to Tunnels.
Then Set the names of these Tunnels the same as the Pin Ids in the Packages.

Save this circuit and use this .simu file as Subcircuit file.

You can do all in one Circuit, as in the image below, with both Chip and Logic Symbol packages and subcircuit.






Add entry to .xml file:


In order to get your subcircuit included in SimulIDE component list you need to add an entry to one of the existing xml files or create a new one.
These files are located at: share/simulide/data
Please have a look to any existing .xml file in data folder to get an idea.

Structure of these xml file are like this:

<!DOCTYPE SimulIDE>

<itemlib>
    <itemset category="New Subcircuits" type="Subcircuit">
        <item name="lcdShield" package="test/lcdshield_LS.package" subcircuit="test/lcdshield-board.simu" />
        <item name="Arduino Uno B" package="test/arduino_board.package" subcircuit="test/arduino_uno_board.simu" />
    </itemset>
</itemlib>
 

 Let's explain by levels:

 <itemset/> Represent a set of components.
 
    category Is the Category name where all components in this set will be included.
                     It can be an existing Category or a new one.
                     It can address a subcategory: "Category/Subcategory" (Category must exist)
 
    type Is the type of component, in this case "Subcircuit"


<item/> Represents a component to be added to the list
 
    name Is the name that will be shown in Component list
 
    package Is the path to package file, relative to data folder (where the .xml file is located).
 
    subcircuit Is the path to subcircuit file, relative to data folder (where the .xml file is located).
 
    info (optional) Extra information that will be shown besides Component name.

There is an option to simplify these entries by indicating the folder where subcircuit and package files are located.
For this option to work, all names must be the same, and files must be in a folder with same name.
An example is 74 series (in 0.5.15 version):
For example 74HC00 files are in a folder named 74HC00 inside "ICs" folder.
ICs (folder)
    74HC00 (folder)
        74HC00.simu
        74HC00.package
        74HC00_LS.package

Then the xml file entry looks like this:

    <itemset category="IC 74/7400-7499" type="Subcircuit" folder="ICs">
        <item name="74HC00"  info="  quad 2-input NAND gate" ></item>



In this case, folder atribute is applied to all components in that itemset.
But it is possible to use a diferent one for each item.
Or set the exact path for package and subcircuit files:

    <itemset category="IC 74/7400-7499" type="Subcircuit" folder="ICs">
        <item name="74HC00"  info="  quad 2-input NAND gate" ></item>
        <item name="Comp_X"  folder="XX" info=" My files in XX folder" ></item>
        <item name="Comp_Y"  package="blah/cY.package" subcircuit="bla2/compY.simu" info=" My files in blah & bla2 folders" ></item>
 
 
Subcircuit and package files are ussually located in folders inside data folder, but this is not a must.
Path to these files are relative to "data" folder.