DEVELOPER INFO
GENERAL INFORMATION
XSCHEM uses layers for its graphics, each layer is a logical entity defining graphic attributes like color and fill style. There are very few graphical primitive objects:
- Lines
- Rectangles
- Open / close Polygons
- Arcs / Circles
- Text
These primitive objects can be drawn on any layer. XSCHEM number of layers can be defined at compile time, however there are some predefiend layers (from 0 to 5) that have specific functions:
- Background color
- Wire color (nets)
- Selection color / grid
- Text color
- Symbol drawing color
- Pin color
- General purpose
- General purpose
- General purpose
....
- General purpose
- General purpose
Although any layer can be used for drawing it is strongly advisable to avoid the background color and the selection color to avoid confusion. Drawing begins by painting the background (layer 0), then drawing the grid (layer 1) then drawing wires (nets) on layer 2, then all graphical objects (lines, rectangles, polygons) starting form layer 0 to the last defined layer.
SYMBOLS
There is a primitive object called symbol. Symbols are just a group of primitive graphic objects (lines, polygons, rectangles, text) that can be shown as a single atomic entity. Once created a symbol can be placed in a schematic. The instantiation of a symbol is called 'component'.

The above picture shows a resistor symbol, built drawing some lines on layer 4 (green), some pins on layer 5 (red) and some text. Symbols once created are stored in libraries (library is just a UNIX directory known to XSCHEM) and can be placed like just any other primitive object multiple times in a schematic window with different orientations.

WIRES
Another special primitive object in XSCHEM is 'Wire', Graphically it is drawn as a line on layer 1 (wires). Wires are drawn only on this layer, they are treated differently by XSCHEM since they carry electrical information. Electrical connection between components is done by drawing a connecting wire.
Since wires are used to build the circuit connectivity it is best to avoid drawing lines on layer 1 to avoid confusion, since they would appear like wires, but ignored completely for electrical connectivity.
PROPERTIES
All XSCHEM objects (wires, lines, rectangles, polygons, text, symbol instance aka component) have a property string attached. Any text can be present in a property string, however in most cases the property string is organized as a set of key=value pairs separated by white space. In addition to object properties the schematic or symbol view has global properties attached. There is one global property defined per netlisting mode (currently SPICE, VHDL, Verilog, tEDAx) and one additional global property for symbols (containing the netlisting rules usually). See the XSCHEM properties section of the manual for more info.
COORDINATE SYSTEM
XSCHEM coordinates are stored as double precision floating point numbers, axis orientation is the same as Xorg default coordinate orientation:

When drawing objecs in XSCHEM coordinates are snapped to a multiple of 10.0 coordinate units, so all drawn objects are easily aligned. The snap level can be changed to any value by the user to allow drawing small objects if desired. Grid points are shown at multiples of 20.0 coordinate units, by default.
XSCHEM FILE FORMAT SPECIFICATION
XSCHEM schematics and symbols are stored in .sch and .sym files respectively. The two file formats are identical, with the exception that symbol (.sym) files usually do not contain wires and component instantiations (although they can).
every schematic/symbol object has a corresponding record in the file. A single character at the beginning of a line, separated by white space from subsequent fields marks the type of object:
- v : XSCHEM Version string
- S : Global property associated to the .sch file for SPICE netlisting
- V : Global property associated to the .sch file for VERILOG netlisting
- G : Global property associated to the .sch file for VHDL netlisting OR Global property associated to the .sym file for netlisting (in 1,2 file format K is used, although backward compatibility is guaranteed)
- E : Global property associated to the .sch file for tEDAx netlisting
- K : Global property associated to the .sch/sym file for netlisting.
For schematic it is used if instantiated as a component (file format 1.2 and newer) - L : Line
- B : Rectangle
- P : Open / Closed polygon
- A : Arc / Circle
- T : Text
- N : Wire, used to connect together components (only in .sch files)
- C : Component instance in a schematic (only in .sch files)
- [ : Start of a symbol embedding, the symbol refers to the immediately preceding component instance. This tag must immediately follow a component instance (C). See the example here under. A component symbol is embedded into the schematic file when saving if the embed=true attribute is set on one of the component instances. Only one copy of the embedded symbol is saved into the schematic and all components referring to this symbol will use the embedded definition. When a component has an embedded symbol definition immediately following, a embed=true is added to the component property string if not already present.
C {TECHLIB/PCH} 620 -810 0 0 {name=x5 model=PCHLV w=4 l=0.09 m=1 embed=true} [ v {xschem version=2.9.7 file_version=1.2} G {} K {type=pmos format="@name @pinlist @model w=@w l=@l m=@m" verilog_format="@verilog_gate #(@del ) @name ( @@d , @@s , @@g );" template=" name=x1 verilog_gate=pmos del=50,50,50 model=PCH w=0.68 l=0.07 m=1 " generic_type="model=string" } V {} S {} E {} L 4 5 20 20 20 {} L 4 20 20 20 30 {} L 4 5 -20 20 -20 {} L 4 20 -30 20 -20 {} L 4 -20 0 -10 0 {} L 4 5 -27.5 5 27.5 {11} L 4 5 -5 10 0 {} L 4 5 5 10 0 {} L 4 10 0 20 0 {} L 18 -2.5 -15 -2.5 15 {} B 5 17.5 27.5 22.5 32.5 {name=d dir=inout} B 5 -22.5 -2.5 -17.5 2.5 {name=g dir=in} B 5 17.5 -32.5 22.5 -27.5 {name=s dir=inout} B 5 17.5 -2.5 22.5 2.5 {name=b dir=in} A 4 -6.25 0 3.75 270 360 {} T {@w/@l*@m} 7.5 -17.5 0 0 0.2 0.2 {} T {@name} 7.5 6.25 0 0 0.2 0.2 {999} T {@model} 2.5 -27.5 0 1 0.2 0.2 {layer=8} T {D} 25 17.5 0 0 0.15 0.15 {layer=13} T {NF=@nf} -5 -15 0 1 0.15 0.15 {} ]
the object tag in column 1 is followed by space separated fields that completely define the corresponding object.
VERSION STRING
Example:
v {xschem version=2.9.7 file_version=1.2}
Two attributes are defined, the xschem version and the file format version. Current file format version is 1.2. This string is guaranteed to be the first one in XSCHEM .sch and .sym files. A comment can be added (by manually editing the xschem schematic or symbol file) as shown below:
v {xschem version=3.1.0 file_version=1.2 * Copyright 2022 Stefan Frederik Schippers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. }
GLOBAL SCHEMATIC/SYMBOL PROPERTIES
Example:
K {type=regulator
format="x@name @pinlist r@symname"
verilog_format="assign @#2 = @#0 ;"
tedax_format="footprint @name @footprint
device @name @symname"
template="name=U1 footprint=TO220"}
Global properties define a property string bound to the parent schematic/symbol file,
there is one global property record per netlisting mode,
currently SPICE, VHDL, Verilog, tEDAx.
In addition (only in file_format 1.2 and newer) for schematics and symbols there is a global attribute ('K')
that defines how to netlist the schematic/symbol if placed as a
symbol into another parent schematic (should be set in the same way as the 'G' global attribute for symbols
in pre-1.2 file format).
Normally only 'G' ('K' in 1.2 file format) type property strings are used for symbols and define attributes
telling netlisters what to do with the symbol, while global property
strings in schematic files corresponding to the active netlisting mode of XSCHEM are
copied verbatim to the netlist.
the object tag (S, V, G, E, K) is followed by the property string enclosed in curly braces
({...}). This allows strings to contain any white space and newlines.
Curly braces if present in the string are automatically escaped with the '\' character
by XSCHEM when saving data.
Example of the 4 property string records for a schematic file:
G {}
V {assign #1500 LDOUT = LDIN +1;
}
E {}
S {}
in this case only the verilog-related global property has some definition. This is Verilog code that is copied into the output netlist.
Attribute strings for all Xschem objects are enclosed in curly braces.
This allows attributes to span multiple lines.
This component instance:
C {capa.sym} 890 -160 0 0 {name=C4 m=1 value=10u device="tantalium capacitor"}
and this one:
C {capa.sym} 890 -160 0 0 {name=C4
m=1 value=10u
device="tantalium capacitor"
}
are perfectly equivalent.
TEXT OBJECT
Example: T {3 of 4 NANDS of a 74ls00} 500 -580 0 0 0.4 0.4 {font=Monospace layer=4}
This line defines a text object, the first field after the type tag is the displayed text,
followed by X and Y coordinates,rotation, mirror,
horizontal and vertical text size and finally a property string defining some text attributes.
- The displayed text is enclosed in curly braces ({...}) to allow white space. Literal curly braces must be escaped if present in the saved string. XSCHEM will automatically add the escapes where needed on save.
- X ad Y coordinates are saved and retrieved as double precision floating point numbers.
- Rotation and mirror are integers (range [0:3], [0:1] respectively) that define the orientation
of text objects. Using rotation and mirror text can be aligned to any corner of its bounding box, so there are 4 different
alignments for vertical text and 4 different alignments for horizontal text. Below picture shows how text is displayed
with respect to its anchor point.
- text X and Y sizes are stored as floating point numbers.
- Finally a property string is stored with the same syntax as the displayed text field.
Currently the following attributes are predefined for text objects:
- font Name of font to be used (ex: font=Arial)
- layer Number of layer to use for drawing (as in Xschem Layers menu)
- hcenter If set to true horizontal center text
- vcenter If set to true vertical center text
- weight If set to bold use bold style
- slant If set to italic or oblique use that style for text
WIRE OBJECT
Example: N 890 -130 890 -110 {lab=ANALOG_GND}
The net 'N' tag is followed by the end point coordinates x1,y1 - x2,y2.
(stored and read as double precision numbers) and a property string, used in this case to name the net.
In most cases you don't need to specify attributes for nets (one exception is the bus attribute)
as the lab attribute is set by xschem when creating a netlist or more generally when
building the connectivity.
This means that almost always nets in a xschem schematic are set as in following example:
N 890 -130 890 -110 {}
Xschem schematic files store only geometrical data and attributes of the graphic primitives,
the connectivity and the logical network is obtained by xschem.
LINE OBJECT
Example: L 4 -50 20 50 20 {This is a line on layer 4}
The line 'L' tag is followed by an integer specifying the graphic layer
followed by the x1,y1 - x2,y2 coordinates of the line and a property string.
RECTANGLE OBJECT
Example: B 5 -62.5 -2.5 -57.5 2.5 {name=IN dir=in pinnumber=1}
The 'Box' 'B' tag is followed by an integer specifying the graphic layer followed
by the x1,y1 - x2,y2 coordinates of the rectangle
and a final property string. This example defines a symbol pin.
OPEN / CLOSED POLYGON OBJECT
Example: P 3 5 2450 -210 2460 -170 2500 -170 2510 -210 2450 -210 {}
the Polygon 'P' tag is followed by an integer specifying the layer number,
followed by the number of points (integer),
the x,y coordinates of the polygon points and the property string (empty in this example).
If the last point is coincident to the first point a closed polygon is drawn.
A 'fill=true' arribute may be given to fill a closed polygon, in this case a polygon line looks like:
P 3 5 2450 -210 2460 -170 2500 -170 2510 -210 2450 -210 {fill=true}
ARC OBJECT
Example: A 3 450 -210 120 45 225 {}
The Arc 'A' tag is followed by an integer specifying the layer number, followed by the arc x, y center coordinates,
the arc radius, the start angle (measured counterclockwise from the three o'clock direction), the arc sweep angle
(measured counterclockwise from the start angle) and the property string (empty in this example).
Angles are measured in degrees.
COMPONENT INSTANCE
Example: C {capa.sym} 890 -160 0 0 {name=C4 m=1 value=10u device="tantalium capacitor"}
Format: C {<symbol reference>} <X coord> <Y coord> <rotation>
<flip> {<attributes>}
The component instance tag C is followed by a string specifying library/symbol or only symbol
(see This tutorial about symbol references)
followed by the x,y coordinates, rotation (integer range [0:3]),
mirror (integer range [0:1]), and a property string defining various attributes
including the mandatory name=... attribute.
Orientation and mirror meanings are as follows:
EXAMPLE OF A COMPLETE SYMBOL FILE (7805.sym)
G {} K {type=regulator format="x@name @pinlist r@symname" verilog_format="assign @#2 = @#0 ;" tedax_format="footprint @name @footprint device @name @symname" template="name=U1 footprint=TO220"} V {} S {} E {} L 4 -60 0 -50 0 {} L 4 50 0 60 0 {} L 4 -50 -20 50 -20 {} L 4 50 -20 50 20 {} L 4 -50 20 50 20 {} L 4 -50 -20 -50 20 {} L 4 0 20 0 30 {} B 5 -62.5 -2.5 -57.5 2.5 {name=IN dir=in pinnumber=1} B 5 -2.5 27.5 2.5 32.5 {name=GND dir=inout pinnumber=2} B 5 57.5 -2.5 62.5 2.5 {name=OUT dir=out pinnumber=3} T {@name} -17.5 -15 0 0 0.2 0.2 {} T {@symname} -17.5 0 0 0 0.2 0.2 {} T {@#0:pinnumber} -47.5 -2.5 0 0 0.12 0.12 {} T {@#1:pinnumber} -2.5 12.5 0 0 0.12 0.12 {} T {@#2:pinnumber} 47.5 -2.5 0 1 0.12 0.12 {}

EXAMPLE OF A COMPLETE SCHEMATIC FILE (pcb_test1.sch)
G {} K {} V {} S {} E {} B 20 270 -550 860 -290 {} T {3 of 4 NANDS of a 74ls00} 500 -580 0 0 0.4 0.4 {} T {EXPERIMENTAL schematic for generating a tEDAx netlist 1) set netlist mode to 'tEDAx' (Options menu -> tEDAx netlist) 2) press 'Netlist' button on the right 3) resulting netlist is in pcb_test1.tdx } 240 -730 0 0 0.5 0.5 {} N 230 -330 300 -330 {lab=INPUT_B} N 230 -370 300 -370 {lab=INPUT_A} N 680 -420 750 -420 {lab=B} N 680 -460 750 -460 {lab=A} N 400 -350 440 -350 {lab=B} N 850 -440 890 -440 {lab=OUTPUT_Y} N 230 -440 300 -440 {lab=INPUT_F} N 230 -480 300 -480 {lab=INPUT_E} N 400 -460 440 -460 {lab=A} N 550 -190 670 -190 {lab=VCCFILT} N 590 -130 590 -110 {lab=ANALOG_GND} N 790 -190 940 -190 {lab=VCC5} N 890 -130 890 -110 {lab=ANALOG_GND} N 730 -110 890 -110 {lab=ANALOG_GND} N 730 -160 730 -110 {lab=ANALOG_GND} N 590 -110 730 -110 {lab=ANALOG_GND} N 440 -460 680 -460 {lab=A} N 500 -420 680 -420 {lab=B} N 500 -420 500 -350 {lab=B} N 440 -350 500 -350 {lab=B} C {title.sym} 160 -30 0 0 {name=l2 author="Stefan"} C {74ls00.sym} 340 -350 0 0 {name=U1:2 risedel=100 falldel=200} C {74ls00.sym} 790 -440 0 0 {name=U1:1 risedel=100 falldel=200} C {lab_pin.sym} 890 -440 0 1 {name=p0 lab=OUTPUT_Y} C {capa.sym} 590 -160 0 0 {name=C0 m=1 value=100u device="electrolitic capacitor"} C {74ls00.sym} 340 -460 0 0 {name=U1:4 risedel=100 falldel=200 power=VCC5 url="http://www.engrcs.com/components/74LS00.pdf".sym} C {LM7805.pdf"} C {lab_pin.sym} 490 -190 0 0 {name=p20 lab=VCC12} C {lab_pin.sym} 940 -190 0 1 {name=p22 lab=VCC5} C {lab_pin.sym} 590 -110 0 0 {name=p23 lab=ANALOG_GND} C {capa.sym} 890 -160 0 0 {name=C4 m=1 value=10u device="tantalium capacitor"} C {res.sym} 520 -190 1 0 {name=R0 m=1 value=4.7 device="carbon resistor"} C {lab_wire.sym} 620 -460 0 0 {name=l3 lab=A} C {lab_wire.sym} 620 -420 0 0 {name=l0 lab=B} C {lab_wire.sym} 650 -190 0 0 {name=l1 lab=VCCFILT} C {connector.sym} 230 -370 0 0 {name=CONN1 lab=INPUT_A verilog_type=reg} C {connector.sym} 230 -330 0 0 {name=CONN2 lab=INPUT_B verilog_type=reg} C {connector.sym} 240 -190 0 0 { name=CONN3 lab=OUTPUT_Y } C {connector.sym} 230 -480 0 0 {name=CONN6 lab=INPUT_E verilog_type=reg} C {connector.sym} 230 -440 0 0 {name=CONN8 lab=INPUT_F verilog_type=reg} C {connector.sym} 240 -160 0 0 { name=CONN9 lab=VCC12 } C {connector.sym} 240 -130 0 0 { name=CONN14 lab=ANALOG_GND verilog_type=reg} C {connector.sym} 240 -100 0 0 { name=CONN15 lab=GND verilog_type=reg} C {code.sym} 1030 -280 0 0 {name=TESTBENCH_CODE only_toplevel=false value="initial begin $dumpfile(\\"dumpfile.vcd\\"); $dumpvars; INPUT_E=0; INPUT_F=0; INPUT_A=0; INPUT_B=0; ANALOG_GND=0; #10000; INPUT_A=1; INPUT_B=1; #10000; INPUT_E=1; INPUT_F=1; #10000; INPUT_F=0; #10000; INPUT_B=0; #10000; $finish; end assign VCC12=1; "} C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" }

XSCHEM COMMAND REFERENCE DOCUMENTATION
The following are xschem specific tcl commands.
All commands are prefixed by the xschem keyword.
Example:
xschem getprop instance x3 OFFSET
- abort_operation
Resets UI state, unselect all and abort any pending operation
Start a GUI placement of a symbol pin
Start a GUI placement of a graph object
Ask user to choose a png file and start a GUI placement of the image
Align currently selected objects to current snap setting
Annotate operating point data into current schematic. use <schematic name>.raw or use supplied argument as raw file to open look for operating point data and annotate voltages/currents into schematic
Start a GUI placement of an arc. User should click 3 unaligned points to define the arc
Attach net labels to selected component(s) instance(s)
Start/end bounding box calculation: parameter is either 'begin' or 'end'
Break wires at selected instance pins
Rebuild color palette using values of tcl vars dim_value and dim_bg
Invoke the callback event dispatcher with a software event
Set case insensitive symbol lookup. Use only on case insensitive filesystems
List all used symbols in current schematic and warn if some symbol is newer
Check if all instances have a unique refdes (name attribute in xschem), highlight such instances. If second parameter is '1' rename duplicates
Start a GUI placement of a circle. User should click 3 unaligned points to define the circle
Clear current schematic window. Resets hierarchy level. Remove symbols the 'force' parameter will not ask to save existing modified schematic. the 'schematic' or 'symbol' parameter specifies to default to a schematic or symbol window (default: schematic)
Clears drawing but does not purge symbols
Dim colors or brite colors depending on value parameter: -5 <= value <= 5
Compare currently loaded schematic with another 'sch_file' schematic. if no file is given prompt user to choose one
Selected nets connected to currently selected net or net label/pin. if '1' argument is given, stop at wire junctions
Copy selection to clipboard
Start a GUI copy operation
Debug command
Create an xplot file in netlist/simulation directory with the list of highlighted nodes in a format the selected waveform viewer understands (bespice, gaw, ngspice)
Cut selection to clipboard
Set xschem in debug mode.'n' is the debug level (0=no debug). Higher levels yield more debug info.
Delete selection
Bring up a file selector the user can use to delete files
Descend into selected component instance. Optional number 'n' specifies the instance number to descend into for vector instances (default: 0).
Descend into the symbol view of selected component instance
Print a list of highlighted objects (nets, net labels/pins, instances)
Redraw graph rectangle number 'n'. If the optional 'flags' integer is given it will be used as the flags bitmask to use while drawing (can be used to restrict what to redraw)
Edit xschem file of current schematic if nothing is selected. Edit .sym file if a component is selected.
Edit global schematic/symbol attributes or attributes of currently selected instances
Edit global schematic/symbol attributes or attributes of currently selected instances using a text editor (defined in tcl 'editor' variable)
Embed base 64 encoded 'raw_file' into currently selected element as a 'spice_data' attribute.
Enable/disable layers depending on tcl array variable enable_layer()
Exit the program, ask for confirm if current file modified.
Expand vectored labels/instance names: xschem expandlabel {2*A[3:0]} --> A[3],A[2],A[1],A[0],A[3],A[2],A[1],A[0] 8 last field is the number of bits since [ and ] are TCL special characters argument must be quoted with { and }
Find n-th field string separated by characters in sep. 1st field is in position 1 xschem find_nth {aaa,bbb,ccc,ddd} {,} 2 --> bbb
Flip selection horizontally
Flip selection horizontally, each object around its center
Toggle fullscreen modes: fullscreen with menu & status, fullscreen, normal
Get C variable/constant 'var'
- backlayer number of background layer
- bbox_hilighted bounding box of highlinhted objects
- bbox_selected bounding box of selected objects
- cadlayers number of layers
- case_insensitive case_insensitive symbol matching
- color_ps color postscript flag
- current_dirname directory name of current design
- current_name name of current design (no library path)
- current_win_path path of current tab/window (.drw, .x1.drw, ...)
- currsch hierarchy level of current schematic (start at 0)
- debug_var debug level (0 = no debug, 1, 2, 3,...)
- draw_window direct draw into window
- format alternate format attribute to use in netlist (or NULL)
- graph_lastsel number of last graph that was clicked
- gridlayer layer number for grid
- help command help
- header_text header metadata (license info etc) present in schematic
- instances number of instances in schematic
- lastsel number of selected objects
- line_width get line width
- netlist_name netlist name if set. If 'fallback' given get default name
- netlist_type get current netlist type (spice/vhdl/verilog/tedax)
- no_draw disable drawing
- ntabs get number of additional tabs (0 = only one tab)
- pinlayer layer number for pins
- rectcolor current layer number
- sellayer layer number for selection
- semaphore used for debug
- schname get full path of current sch. if 'n' given get sch of level 'n'
- sch_path get hierarchy path. if 'n' given get hierpath of level 'n'
- sch_to_compare if set return schematic current design is compared with
- temp_dir get windows temporary dir
- text_svg return 1 if using <text> elements in svg export
- textlayer layer number for texts
- top_path get top hier path of current window (always "") for tabbed if
- topwindow same as top_path but main window returned as "."
- version return xschem version
- wirelayer layer used for wires
- xorigin x coordinate of origin
- yorigin y coordinate of origin
- zoom zoom level
Get the full attribute string of 'inst' getprop instance inst attr Get the value of attribute 'attr' If 'attr has the form 'cell::sym_attr' look up attribute 'sym_attr' of the symbol referenced by the instance. getprop instance_pin inst pin Get the full attribute string of pin 'pin' of instance 'inst' Example: xschem getprop instance_pin x3 MINUS --> name=MINUS dir=in getprop instance_pin inst pin pin_attr Get attribute 'pin_attr' of pin 'pin' of instance 'inst' Example: xschem getprop instance_pin x3 MINUS dir --> in getprop symbol sym_name Get full attribute string of symbol 'sym_name' example: xschem getprop symbol comp_ngspice.sym --> type=subcircuit format="@name @pinlist @symname OFFSET=@OFFSET AMPLITUDE=@AMPLITUDE GAIN=@GAIN ROUT=@ROUT COUT=@COUT" template="name=x1 OFFSET=0 AMPLITUDE=5 GAIN=100 ROUT=1000 COUT=1p" getprop symbol sym_name sym_attr [with_quotes] Get value of attribute 'sym_attr' of symbol 'sym_name' 'with_quotes' (default:0) is an integer passed to get_tok_value() getprop rect layer num attr Get attribute 'attr' of rectangle number 'num' on layer 'layer' getprop text num attr Get attribute 'attr' of text number 'num' ('inst' can be an instance name or instance number) ('pin' can be a pin name or pin number)
get value of token 'tok' in string 'str' 'with_quotes' (default:0) is an integer passed to get_tok_value()
Get length of last looked up attribute name (not its value) if returned value is 0 it means that last searched attribute did not exist
Return various global variables used in the program
Go up one level (pop) in hierarchy
Do a simple hash of 'file' 'skip_path_lines' is an integer (default: 0) passed to hash_file()
Do a simple hashing of string 'str'
Print command help
Hierarchical postscript / pdf print if 'file' is not given show a fileselector dialog box
Highlight selected element/pins/labels/nets if 'drill' is given propagate net highlights through conducting elements (elements that have the 'propag' attribute on pins )
Highlight instance 'inst' 'inst' can be an instance name or number
Highlight net name 'net'
Place a new instance of symbol 'sym_name' at position x,y, rotation and flip set to 'rot', 'flip' if 'prop' is given it is the new instance attribute string (default: symbol template string) if 'first_call' is given it must be 1 on first call and zero on following calls It is used only for efficiency reasons if placing multiple instances
return instance and symbol bounding boxes 'inst' can be an instance name or number
Return the name of the net attached to pin 'pin' of instance 'inst' Example: xschem instance_net x3 MINUS --> REF
Return the instance name followed by a list of 'pin net' associations example: xschem instance_nodemap x3 --> x3 PLUS LED OUT LEVEL MINUS REF instance x3 pin PLUS is attached to net LED, pin OUT to net LEVEL and so on...
Return the name and coordinates of pin with attribute 'attr' set to 'value' of instance 'inst' 'inst can be an instance name or a number Example: xschem instance_pin_coord x3 name MINUS --> {MINUS} 600 -840
Return list of pins of instance 'inst' 'inst can be an instance name or a number
Get number (position) of instance name 'inst'
Return list of instances names and pins attached to net 'net' Example: xschem instances_to_net PANEL --> { {Vsw} {plus} {580} {-560} } { {p2} {p} {660} {-440} } { {Vpanel1} {minus} {600} {-440} }
Place a line on current layer (rectcolor) if integer number 'pos' is given place line at indicated position in the line array.
set line width to floating point number 'n'
List all schematics at or below current hierarchy with modification times. Example: xschem list_hiearchy --> 20230302_003134 {/home/.../ngspice/solar_panel.sch} 20230211_010031 {/home/.../ngspice/pv_ngspice.sch} 20221011_175308 {/home/.../ngspice/diode_ngspice.sch} 20221014_091945 {/home/.../ngspice/comp_ngspice.sch}
Sorted list of highlight nets, separated by character 'sep' (default: space)
List tokens in string 'str' with_quotes: 0: eat non escaped quotes (") 1: return unescaped quotes as part of the token value if they are present 2: eat backslashes
Load a new file 'f'. 'force': do not ask to save modified file or warn if opening an already open file 'noundoreset': do not reset the undo history 'symbol': do not load symbols (used if loading a symbol instead of a schematic) 'nofullzoom': do not do a fll zoom on new schematic.
Load schematic in a new tab/window. If 'f' not given prompt user
If 'f' is given output stderr messages to file 'f' if 'f' is not given and a file log is open, close log file and resume logging to stderr
Set selected nets, net labels or pins to logic level 'n' 'num' times. 'n': 0 set to logic value 0 1 set to logic value 1 2 set to logic value X 3 set to logic value Z -1 toggle logic valie (1->0, 0->1) the 'num' parameter is essentially useful only with 'toggle' (-1) value
Set selected nets, net labels or pins to logic level 'n' 'num' times. 'n': 0 set to logic value 0 1 set to logic value 1 2 set to logic value X 3 set to logic value Z -1 toggle logic valie (1->0, 0->1) the 'num' parameter is essentially useful only with 'toggle' (-1) value
create an LCC instance from selection and place it instead of selection also ask if a symbol (.sym) file needs to be created
From current schematic (circuit.sch) create a symbol (circuit.sym) using ipin.sym, opin.sym, iopin.sym in schematic to deduce symbol interface pins.
Merge another file. if 'f' not given prompt user.
Start a move operation on selection and let user terminate the operation in the GUI if dx and dy are given move by that amount.
Place a new net label 'type': 1: place a 'lab_pin.sym' label 0: place a 'lab_wire.sym' label User should complete the placement in the GUI.
Highlight nets attached to selected symbols with a different name than symbol pin
do a netlist of current schematic in currently defined netlist format
Open/destroy a new tab or window create: create new empty window or with 'file' loaded if 'file' given. The winpath must be given (even {} is ok) but not used. destroy: destroy tab/window identified by winpath. Example: xschem new_schematic destroy .x1.drw destroy_all: close all tabs/additional windows switch_win: switch context to specified 'winpath' window switch_tab: switch context to specified 'winpath' tab Main window/tab has winpath set to .drw, Additional windows/tabs have winpath set to .x1.drw, .x2.drw and so on...
Start a new xschem process for a symbol. If 'f' is given load specified symbol.
Start a new xschem process for a schematic. If 'f' is given load specified schematic.
dim schematic to better show highlights
Move origin to 'x, y', optionally changing zoom level to 'zoom'
debug command to test parse_cmd_string() splits a command string into argv-like arguments return # of args in *argc argv[*argc] is always set to NULL
Debug command to test vector net syntax parser
Paste clipboard. If 'x y' not given user should complete placement in the GUI
List all pins of instance 'inst' Example: xschem pinlist x3 --> { {0} {name=PLUS dir=in } } { {1} {name=OUT dir=out } } { {2} {name=MINUS dir=in } }
Start a GUI placement operation of specified 'sym_name' symbol. If 'sym_name' not given prompt user 'prop' is the attribute string of the symbol. If not given take from symbol template attribute.
Start a GUI placement of a text object
Start a GUI placement of a polygon
Used in fileselector to show a schematic preview.
Export current schematic to image. img x y size xschem area to export 0 1 2 3 4 5 6 7 8 9 xschem print png file.png 400 300 [ -300 -200 300 200 ] xschem print svg file.svg 400 300 [ -300 -200 300 200 ] xschem print ps file.ps xschem print pdf file.pdf
from highlighted nets/pins/labels: show == 0 ==> create pins from highlight nets show == 1 ==> show list of highlight net in a dialog box show == 2 ==> create labels with i prefix from hilight nets show == 3 ==> show list of highlight net with path and label expansion in a dialog box show == 4 ==> create labels without i prefix from hilight nets for show = 0, 2, 4 user should complete GUI placement of created objects
Print spice raw netlist line for instance (number or name) 'inst'
Debug: wrapper to propagate_hilights() function
Push current state on undo stack
Delete loaded simulation raw file
xschem raw_query list: get list of saved simulation variables xschem raw_query vars: get number of simulation variables xschem raw_query datasets: get number of datasets (simulation runs) xschem raw_query value node n: return n-th value of 'node' in raw file xschem raw_query loaded: return hierarchy level where raw file was loaded or -1 if no raw loaded xschem raw_query index node: get index of simulation variable 'node'. Example: raw_query index v(led) --> 46 xschem raw_query values node [dset] : print all simulation values of 'node' for dataset 'dset' (default dset=0) xschem raw_query points [dset] : print simulation points for dataset 'dset' (default dset=0)
If a raw file is already loaded delete from memory else load specified file and analysis 'sim' (dc, ac, tran, op, ...) If 'sim' not specified load first section found in raw file.
If a simulation raw file is already loaded delete from memory else read section 'sim' (tran, dc, ac, op, ...) of base64 encoded data from a 'spice_data' attribute of selected instance If sim not given read first section found
Rebuild logical connectivity abstraction of schematic
Rebuild selection list
if 'x1 y1 x2 y2'is given place recangle on current layer (rectcolor) at indicated coordinates. if 'pos' is given insert at given position in rectangle array. If no coordinates are given start a GUI operation of rectangle placement
Redo last undone action
redraw window
Forced (be careful!) Reload current schematic from disk
Reload all used symbols from disk
Internal command: remove all symbol definitions
Replace 'inst' symbol with 'new_symbol' If doing multiple substitutions set 'fast' to 0 on first call and non zero on next calls for faster operation Example: xschem replace_symbol R3 capa.sym
Rotate selected objects around their centers
Save schematic if modified. Does not ask confirmation!
save current schematic as 'file' if file is empty ({}) use current schematic name as defalt and prompt user with file selector 'type' is used used to set/change file extension: schematic: save as schematic (*.sch) symbol: save as symbol (*.sym) If not specified default to schematic (*.sch) Does not ask confirmation if file name given
When a symbol is selected edit corresponding schematic in a new tab/window if not already open. If nothing selected open another window of the second schematic (issues a warning). if 'new_process' is given start a new xschem process
Search instances with attribute string containing 'tok' attribute and value 'val' search can be exact ('exact') or as a regular expression ('regex') select: 0 : highlight matching instances 1 : select matching instances -1 : unselect matching instances 'tok' set as: propstring : will search for 'val' in the entire *instance* attribute string. cell::propstring : will search for 'val' in the entire *symbol* attribute string. cell::name : will search for 'val' in the symbol name cell::<attr> will search for 'val' in symbol attribute 'attr' example: xschem search regex 0 cell::template GAIN=100
Select indicated instance or wire or text. For 'instance' 'id' can be the instance name or number for 'wire' or 'text' 'id' is the position in the respective arrays if 'clear' is specified does an unselect operation
Selects all objects in schematic
Select all highlight objects (wires, labels, pins, instances)
Return a list of selected instance names
Return list of selected nets
Send selected wires/net labels/pins/voltage source or ammeter currents to current open viewer (gaw or bespice)
Set C variable 'var' to 'value'
- cadgrid set cad grid (default: 20)
- cadsnap set mouse snap (default: 10)
- color_ps set color psoscript (1 or 0)
- constrained_move set constrained move (1=horiz, 2=vert, 0=none)
- draw_window set drawing to window (1 or 0)
- format set name of custom format attribute used for netlisting
- header_text set header metadata (used for license info)
- hide_symbols set to 0,1,2 for various hiding level of symbols
- netlist_name set custom netlist name
- netlist_type set netlisting mode (spice, verilog, vhdl, tedax, symbol)
- no_draw set no drawing flag (0 or 1)
- no_undo set to 1 to disable undo
- rectcolor set current layer (0, 1, .... , cadlayers-1)
- sch_to_compare st name of schematic to compare current window with
- text_svg set to 1 to use svg <text> elements
- semaphore debug
- show_hidden_texts set to 1 to enable showing texts with attr hide=true
- sym_txt set to 0 to hide symbol texts
Return string 'str' replacing/adding/removing tokens that are different between 'new_str' and 'old_str'
Force modify status on current schematic
set attribute 'tok' of instance (name or number) 'inst' to value 'val' If 'val' not given (no attribute value) delete attribute from instance If 'fast' argument if given does not redraw and is not undoable setprop rect lay n tok [val] [fast|fastundo] Set attribute 'tok' of rectangle number'n' on layer 'lay' If 'val' not given (no attribute value) delete attribute from rect If 'fast' argument is given does not redraw and is not undoable If 'fastundo' s given same as above but action is undoable. setprop rect 2 n fullxzoom setprop rect 2 n fullyzoom These commands do full x/y zoom of graph 'n' (on layer 2, this is hardcoded). setprop text n tok [val] [fast|fastundo] Set attribute 'tok' of text number 'n' If 'val' not given (no attribute value) delete attribute from text If 'fast' argument is given does not redraw and is not undoable If 'fastundo' s given same as above but action is undoable.
Run a simulation (start simulator configured as default in Tools -> Configure simulators and tools)
Start a GUI start snapped wire placement (click to start a wire to closest pin/net endpoint)
Return string 'str' with 'tok' attribute value replaced with 'newval'
When a symbol is selected edit it in a new tab/window if not already open. If nothing selected open another window of the second schematic (issues a warning). if 'new_process' is given start a new xschem process
List all used symbols
If a simulation raw file is lodaded unload from memory. else read a tabular file 'table_file' First line is the header line containing variable names. data is presented in column format after the header line First column is sweep (x-axis) variable Double empty lines start a new dataset Single empty lines are ignored Datasets can have different # of lines. new dataset do not start with a header row. Lines beginning with '#' are comments and ignored time var_a var_b var_c # this is a comment, ignored 0.0 0.0 1.8 0.3 <single empty line: ignored> 0.1 0.0 1.5 0.6 ... ... ... ... <empty line> <Second empty line: start new dataset> 0.0 0.0 1.8 0.3 0.1 0.0 1.5 0.6 ... ... ... ...
testmode
Toggle dark/light colorscheme
Translate string 'str' replacing @xxx tokens with values in instance 'n' attributes
Remove operlapping wires, join lines, trim wires at intersections
Undo last action
Use disk file ('disk') or RAM ('memory') for undo bufer
Clear all highlights
Unhighlight selected nets/pins
Unselect everything
Update all symbol bounding boxes (useful if show_pin_net_names is set)
View attributes of selected element (read only) if multiple selection show the first element (in xschem array order)
Highlight or select (if 'sel' set to 1) perfectly overlapped instances this is usually an error and difficult to grasp visually
Used by xschem.tcl for configure events
Place a new wire if no coordinates are given start a GUI wire placement
For debug
Zoom to specified coordinates, if 'factor' is given reduce view (factor < 1.0) or add border (factor > 1.0) If no coordinates are given start GUI zoom box operation
Set full view. If 'center' is given center vire instead of lower-left align If 'nodraw' is given don't redraw If 'nolinewidth]' is given don't reset line widths.
Zoom to highlighted objects
Zoom in drawing
Zoom out drawing
Zoom to selection
XSCHEM TCL GLOBAL VARIABLES
sim(spice,0,cmd) {$terminal -e 'ngspice -i "$N" -a || sh'} sim(spice,0,fg) 0 sim(spice,0,st) 0 sim(spice,1,cmd) {ngspice -b -r "$n.raw" -o "$n.out" "$N"} sim(spice,1,fg) 0 sim(spice,1,st) 1 sim(spice,2,cmd) "Xyce \"\$N\"\n# Add -r \"\$n.raw\" if you want all variables saved" sim(spice,2,fg) 0 sim(spice,2,st) 1 sim(spice,3,cmd) {mpirun /path/to/parallel/Xyce "$N"} sim(spice,3,fg) 0 sim(spice,3,st) 1 sim(spice,n) 4 sim(spice,default) 0 sim(spicewave,0,cmd) {gaw "$n.raw" } sim(spicewave,0,fg) 0 sim(spicewave,0,st) 0 sim(spicewave,1,cmd) {$terminal -e ngspice} sim(spicewave,1,fg) 0 sim(spicewave,1,st) 0 sim(spicewave,2,cmd) {rawtovcd -v 1.5 "$n.raw" > "$n.vcd" && gtkwave "$n.vcd" "$n.sav" 2>/dev/null} sim(spicewave,2,fg) 0 sim(spicewave,2,st) 0 sim(spicewave,3,cmd) {$env(HOME)/analog_flavor_eval/bin/bspwave --socket localhost $bespice_listen_port "$n.raw" } sim(spicewave,3,fg) 0 sim(spicewave,3,st) 0 sim(spicewave,n) 4 sim(spicewave,default) 0 sim(verilog,0,cmd) {iverilog -o .verilog_object -g2012 "$N" && vvp .verilog_object} sim(verilog,0,fg) 0 sim(verilog,0,st) 1 sim(verilog,n) 1 sim(verilog,default) 0 sim(verilogwave,0,cmd) {gtkwave dumpfile.vcd "$N.sav" 2>/dev/null} sim(verilogwave,0,fg) 0 sim(verilogwave,0,st) 0 sim(verilogwave,n) 1 sim(verilogwave,default) 0 sim(vhdl,0,cmd) {ghdl -c --ieee=synopsys -fexplicit "$N" -r "$s" --wave="$n.ghw"} sim(vhdl,0,fg) 0 sim(vhdl,0,st) 1 sim(vhdl,n) 1 sim(vhdl,default) 0 sim(vhdlwave,0,cmd) {gtkwave "$n.ghw" "$N.sav" 2>/dev/null} sim(vhdlwave,0,fg) 0 sim(vhdlwave,0,st) 0 sim(vhdlwave,n) 1 sim(vhdlwave,default) 0 add_all_windows_drives 1 autofocus_mainwindow 1 auto_hilight 0 autotrim_wires 0 bespice_listen_port {} bespice_server_getdata big_grid_points 0 bus_replacement_char {} ;# use {<>} to replace [] with <> in bussed signals cadlayers 22 cairo_font_line_spacing 1.0 cairo_font_name {Sans-Serif} cairo_font_scale 1.0 cairo_vert_correct 0 case_insensitive 0 change_lw 1 color_ps 1 colors $dark_colors compare_sch 0 component_browser_on_top 1 connect_by_kissing 0 constrained_move 0 copy_cell 0 dark_colors { "#000000" "#00ccee" "#3f3f3f" "#cccccc" "#88dd00" "#bb2200" "#00ccee" "#ff0000" "#ffff00" "#ffffff" "#ff00ff" "#00ff00" "#0044dd" "#aaaa00" "#aaccaa" "#ff7777" "#bfff81" "#00ffcc" "#ce0097" "#d2d46b" "#ef6158" "#fdb200"} dark_colorscheme 1 dark_colors_save debug_var 0 dim_bg 0.0 dim_value 0.0 dircolor(/share/doc/xschem/) {#338844} dircolor(/share/xschem/) red disable_unique_names 0 download_url_helper {curl -f -s -O} draw_grid 1 draw_window 0 editor {gvim -f} edit_prop_size 80x12 edit_symbol_prop_new_sel {} enable_dim_bg 0 enable_layer($i) 1 enable_stretch 0 en_hilight_conn_inst 0 execute(cmd,<id>) execute(data,<id>) execute(status,<id>) execute(cmd,last) execute(data,last) execute(status,last) flat_netlist 0 fullscreen 0 gaw_tcp_address {localhost 2020} graph_bus 0 graph_logx 0 graph_logy 0 graph_rainbow 0 graph_raw_level -1 ;# hierarchy level where raw file has been loaded graph_schname {} graph_sel_color 4 graph_selected {} graph_sel_wave {} graph_sort 0 has_cairo 1 has_x hide_empty_graphs 0 ;# if set to 1 waveform boxes will be hidden if no raw file loaded hide_symbols 0 incr_hilight 1 initial_geometry {900x600} launcher_default_program {xdg-open} light_colors { "#ffffff" "#0044ee" "#aaaaaa" "#222222" "#229900" "#bb2200" "#00ccee" "#ff0000" "#888800" "#00aaaa" "#880088" "#00ff00" "#0000cc" "#666600" "#557755" "#aa2222" "#7ccc40" "#00ffcc" "#ce0097" "#d2d46b" "#ef6158" "#fdb200"} light_colors_save line_width 0 live_cursor2_backannotate 0 local_netlist_dir 0 ;# if set use <sch_dir>/simulation for netlist and sims lvs_netlist 0 measure_text "y=\nx=" menu_debug_var 0 myload_files2 {} myload_globfilter {*} myload_index1 0 netlist_dir "$USER_CONF_DIR/simulations" netlist_show 0 netlist_type spice nocairo_font_xscale .85 nocairo_font_yscale .88 nocairo_vert_correct 0 no_change_attrs 0 nolist_libs {} noprint_libs {} only_probes 0 ; # 20110112 OS persistent_command 0 preserve_unchanged_attrs 0 rainbow_colors 0 search_schematic 0 show_hidden_texts 0 show_infowindow 0 show_pin_net_names 0 spiceprefix 1 split_files 0 svg_font_name {Sans-Serif} symbol_width 150 sym_txt 1 tabbed_interface 0 tcl_files {} tclstop 0 terminal xterm text_line_default_geometry 80x12 textwindow_wcounter toolbar_horiz 1 toolbar_list { toolbar_visible 0 to_pdf {ps2pdf} to_png {gm convert} transparent_svg 0 undo_type disk unzoom_nodrift 0 USER_CONF_DIR verilog_2001 1 verilog_bitblast 0 viewdata_wcounter xschem_libs {} xschem_listen_port {} xschem_server_getdata XSCHEM_SHAREDIR XSCHEM_START_WINDOW {} XSCHEM_TMP_DIR {/tmp}