add commands "xschem get wires", "xschem getprop wire n attr", "xschem touch x1 y1 x2 y2 x0 y0", "xschem wire_coord n"

This commit is contained in:
stefan schippers 2023-09-14 08:31:01 +02:00
parent e6211ac93b
commit 34946c2f0a
2 changed files with 63 additions and 5 deletions

View File

@ -500,6 +500,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
@ -673,6 +675,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> topwindow </kbd> same as top_path but main window returned as "." </li>
<li><kbd> version </kbd> return xschem version </li>
<li><kbd> wirelayer </kbd> layer used for wires </li>
<li><kbd> wires </kbd> number of wires </li>
<li><kbd> xorigin </kbd> x coordinate of origin </li>
<li><kbd> yorigin </kbd> y coordinate of origin </li>
<li><kbd> zoom </kbd> zoom level </li>
@ -721,6 +724,9 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
getprop text num attr
Get attribute 'attr' of text number 'num'
getprop wire num attr
Get attribute 'attr' of wire number 'num'
('inst' can be an instance name or instance number)
('pin' can be a pin name or pin number)</pre>
<li><kbd> get_tok str tok [with_quotes]</kbd></li><pre>
@ -1206,6 +1212,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> toggle_ignore</kbd></li><pre>
toggle *_ignore=true attribute on selected instances
* = {spice,verilog,vhdl,tedax} depending on current netlist mode </pre>
<li><kbd> touch x1 y1 x2 y2 x0 y0</kbd></li><pre>
returns 1 if line {x1 y1 x2 y2} touches point {x0 y0}, 0 otherwise </pre>
<li><kbd> translate n str</kbd></li><pre>
Translate string 'str' replacing @xxx tokens with values in instance 'n' attributes
Example: xschem translate vref {the voltage is @value}
@ -1230,8 +1238,10 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> warning_overlapped_symbols [sel]</kbd></li><pre>
Highlight or select (if 'sel' set to 1) perfectly overlapped instances
this is usually an error and difficult to grasp visually </pre>
<li><kbd> windowid</kbd></li><pre>
Used by xschem.tcl for configure events </pre>
<li><kbd> windowid topwin_path</kbd></li><pre>
Used by xschem.tcl for configure events (set icon) </pre>
<li><kbd> wire_coord n</kbd></li><pre>
return 4 coordinates of wire[n] </pre>
<li><kbd> wire [x1 y1 x2 y2] [pos] [prop] [sel]</kbd></li><pre>
Place a new wire
if no coordinates are given start a GUI wire placement </pre>
@ -1276,6 +1286,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
</ul>
<!-- TCL global variables -->

View File

@ -1131,6 +1131,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
case 'w':
if(!strcmp(argv[2], "wirelayer")) { /* layer used for wires */
Tcl_SetResult(interp, my_itoa(WIRELAYER), TCL_VOLATILE);
} else if(!strcmp(argv[2], "wires")) { /* number of wires */
Tcl_SetResult(interp, my_itoa(xctx->wires), TCL_VOLATILE);
}
break;
case 'x':
@ -1220,6 +1222,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
* getprop text num attr
* Get attribute 'attr' of text number 'num'
*
* getprop wire num attr
* Get attribute 'attr' of wire number 'num'
*
* ('inst' can be an instance name or instance number)
* ('pin' can be a pin name or pin number)
*/
@ -1331,6 +1336,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
int n = atoi(argv[3]);
Tcl_SetResult(interp, (char *)get_tok_value(xctx->text[n].prop_ptr, argv[4], 2), TCL_VOLATILE);
}
} else if(!strcmp(argv[2], "wire")) { /* xschem getprop wire n token */
if(argc < 5) {
Tcl_SetResult(interp, "xschem getprop wire needs <n> <token>", TCL_STATIC);
return TCL_ERROR;
} else {
int n = atoi(argv[3]);
Tcl_SetResult(interp, (char *)get_tok_value(xctx->wire[n].prop_ptr, argv[4], 2), TCL_VOLATILE);
}
}
}
@ -3985,6 +3998,24 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp);
}
/* touch x1 y1 x2 y2 x0 y0
* returns 1 if line {x1 y1 x2 y2} touches point {x0 y0}, 0 otherwise */
else if(!strcmp(argv[1], "touch") )
{
if(argc>7) {
double x1, y1, x2, y2, x0, y0;
int r;
x0 = atof(argv[6]);
y0 = atof(argv[7]);
x1 = atof(argv[2]);
y1 = atof(argv[3]);
x2 = atof(argv[4]);
y2 = atof(argv[5]);
r = touch(x1, y1, x2, y2, x0, y0);
Tcl_SetResult(interp, my_itoa(r), TCL_VOLATILE);
}
}
/* translate n str
* Translate string 'str' replacing @xxx tokens with values in instance 'n' attributes
* Example: xschem translate vref {the voltage is @value}
@ -4130,15 +4161,31 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
warning_overlapped_symbols(0);
}
}
/* windowid
* Used by xschem.tcl for configure events */
/* windowid topwin_path
* Used by xschem.tcl for configure events (set icon) */
else if(!strcmp(argv[1], "windowid"))
{
if(argc > 2) {
windowid(argv[2]);
}
}
/* wire_coord n
* return 4 coordinates of wire[n] */
else if(!strcmp(argv[1], "wire_coord"))
{
if(argc > 2) {
char *r = NULL;
int n = atoi(argv[2]);
if(n > 0 && n < xctx->wires) {
xWire * const wire = xctx->wire;
my_mstrcat(_ALLOC_ID_, &r, dtoa(wire[n].x1), " ", NULL);
my_mstrcat(_ALLOC_ID_, &r, dtoa(wire[n].y1), " ", NULL);
my_mstrcat(_ALLOC_ID_, &r, dtoa(wire[n].x2), " ", NULL);
my_mstrcat(_ALLOC_ID_, &r, dtoa(wire[n].y2), NULL);
Tcl_SetResult(interp, r, TCL_VOLATILE);
}
}
}
/* wire [x1 y1 x2 y2] [pos] [prop] [sel]
* Place a new wire
* if no coordinates are given start a GUI wire placement */