From 8d68beb914d0c845a9aa26752f5dd0d8648543cc Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Mon, 15 Apr 2024 16:43:56 +0200 Subject: [PATCH] added drc_check() function, that evaluates tcl scripts contained in symbol `drc` attribute. Used for checking allowed dimensions, mostly --- doc/xschem_man/developer_info.html | 4 +++ src/editprop.c | 48 ++++++++++++++++++++++++++++++ src/save.c | 5 +++- src/scheduler.c | 14 +++++++++ src/xschem.h | 1 + src/xschem.tcl | 4 +-- 6 files changed, 73 insertions(+), 3 deletions(-) diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index 617d6ee6..9b77dfa2 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -664,6 +664,10 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" 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) +
  • drc_check [i]
  • +   Perform DRC rulecheck of instances. 
    +   if i is specified do check of specified instance
    +   otherwise check all instances in current schematic. 
  • edit_file
  •     Edit xschem file of current schematic if nothing is selected.
        Edit .sym file if a component is selected. 
    diff --git a/src/editprop.c b/src/editprop.c index 26b3eb38..6c0c4d82 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -1371,6 +1371,52 @@ static int edit_text_property(int x) return modified; } +int drc_check(int i) +{ + int j, ret = 0; + char *drc = NULL, *res = NULL; + char *check_result = NULL; + int start = 0; + int end = xctx->instances; + + if(i >= 0 && i < xctx->instances) { + start = i; + end = i + 1; + } + for(j = start; j < end; j++) { + my_strdup(_ALLOC_ID_, &drc, get_tok_value(xctx->sym[xctx->inst[j].ptr].prop_ptr, "drc", 2)); + if(drc) { + my_strdup(_ALLOC_ID_, &res, translate3(drc, 1, + xctx->inst[j].prop_ptr, xctx->sym[xctx->inst[j].ptr].templ, NULL)); + dbg(1, "drc_check(): res = |%s|, drc=|%s|\n", res, drc); + if(res) { + const char *result; + const char *replace_res; + + replace_res = str_replace(res, "@symname", xctx->sym[xctx->inst[j].ptr].name, '\\'); + result = tcleval(replace_res); + if(result && result[0]) { + ret = 1; + my_mstrcat(_ALLOC_ID_, &check_result, result, NULL); + } + } + } + } + if(drc) my_free(_ALLOC_ID_, &drc); + if(res) my_free(_ALLOC_ID_, &res); + if(check_result) { + if(has_x) { + /* tclvareval("alert_ {", check_result, "} {}", NULL); */ + statusmsg(check_result, 3); + tcleval("show_infotext 1"); + } else { + dbg(0, "%s\n", check_result); + } + my_free(_ALLOC_ID_, &check_result); + } + return ret; +} + /* x=0 use text widget x=1 use vim editor */ static int update_symbol(const char *result, int x, int selected_inst) { @@ -1521,6 +1567,8 @@ static int update_symbol(const char *result, int x, int selected_inst) if(xctx->hilight_nets) { propagate_hilights(1, 1, XINSERT_NOREPLACE); } + /* DRC check */ + drc_check(*ii); } /* redraw symbol with new props */ set_modify(-2); /* reset floaters caches */ diff --git a/src/save.c b/src/save.c index 8a5c8297..eb279724 100644 --- a/src/save.c +++ b/src/save.c @@ -3233,7 +3233,10 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler propagate_hilights(1, 1, XINSERT_NOREPLACE); } /* set local simulation directory if local_netlist_dir is set*/ - if(reset_undo) set_netlist_dir(2, NULL); + if(reset_undo) { + set_netlist_dir(2, NULL); + drc_check(-1); + } return ret; } diff --git a/src/scheduler.c b/src/scheduler.c index 191b2fa4..07253fda 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -807,6 +807,20 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } Tcl_ResetResult(interp); } + /* drc_check [i] + * Perform DRC rulecheck of instances. + * if i is specified do check of specified instance + * otherwise check all instances in current schematic. */ + else if(!strcmp(argv[1], "drc_check")) + { + int i = -1; + if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;} + if(argc > 2 && (i = get_instance(argv[2])) < 0 ) { + Tcl_SetResult(interp, "xschem getprop: instance not found", TCL_STATIC); + return TCL_ERROR; + } + drc_check(i); + } else { cmd_found = 0;} break; case 'e': /*----------------------------------------------*/ diff --git a/src/xschem.h b/src/xschem.h index 8fc35a54..13bf4763 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1706,6 +1706,7 @@ extern void hilight_child_pins(void); extern void hilight_parent_pins(void); extern void hilight_net_pin_mismatches(void); extern Node_hashentry **get_node_table_ptr(void); +extern int drc_check(int i); extern void change_elem_order(int n); extern int is_generator(const char *name); extern char *str_chars_replace(const char *str, const char *replace_set, const char with); diff --git a/src/xschem.tcl b/src/xschem.tcl index f9a3d8c9..6ef9ae6a 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -5493,8 +5493,8 @@ proc alert_ {txtlabel {position +200+300} {nowait {0}} {yesno 0}} { } else { wm geometry .alert "+$X+$Y" } - label .alert.l1 -font {Sans 10 bold} \ - -text " \n ${txtlabel} \n" -wraplength 750 + label .alert.l1 -font {Sans 10 bold} -justify left \ + -text " \n${txtlabel} \n" -wraplength 750 if { $yesno} { set oktxt Yes } else {