From 34946c2f0a372bbfda5350c379be5ae4ea6a885e Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Thu, 14 Sep 2023 08:31:01 +0200 Subject: [PATCH] add commands "xschem get wires", "xschem getprop wire n attr", "xschem touch x1 y1 x2 y2 x0 y0", "xschem wire_coord n" --- doc/xschem_man/developer_info.html | 15 +++++++-- src/scheduler.c | 53 ++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index e1d47ace..ebd464e5 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -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"
  • topwindow same as top_path but main window returned as "."
  • version return xschem version
  • wirelayer layer used for wires
  • +
  • wires number of wires
  • xorigin x coordinate of origin
  • yorigin y coordinate of origin
  • zoom zoom level
  • @@ -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)
  • get_tok str tok [with_quotes]
  • @@ -1206,6 +1212,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
        
  • toggle_ignore
  •     toggle *_ignore=true attribute on selected instances
        * = {spice,verilog,vhdl,tedax} depending on current netlist mode 
    +
  • touch x1 y1 x2 y2 x0 y0
  • +   returns 1 if line {x1 y1 x2 y2} touches point {x0 y0}, 0 otherwise 
  • translate n str
  •     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"
        
  • warning_overlapped_symbols [sel]
  •     Highlight or select (if 'sel' set to 1) perfectly overlapped instances
        this is usually an error and difficult to grasp visually 
    -
  • windowid
  • -   Used by xschem.tcl for configure events 
    +
  • windowid topwin_path
  • +   Used by xschem.tcl for configure events (set icon) 
    +
  • wire_coord n
  • +   return 4 coordinates of wire[n] 
  • wire [x1 y1 x2 y2] [pos] [prop] [sel]
  •     Place a new wire
        if no coordinates are given start a GUI wire placement 
    @@ -1276,6 +1286,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" + diff --git a/src/scheduler.c b/src/scheduler.c index 63849f6e..f3a9b710 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -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 ", 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 */