Tutorial: .libpath directive

I appreciate QSpice’s addition of the .libpath directive.

Without the .libpath directive, QSpice assumes that all needed simulation information (I call components) such as C-Blocks, Verilog-Blocks, symbols, subcircuits and models are in the same directory as the schematic.

.libpath defines a the C compiler equivalent to adding a “include” directory path. This allows you to place pieces of the simulation design in a logical folder format. This allows common components used across multiple simulation designs to not need copying into each simulation design folder.

There are two ways to use this directive.

The Direct Method

To use this command directly in the schematic just add the text “.libpath =folderpath=” to the schematic.

=folderpath= can be a relative path or an absolute path.

QSpice will first look in the folder where the simulation design schematic exists. If the components added to the schematic is not found in this directory, it will use the .libpath to find it.

The Indirect Method (“Symbols & IP Browser”)

QSpice added the .libpath directive into the NetList based on the added “symbol directories” to the “Symbols & IP Browser”.

Here is a snapshot of this browser with the default symbol directories.
image

These directories are the “default” included libpath directories.

If you place your project sharable components in separate directories you can add the directories to the “Symbols & IP Browser”. Just Right-click on “Symbols & IP” and select “Add a symbol directory”
image
Find the desired directory in the File Explorer and Select Folder".

You can see in my snapshot I added 4 Symbol and IP directories.

If you open the NetList you will find the added directories as .libpath absolute paths in the other you added them to the “Symbols & IP Browser”.

Executing the simulation will add those libpaths.

I’d like to point out 3 things about using this indirect method.

  1. When you add directories to the “Symbol & IP Browser” these adds persist across multiple QSpice instances. This can be convenient when creating different simulations that use common components.

  2. Adding directories “Symbol & IP Browser” will display symbols in the treeview structure. If your added directory has no symbols, the treeveiw under that directory may look empty. However, the special component files will still be referenced using the .libpath directive. So don’t panic.

  3. The libpaths in the NetList will be executed in the order that it shows up in “Symbol & IP Browser”, This means if you have a component with the same name across different directories in the Browser, the first component found will be included. If you need to change the Netlist order, delete the directory with the old version of the component. If the directory is still needed, add it to the end of the “Symbol & IP Browser” treeview list.

Len

6 Likes

Nice tutorial, Len.

Some additional information – not fully verified but I think is correct…

“Removing” a custom symbol directory (right-click on it in the Symbol & IP pane, select remove) doesn’t actually remove it. Start a new schematic and any previously added custom symbol directories will appear in new schematic netlists. Not sure what happens when editing an existing schematic.

For the moment, it looks like the only way to fully remove a custom symbol directory is to edit the Registry.

There’s no real harm in having empty/unused custom symbol directories and there is some risk to editing the Registry. In my case, I created/added some temporary directories before the .libpath support was added and don’t want them included in the netlist in the future so I’m going to edit the Registry entry.

Anyway, maybe others will find this additional information useful.

–robert

Robert,

You’re right. There are interesting things going on in the System Registry.
I agree it is generally not advisable to alter the System Registry without being sufficiently knowledgeable.

I found the Registry directory you sited.

When I add a directory to the list, I can F5 refresh the registry item “UserSymbolDirectories” and the newly added directory is appended to the end with a pipe symbol ‘|’. As expected.

Here’s where it gets a bit wonky.

If I remove one of the directories from the list and then exit QSpice OR refresh the “UserSymbolDirectories” , the intended deleted directory and all the appended files after it get deleted.

When I enter back into QSpice, the added directories BEFORE the removed directory are still there but all the previously added directories after the removed directory are gone from the list. This confirms what I saw going on in “UserSymbolDirectories”.

I’m pinging Mike @Engelhardt to hopefully take a look at this.

My guess is that he isn’t parsing the piped list just deleting from the desired directory to remove.

Len