diff --git a/src/token.c b/src/token.c index 7253b09c..85931c0d 100644 --- a/src/token.c +++ b/src/token.c @@ -1827,8 +1827,17 @@ static int has_included_subcircuit(int inst, int symbol, char **result) my_strdup2(_ALLOC_ID_, &spice_sym_def, get_tok_value(xctx->sym[symbol].prop_ptr, "spice_sym_def", 0)); } if(xctx->tok_size) { - tclvareval("has_included_subcircuit {", get_cell(xctx->sym[symbol].name, 0), "} {", + char *symname = NULL; + my_strdup2(_ALLOC_ID_, &symname, get_tok_value(xctx->inst[inst].prop_ptr, "schematic", 0)); + if(!symname[0]) { + my_strdup2(_ALLOC_ID_, &symname, get_tok_value(xctx->sym[symbol].prop_ptr, "schematic", 0)); + } + if(!symname[0]) { + my_strdup2(_ALLOC_ID_, &symname, xctx->sym[symbol].name); + } + tclvareval("has_included_subcircuit {", get_cell(symname, 0), "} {", spice_sym_def, "}", NULL); + my_free(_ALLOC_ID_, &symname); if(tclresult()[0]) { char *pinlist = NULL; char *pin, *save; diff --git a/src/xschem.tcl b/src/xschem.tcl index 64aa464f..e4adf286 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -701,9 +701,9 @@ proc has_included_subcircuit {symname spice_sym_def} { } # return pinlist as found in the .subckt line or empty string if not found if {!$include_found} { - puts "has_included_subcircuit: no matching .subckt found in spice_sym_def. Ignore" + puts "has_included_subcircuit: $symname: no matching .subckt found in spice_sym_def. Ignore" if { [info exists has_x] } { - alert_ "has_included_subcircuit: no matching .subckt found in spice_sym_def. Ignore" + alert_ "has_included_subcircuit: $symname: no matching .subckt found in spice_sym_def. Ignore" } } return $pinlist diff --git a/xschem_library/Makefile b/xschem_library/Makefile index 89401603..f710925a 100644 --- a/xschem_library/Makefile +++ b/xschem_library/Makefile @@ -15,6 +15,7 @@ install: FORCE $(SCCBOX) install -f -d devices/*.sch "$(system_library_dir)" $(SCCBOX) install -f -d examples/*.sym "$(XDOCDIR)"/examples $(SCCBOX) install -f -d examples/*.sch "$(XDOCDIR)"/examples + $(SCCBOX) install -f -d examples/*.cir "$(XDOCDIR)"/examples $(SCCBOX) install -f -d examples/stimuli.* "$(XDOCDIR)"/examples $(SCCBOX) install -f -d binto7seg/*.sym "$(XDOCDIR)"/binto7seg $(SCCBOX) install -f -d binto7seg/*.sch "$(XDOCDIR)"/binto7seg diff --git a/xschem_library/examples/0_examples_top.sch b/xschem_library/examples/0_examples_top.sch index 6bb095c8..8a1e83e7 100644 --- a/xschem_library/examples/0_examples_top.sch +++ b/xschem_library/examples/0_examples_top.sch @@ -108,7 +108,7 @@ N 410 -350 410 -320 {lab=BUS[2]} N 460 -400 460 -320 {lab=BUS[2:1]} N 860 -460 860 -390 {lab=#net2} N 820 -420 910 -420 {lab=#net1} -C {poweramp.sym} 480 -900 0 0 {name=x1 +C {poweramp.sym} 160 -140 0 0 {name=x1 tclcommand="xschem descend"} C {tesla.sym} 160 -700 0 0 {name=x2} C {test_ne555.sym} 160 -660 0 0 {name=x3} @@ -1481,18 +1481,19 @@ C {test_ac.sym} 160 -340 0 0 {name=x15} C {rom8k.sym} 160 -180 0 0 {name=x17} C {test_doublepin.sym} 160 -300 0 0 {name=x19} C {classD_amp.sym} 160 -220 0 0 {name=x20} -C {delta_sigma.sym} 480 -820 0 0 {name=x21} -C {solar_panel.sym} 480 -780 0 0 {name=xsolar} +C {delta_sigma.sym} 480 -900 0 0 {name=x21} +C {solar_panel.sym} 480 -860 0 0 {name=xsolar} C {test_extracted_netlist.sym} 160 -260 0 0 {name=x23 tclcommand="xschem descend"} -C {poweramp_lcc.sym} 480 -860 0 0 {name=x16 +C {poweramp_lcc.sym} 160 -100 0 0 {name=x16 tclcommand="xschem descend"} -C {test_symbolgen.sym} 480 -740 0 0 {name=x18} -C {inst_sch_select.sym} 480 -700 0 0 {name=x24} -C {test_bus_tap.sym} 480 -660 0 0 {name=x22} +C {test_symbolgen.sym} 480 -820 0 0 {name=x18} +C {inst_sch_select.sym} 480 -740 0 0 {name=x24} +C {test_bus_tap.sym} 480 -700 0 0 {name=x22} C {bus_tap.sym} 450 -310 1 1 {name=l5 lab=[2:1]} -C {test_jfet.sym} 480 -620 0 0 {name=x25} -C {test_short_option.sym} 480 -580 0 0 {name=x26} -C {test_lvs_ignore.sym} 480 -540 0 0 {name=x27} -C {test_generators.sym} 480 -500 0 0 {name=x28} -C {autozero_comp.sym} 480 -460 0 0 {name=x29} +C {test_jfet.sym} 480 -660 0 0 {name=x25} +C {test_short_option.sym} 480 -620 0 0 {name=x26} +C {test_lvs_ignore.sym} 480 -580 0 0 {name=x27} +C {test_generators.sym} 480 -540 0 0 {name=x28} +C {autozero_comp.sym} 480 -500 0 0 {name=x29} +C {tb_symbol_include.sym} 480 -780 0 0 {name=x30} diff --git a/xschem_library/examples/symbol_include.cir b/xschem_library/examples/symbol_include.cir new file mode 100644 index 00000000..b1365b53 --- /dev/null +++ b/xschem_library/examples/symbol_include.cir @@ -0,0 +1,7 @@ +* example of a subcircuit contained in a file + +.subckt symbol_include Z VCC VSS ++ A B C W=10 L=1 +... +... +.ends diff --git a/xschem_library/examples/symbol_include.sch b/xschem_library/examples/symbol_include.sch new file mode 100644 index 00000000..410f5e77 --- /dev/null +++ b/xschem_library/examples/symbol_include.sch @@ -0,0 +1,11 @@ +v {xschem version=3.4.5 file_version=1.2} +G {} +V {} +E {} +S {} +C {ipin.sym} -120 0 0 0 {name=g0 lab=A } +C {ipin.sym} -120 20 0 0 {name=g1 lab=B } +C {ipin.sym} -120 40 0 0 {name=g2 lab=C } +C {ipin.sym} -120 60 0 0 {name=g3 lab=VCC } +C {ipin.sym} -120 80 0 0 {name=g4 lab=VSS } +C {opin.sym} 120 0 0 0 {name=g5 lab=Z } diff --git a/xschem_library/examples/symbol_include.sym b/xschem_library/examples/symbol_include.sym new file mode 100644 index 00000000..18edb633 --- /dev/null +++ b/xschem_library/examples/symbol_include.sym @@ -0,0 +1,52 @@ +v {xschem version=3.4.5 file_version=1.2 +} +G {} +K {type=subcircuit +format="@name @pinlist @symname" +template="name=x1" +comm="default_schematic=ignore will prevent netlisting the symbol definition, + only definitions contained in instance schematic=... will be used" +xdefault_schematic=ignore + +comm="following spice_sym_def includes a file with the subckt definition" +spice_sym_def=".include symbol_include.cir" + +comm="following spice_sym_def directly contains the definition of the subckt" +xxspice_sym_def=" +.subckt symbol_include Z VCC VSS ++ A B C +... +... +.ends +"} +V {} +S {} +E {} +L 4 -130 -50 130 -50 {} +L 4 -130 50 130 50 {} +L 4 -130 -50 -130 50 {} +L 4 130 -50 130 50 {} +L 4 -150 -40 -130 -40 {} +L 4 -150 -20 -130 -20 {} +L 4 -150 0 -130 0 {} +L 4 130 -40 150 -40 {} +L 4 -150 20 -130 20 {} +L 4 -150 40 -130 40 {} +B 5 -152.5 -42.5 -147.5 -37.5 {name=A dir=in} +B 5 -152.5 -22.5 -147.5 -17.5 {name=B dir=in} +B 5 -152.5 -2.5 -147.5 2.5 {name=C dir=in} +B 5 147.5 -42.5 152.5 -37.5 {name=Z dir=out} +B 5 -152.5 17.5 -147.5 22.5 {name=VCC dir=in} +B 5 -152.5 37.5 -147.5 42.5 {name=VSS dir=in} +T {@symname} -81 -6 0 0 0.3 0.3 {} +T {@name} 135 -62 0 0 0.2 0.2 {} +T {A} -125 -44 0 0 0.2 0.2 {} +T {B} -125 -24 0 0 0.2 0.2 {} +T {C} -125 -4 0 0 0.2 0.2 {} +T {Z} 125 -44 0 1 0.2 0.2 {} +T {VCC} -125 16 0 0 0.2 0.2 {} +T {VSS} -125 36 0 0 0.2 0.2 {} +T {This symbol has attribute "spice_sym_def" +that references a .subckt file. +The port order of the symbol instance call +will match the order in the .subckt} -190 -210 0 0 0.4 0.4 {hide=instance layer=6} diff --git a/xschem_library/examples/symbol_include2.cir b/xschem_library/examples/symbol_include2.cir new file mode 100644 index 00000000..b1365b53 --- /dev/null +++ b/xschem_library/examples/symbol_include2.cir @@ -0,0 +1,7 @@ +* example of a subcircuit contained in a file + +.subckt symbol_include Z VCC VSS ++ A B C W=10 L=1 +... +... +.ends diff --git a/xschem_library/examples/symbol_include2.sch b/xschem_library/examples/symbol_include2.sch new file mode 100644 index 00000000..410f5e77 --- /dev/null +++ b/xschem_library/examples/symbol_include2.sch @@ -0,0 +1,11 @@ +v {xschem version=3.4.5 file_version=1.2} +G {} +V {} +E {} +S {} +C {ipin.sym} -120 0 0 0 {name=g0 lab=A } +C {ipin.sym} -120 20 0 0 {name=g1 lab=B } +C {ipin.sym} -120 40 0 0 {name=g2 lab=C } +C {ipin.sym} -120 60 0 0 {name=g3 lab=VCC } +C {ipin.sym} -120 80 0 0 {name=g4 lab=VSS } +C {opin.sym} 120 0 0 0 {name=g5 lab=Z } diff --git a/xschem_library/examples/tb_symbol_include.sch b/xschem_library/examples/tb_symbol_include.sch new file mode 100644 index 00000000..1656657f --- /dev/null +++ b/xschem_library/examples/tb_symbol_include.sch @@ -0,0 +1,29 @@ +v {xschem version=3.4.5 file_version=1.2 +} +G {} +K {} +V {} +S {} +E {} +T {Control + left mouse button on +the symbol to see the +symbol_include.cir file} 290 -130 0 0 0.3 0.3 {} +C {symbol_include.sym} 410 -190 0 0 {name=x1 +tclcommand="textwindow [xschem get current_dirname]/symbol_include.cir" + +comm="following instance attributes (now 'x' commented) specify an alternate + symbol reference to use in netlist" +xspice_sym_def=".include symbol_include2.cir" +xschematic="symbol_include2.sch"} +C {lab_pin.sym} 260 -230 0 0 {name=p1 lab=XA} +C {lab_pin.sym} 260 -210 0 0 {name=p2 lab=XB} +C {lab_pin.sym} 260 -190 0 0 {name=p3 lab=XC} +C {lab_pin.sym} 560 -230 0 1 {name=p4 lab=XZ} +C {lab_pin.sym} 260 -170 0 0 {name=p5 lab=XVCC} +C {lab_pin.sym} 260 -150 0 0 {name=p6 lab=XVSS} +C {opin.sym} 120 -70 0 0 { name=p7 lab=XZ } +C {ipin.sym} 80 -70 0 0 { name=p8 lab=XVSS } +C {ipin.sym} 80 -90 0 0 { name=p9 lab=XVCC } +C {ipin.sym} 80 -110 0 0 { name=p10 lab=XC } +C {ipin.sym} 80 -130 0 0 { name=p11 lab=XB } +C {ipin.sym} 80 -150 0 0 { name=p12 lab=XA } diff --git a/xschem_library/examples/tb_symbol_include.sym b/xschem_library/examples/tb_symbol_include.sym new file mode 100644 index 00000000..7d857e12 --- /dev/null +++ b/xschem_library/examples/tb_symbol_include.sym @@ -0,0 +1,11 @@ +v {xschem version=3.4.5 file_version=1.2} +K {type=subcircuit +format="@name @pinlist @symname" +template="name=x1" +} +T {@symname} -94.5 -6 0 0 0.3 0.3 {} +T {@name} 135 -22 0 0 0.2 0.2 {} +L 4 -130 -10 130 -10 {} +L 4 -130 10 130 10 {} +L 4 -130 -10 -130 10 {} +L 4 130 -10 130 10 {}