From c317fdd025fab26e9564b1117d278ffd7e60b360 Mon Sep 17 00:00:00 2001 From: StefanSchippers <69359491+StefanSchippers@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:16:36 +0100 Subject: [PATCH] Created Use an existing spice text file for a subcircuit (markdown) --- ...isting-spice-text-file-for-a-subcircuit.md | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Use-an-existing-spice-text-file-for-a-subcircuit.md diff --git a/Use-an-existing-spice-text-file-for-a-subcircuit.md b/Use-an-existing-spice-text-file-for-a-subcircuit.md new file mode 100644 index 0000000..8bfcf18 --- /dev/null +++ b/Use-an-existing-spice-text-file-for-a-subcircuit.md @@ -0,0 +1,51 @@ +If you have for example the following definition in a file, say `symbol_include.cir`: +``` +* example of a subcircuit contained in a file + +.subckt symbol_include Z VCC VSS ++ A B C W=10 L=1 +... +... +.ends +``` + +You can use this file to get the spice netlist port order: + +In the following testbench: + +![1](https://github.com/StefanSchippers/xschem/assets/69359491/17ef7c28-9167-4507-8898-26e01dbe989a) + +the symbol is defined as follows: + +![2](https://github.com/StefanSchippers/xschem/assets/69359491/db2f6c2b-3a4f-4a1b-bb76-861d13c6b964) + +When netlisting the testbench the port order (the @pinlist in the `format` string) +of the `x1` instance call will match the order in the file `symbol_include.cir`: +``` +** sch_path: /home/schippes/.xschem/xschem_library/symbol_include/tb_symbol_include.sch +**.subckt tb_symbol_include XZ XVSS XVCC XC XB XA +*.opin XZ +*.ipin XVSS +*.ipin XVCC +*.ipin XC +*.ipin XB +*.ipin XA +x1 XZ XVCC XVSS XA XB XC symbol_include +**.ends + +* expanding symbol: symbol_include.sym # of pins=6 +** sym_path: /home/schippes/.xschem/xschem_library/symbol_include/symbol_include.sym +.include symbol_include.cir +.end +``` + +A final note, the `spice_sym_def` does not necessarily need to use a .include line. You can directly define the subcircuit: +``` +spice_sym_def=" +.subckt symbol_include Z VCC VSS ++ A B C +... +... +.ends +" +``` \ No newline at end of file