From 8fe4f2fd11a6f4a7364979b83f95a455b50bb92a Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Thu, 28 Sep 2023 16:09:06 +0200 Subject: [PATCH] add src/place_pins.tcl, src/place_sym_pins.tcl --- src/place_pins.tcl | 35 ++++++++++++++++++++++++++++++ src/place_sym_pins.tcl | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 src/place_pins.tcl create mode 100644 src/place_sym_pins.tcl diff --git a/src/place_pins.tcl b/src/place_pins.tcl new file mode 100644 index 00000000..c74a4807 --- /dev/null +++ b/src/place_pins.tcl @@ -0,0 +1,35 @@ + +# from a 'pinlist' file like the one below: +# vss 1 +# vccsa 2 +# vccdec 3 +# LDYMS[15:0] 4 +# LDSAL 5 +# LDPRECH 6 +# +# place pin symbols (like ipin.sym, opin.sym, iopin.sym, +# or devices/ipin.sym depending on your search path setting) in current schematic. +# Pins are placed at growing y coordinates (going down in xschem coordinate system) +# parameters: +# filename: name for the file holding the list of pins. +# 2 columns are assumed: pin name and pin number +# symname: name of the pin to place (ipin.sym, opin.sym, devices/ipin.sym, ...). +# x, y: coordinate for first pin +# spacing: vertical spacing between one pin and the following. +# +proc place_pins {filename symname {x 0} {y 0} {spacing 40}} { + set i 0 + set fd [open $filename r] + set pinlist [read -nonewline $fd] + close $fd + foreach {name num} $pinlist { + puts "$name num" + # xschem instance sym_name x y rot flip [prop] [n] + xschem instance $symname $x $y 0 0 "name=p$num lab=$name" $i + incr i + incr y $spacing + } + xschem redraw +} + + diff --git a/src/place_sym_pins.tcl b/src/place_sym_pins.tcl new file mode 100644 index 00000000..2bb142ea --- /dev/null +++ b/src/place_sym_pins.tcl @@ -0,0 +1,48 @@ +# from a 'pinlist' file like the one below: +# vss 1 +# vccsa 2 +# vccdec 3 +# LDYMS[15:0] 4 +# LDSAL 5 +# LDPRECH 6 +# +# place pin objects (squares on layer 5) and labels in the current symbol window. +# pins are placed at growing y coordinates (going down in xschem coordinate system) +# parameters: +# filename: name for the file holding the list of pins. +# 2 columns are assumed: pin name and pin number +# dir: pin direction (in, out or inout) +# x, y: coordinate for first pin +# spacing: vertical spacing between one pin and the following. +# +proc place_sym_pins {filename dir {x 0} {y 0} {spacing 20}} { + set fd [open $filename r] + set pinlist [read -nonewline $fd] + if {$dir == {in} } { + set flip 0 + set offset 25 + set line_offset 20 + } else { + set flip 1 + set offset -25 + set line_offset -20 + } + close $fd + foreach {name num} $pinlist { + puts "$name num" + set x1 [expr {$x - 2.5}] + set x2 [expr {$x + 2.5}] + set y1 [expr {$y - 2.5}] + set y2 [expr {$y + 2.5}] + xschem set rectcolor 5 ;# symbol pin layer + xschem rect $x1 $y1 $x2 $y2 -1 "name=$name dir=$dir" 0 + xschem set rectcolor 4 ;# symbol line color + xschem line $x $y [expr {$x + $line_offset}] $y {} 0 + xschem create_text 0 [expr {$x + $offset}] [expr {$y - 4}] 0 $flip $name {} 0.2 + incr y $spacing + } + xschem set schsymbolprop "type=subcircuit\nformat=\"@name @pinlist @symname\"\ntemplate=\"name=X1\"" + xschem redraw +} + +