integrated create_symbol.tcl in xschem.tcl, some old version strings updated in scripts, some code indenting fixes

This commit is contained in:
stefan schippers 2025-02-01 00:03:12 +01:00
parent 752f794c96
commit e471f577fa
9 changed files with 47 additions and 69 deletions

View File

@ -17,7 +17,6 @@ put /local/install_shares {
add_custom_button.tcl change_index.tcl icon.xpm resources.tcl xschemrc
ngspice_backannotate.tcl gschemtoxschem.awk mouse_bindings.tcl
place_sym_pins.tcl place_pins.tcl make_sch_from_spice.awk make_sym_from_spice.awk
create_symbol.tcl
}
# generate a list of objects from the list of source files

View File

@ -1,61 +0,0 @@
#
# File: create_symbol.tcl
#
# This file is part of XSCHEM,
# a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit
# simulation.
# Copyright (C) 1998-2024 Stefan Frederik Schippers
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Create an xschem symbol from a list of in, inout, out pins.
# Example:
# create_symbol test.sym {CLK RST D} {Q QB} {VCC VSS}
#
proc create_symbol {name {in {}} {out {}} {inout {}}} {
set symname [file rootname $name].sym
set res [catch {open $symname {WRONLY CREAT EXCL}} fd]
if {$res} {puts $fd; return 0} ;# Error. Print reason and exit.
puts $fd {v {xschem version=3.4.6RC file_version=1.2}}
puts $fd {K {type=subcircuit format="@name @pinlist @symname" template="name=X1"}}
set x -150
set y 0
foreach pin $in { ;# create all input pins on the left
puts $fd "B 5 [expr {$x - 2.5}] [expr {$y - 2.5}] [expr {$x + 2.5}] [expr {$y + 2.5}] {name=$pin dir=in}"
puts $fd "T {$pin} [expr {$x + 25}] [expr {$y - 6}] 0 0 0.2 0.2 {}"
puts $fd "L 4 $x $y [expr {$x + 20}] $y {}"
incr y 20
}
set x 150
set y 0
foreach pin $out { ;# create all out pins on the top right
puts $fd "B 5 [expr {$x - 2.5}] [expr {$y - 2.5}] [expr {$x + 2.5}] [expr {$y + 2.5}] {name=$pin dir=out}"
puts $fd "T {$pin} [expr {$x - 25}] [expr {$y - 6}] 0 1 0.2 0.2 {}"
puts $fd "L 4 [expr {$x - 20}] $y $x $y {}"
incr y 20
}
foreach pin $inout { ;# create all inout pins on the bottom right
puts $fd "B 5 [expr {$x - 2.5}] [expr {$y - 2.5}] [expr {$x + 2.5}] [expr {$y + 2.5}] {name=$pin dir=inout}"
puts $fd "T {$pin} [expr {$x - 25}] [expr {$y - 6}] 0 1 0.2 0.2 {}"
puts $fd "L 7 [expr {$x - 20}] $y $x $y {}"
incr y 20
}
puts $fd "B 4 -130 -10 130 [expr {$y - 10}] {fill=0}" ;# symbol box
puts $fd "T {@symname} 0 [expr {($y - 20) / 2}] 0 0 0.3 0.3 {hcenter=1 vcenter=1}" ;#symbol name
puts $fd "T {@name} 130 -10 2 1 0.2 0.2 {}" ;# instance name
close $fd
puts "Created symbol ${symname}"
return 1
}

View File

@ -700,7 +700,7 @@ function print_sym(sym, template, format, subckt_name, sym_type, extra, dir, pin
print "start print symbol: " sym
print "v {xschem version=3.4.6RC file_version=1.2}" > sym
print "v {xschem version=3.4.6 file_version=1.2}" > sym
print "K {type=" sym_type > sym
# print "format=\"@name @pinlist @symname " format_translate(template) "\"" > sym
iii = format_translate(template, extra)

View File

@ -68,7 +68,7 @@ function beginfile(f)
text_voffset=20
lab_voffset=4
ip=op=n_pin=0
print "v {xschem version=3.4.6RC file_version=1.2}" > sym
print "v {xschem version=3.4.6 file_version=1.2}" > sym
if(template !~/^{[ \t\n]*$/) {
printf "%s", "K {type=subcircuit\nformat=\"@name @pinlist @symname\"\n" >sym
printf "%s\n", "template=\"name=x1\"" >sym

View File

@ -401,7 +401,7 @@ function print_sym(sym, template, format, subckt_name, sym_type, extra, dir, pin
print "start print symbol: " sym
print "v {xschem version=3.4.6RC file_version=1.2}" > sym
print "v {xschem version=3.4.6 file_version=1.2}" > sym
print "K {type=" sym_type > sym
# print "format=\"@name @pinlist @symname " format_translate(template) "\"" > sym
iii = format_translate(template, extra)

View File

@ -61,7 +61,7 @@ function beginfile(f)
text_voffset=10
lab_voffset=4
ip=op=n_pin=n_p=n_l=0
print "v {xschem version=2.9.8 file_version=1.2}" > sym
print "v {xschem version=3.4.6 file_version=1.2}" > sym
if(template=="") {
printf "%s", "K {type=subcircuit\nformat=\"@name @pinlist @symname\"\n" >sym
printf "%s\n", "template=\"name=x1\"" >sym

View File

@ -1704,8 +1704,8 @@ int sym_vs_sch_pins(int all)
fprintf(errfp,"sym_vs_sch_pins(): WARNING: missing fields for LINE/BOX object, ignoring\n");
read_line(fd, 0);
break;
}
load_ascii_string(&tmp, fd);
}
load_ascii_string(&tmp, fd);
break;
case 'P':
if(fscanf(fd, "%d %d",&tmpi, &tmpi)<2) {

View File

@ -393,7 +393,7 @@ function attrs(a)
function header()
{
print "v {xschem version=3.4.6RC file_version=1.2}"
print "v {xschem version=3.4.6 file_version=1.2}"
}
function round(n)

View File

@ -4874,6 +4874,46 @@ proc add_lab_prefix {} {
xschem merge $USER_CONF_DIR/.clipboard.sch
}
# Create an xschem symbol from a list of in, out, inout pins.
# Example:
# create_symbol test.sym {CLK RST D} {Q QB} {VCC VSS}
#
proc create_symbol {name {in {}} {out {}} {inout {}}} {
set symname [file rootname $name].sym
set res [catch {open $symname {WRONLY CREAT EXCL}} fd]
if {$res} {puts $fd; return 0} ;# Error. Print reason and exit.
puts $fd {v {xschem version=3.4.6 file_version=1.2}}
puts $fd {K {type=subcircuit format="@name @pinlist @symname" template="name=X1"}}
set x -150
set y 0
foreach pin $in { ;# create all input pins on the left
puts $fd "B 5 [expr {$x - 2.5}] [expr {$y - 2.5}] [expr {$x + 2.5}] [expr {$y + 2.5}] {name=$pin dir=in}"
puts $fd "T {$pin} [expr {$x + 25}] [expr {$y - 6}] 0 0 0.2 0.2 {}"
puts $fd "L 4 $x $y [expr {$x + 20}] $y {}"
incr y 20
}
set x 150
set y 0
foreach pin $out { ;# create all out pins on the top right
puts $fd "B 5 [expr {$x - 2.5}] [expr {$y - 2.5}] [expr {$x + 2.5}] [expr {$y + 2.5}] {name=$pin dir=out}"
puts $fd "T {$pin} [expr {$x - 25}] [expr {$y - 6}] 0 1 0.2 0.2 {}"
puts $fd "L 4 [expr {$x - 20}] $y $x $y {}"
incr y 20
}
foreach pin $inout { ;# create all inout pins on the bottom right
puts $fd "B 5 [expr {$x - 2.5}] [expr {$y - 2.5}] [expr {$x + 2.5}] [expr {$y + 2.5}] {name=$pin dir=inout}"
puts $fd "T {$pin} [expr {$x - 25}] [expr {$y - 6}] 0 1 0.2 0.2 {}"
puts $fd "L 7 [expr {$x - 20}] $y $x $y {}"
incr y 20
}
puts $fd "B 4 -130 -10 130 [expr {$y - 10}] {fill=0}" ;# symbol box
puts $fd "T {@symname} 0 [expr {($y - 20) / 2}] 0 0 0.3 0.3 {hcenter=1 vcenter=1}" ;#symbol name
puts $fd "T {@name} 130 -10 2 1 0.2 0.2 {}" ;# instance name
close $fd
puts "Created symbol ${symname}"
return 1
}
proc make_symbol {name {ask {no}} } {
global XSCHEM_SHAREDIR symbol_width
set name [abs_sym_path $name ]