added drc_check() function, that evaluates tcl scripts contained in symbol `drc` attribute. Used for checking allowed dimensions, mostly

This commit is contained in:
stefan schippers 2024-04-15 16:43:56 +02:00
parent 260256afb9
commit 8d68beb914
6 changed files with 73 additions and 3 deletions

View File

@ -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) </pre>
<li><kbd> drc_check [i]</kbd></li><pre>
Perform DRC rulecheck of instances.
if i is specified do check of specified instance
otherwise check all instances in current schematic. </pre>
<li><kbd> edit_file</kbd></li><pre>
Edit xschem file of current schematic if nothing is selected.
Edit .sym file if a component is selected. </pre>

View File

@ -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 */

View File

@ -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;
}

View File

@ -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': /*----------------------------------------------*/

View File

@ -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);

View File

@ -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 {