"xschem hilight_netname" command to hilight a specific net name, "xschem search exact ..." finds specific instances of vector instances, "probe_net" procedure descends into the right bussed instance and hilights the correct net bit, added "xschem display_hilights" to return all hilighted nets in the hierarchy, added "gaw_cmd" procedure to send socket commands to gaw (like "gaw_cmd reload_all") (recently added command to gaw ttg)

This commit is contained in:
Stefan Schippers 2020-09-22 13:35:55 +02:00
parent eaee40f5f3
commit 82451fd50e
8 changed files with 113 additions and 32 deletions

View File

@ -277,7 +277,7 @@ int find_types_something_t(const char *name, int logdepth, int fatal, const char
for(include = first_include; *include != NULL; include++) { for(include = first_include; *include != NULL; include++) {
sprintf(test_c, test_c_include, define, *include, typ); sprintf(test_c, test_c_include, define, *include, typ);
if ((compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) && (strncmp(out, "OK", 2) == 0)) { if ((compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) && out != NULL && (strncmp(out, "OK", 2) == 0)) {
report("Found; "); report("Found; ");
logprintf(logdepth+1, "include %s works\n", *include); logprintf(logdepth+1, "include %s works\n", *include);
sprintf(nodeend, "includes"); sprintf(nodeend, "includes");

View File

@ -1041,6 +1041,10 @@ void launcher(void) /* 20161102 */
rebuild_selected_array(); rebuild_selected_array();
if(lastselected ==1 && selectedgroup[0].type==ELEMENT) if(lastselected ==1 && selectedgroup[0].type==ELEMENT)
{ {
double mx=mousex, my=mousey;
select_object(mx,my,SELECTED, 0);
tcleval("update; after 300");
select_object(mx,my,0, 0);
n=selectedgroup[0].n; n=selectedgroup[0].n;
my_strncpy(program, get_tok_value(inst_ptr[n].prop_ptr,"program",2), S(program)); /* 20170414 handle backslashes */ my_strncpy(program, get_tok_value(inst_ptr[n].prop_ptr,"program",2), S(program)); /* 20170414 handle backslashes */
str = get_tok_value(inst_ptr[n].prop_ptr,"url",2); /* 20170414 handle backslashes */ str = get_tok_value(inst_ptr[n].prop_ptr,"url",2); /* 20170414 handle backslashes */
@ -1062,7 +1066,7 @@ void launcher(void) /* 20161102 */
} }
} }
void descend_schematic(void) void descend_schematic(int instnumber)
{ {
const char *str; const char *str;
char filename[PATH_MAX]; char filename[PATH_MAX];
@ -1130,17 +1134,22 @@ void descend_schematic(void)
inst_number = 1; inst_number = 1;
if(inst_mult > 1) { /* on multiple instances ask where to descend, to correctly evaluate if(inst_mult > 1) { /* on multiple instances ask where to descend, to correctly evaluate
the hierarchy path you descend to */ the hierarchy path you descend to */
const char *inum;
Tcl_VarEval(interp, "input_line ", "{input instance number (leftmost = 1) to descend into:\n" if(instnumber <= 0 ) {
"negative numbers select instance starting\nfrom the right (rightmost = -1)}" const char *inum;
" {} 1 6", NULL); Tcl_VarEval(interp, "input_line ", "{input instance number (leftmost = 1) to descend into:\n"
inum = tclresult(); "negative numbers select instance starting\nfrom the right (rightmost = -1)}"
dbg(1, "descend_schematic(): inum=%s\n", inum); " {} 1 6", NULL);
if(!inum[0]) { inum = tclresult();
my_free(710, &sch_path[currentsch+1]); dbg(1, "descend_schematic(): inum=%s\n", inum);
return; if(!inum[0]) {
my_free(710, &sch_path[currentsch+1]);
return;
}
inst_number=atoi(inum);
} else {
inst_number = instnumber;
} }
inst_number=atoi(inum);
if(inst_number < 0 ) inst_number += inst_mult+1; if(inst_number < 0 ) inst_number += inst_mult+1;
if(inst_number <1 || inst_number > inst_mult) inst_number = 1; /* any invalid number->descend to leftmost inst */ if(inst_number <1 || inst_number > inst_mult) inst_number = 1; /* any invalid number->descend to leftmost inst */
} }

View File

@ -734,7 +734,7 @@ int callback(int event, int mx, int my, KeySym key,
if(key=='e' && state == 0) /* descend to schematic */ if(key=='e' && state == 0) /* descend to schematic */
{ {
if(semaphore >= 2) break; if(semaphore >= 2) break;
descend_schematic();break; descend_schematic(0);break;
} }
if(key=='e' && state == Mod1Mask) /* edit schematic in new window */ if(key=='e' && state == Mod1Mask) /* edit schematic in new window */
{ {

View File

@ -26,7 +26,7 @@ static struct hilight_hashentry *hilight_table[HASHSIZE];
static int nelements=0; /* 20161221 */ static int nelements=0; /* 20161221 */
static int *inst_color=NULL; static int *inst_color=NULL;
static unsigned int hash(char *tok) static unsigned int hash(const char *tok)
{ {
unsigned int hash = 0; unsigned int hash = 0;
char *str; char *str;
@ -53,16 +53,18 @@ static struct hilight_hashentry *free_hilight_entry(struct hilight_hashentry *en
return NULL; return NULL;
} }
/* for debug only */ void display_hilights(char **str)
void display_hilights()
{ {
int i; int i;
int first = 1;
struct hilight_hashentry *entry; struct hilight_hashentry *entry;
fprintf(errfp, "-----------------\n");
for(i=0;i<HASHSIZE;i++) { for(i=0;i<HASHSIZE;i++) {
entry = hilight_table[i]; entry = hilight_table[i];
while(entry) { while(entry) {
fprintf(errfp, "\nhilight hash content: token=%s, path=%s, value=%d\n", entry->token, entry->path, entry->value); if(!first) my_strcat(93, str, ",");
my_strcat(562, str, entry->path+1);
my_strcat(1160, str, entry->token);
first = 0;
entry = entry->next; entry = entry->next;
} }
} }
@ -166,7 +168,7 @@ void create_plot_cmd(int viewer)
} }
} }
struct hilight_hashentry *hilight_lookup(char *token, int value, int remove) struct hilight_hashentry *hilight_lookup(const char *token, int value, int remove)
/* token remove ... what ... */ /* token remove ... what ... */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* "whatever" 0,XINSERT insert in hash table if not in and return NULL */ /* "whatever" 0,XINSERT insert in hash table if not in and return NULL */
@ -464,9 +466,9 @@ int search(const char *tok, const char *val, int sub, int sel, int what)
if(str && has_token) { if(str && has_token) {
#ifdef __unix__ #ifdef __unix__
if( (!regexec(&re, str,0 , NULL, 0) && !sub) || /* 20071120 regex instead of strcmp */ if( (!regexec(&re, str,0 , NULL, 0) && !sub) || /* 20071120 regex instead of strcmp */
(!strcmp(str,val) && sub) ) (!strcmp(str, val) && sub && !bus) || (strstr(str,val) && sub && bus))
#else #else
if (!strcmp(str, val) && sub) if ((!strcmp(str, val) && sub && !bus) || (strstr(str,val) && sub && bus))
#endif #endif
{ {
if(!sel) { /*20190525 */ if(!sel) { /*20190525 */
@ -693,6 +695,24 @@ void send_net_to_gaw(char *node)
} }
} }
int hilight_netname(const char *name)
{
int ret = 0;
struct node_hashentry *node_entry;
prepare_netlist_structs(0);
dbg(1, "hilight_netname(): entering\n");
rebuild_selected_array();
node_entry = bus_hash_lookup(name, "", XLOOKUP, 0, "", "", "", "");
ret = node_entry ? 1 : 0;
if(ret && !bus_hilight_lookup(name, hilight_color, XINSERT)) {
hilight_nets=1;
if(incr_hilight) hilight_color++;
}
redraw_hilights();
return ret;
}
void hilight_net(int to_waveform) void hilight_net(int to_waveform)
{ {
int i, n; int i, n;

View File

@ -221,7 +221,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"descend")) else if(!strcmp(argv[1],"descend"))
{ {
descend_schematic(); if(argc >=3) {
int n = atoi(argv[2]);
descend_schematic(n);
} else {
descend_schematic(0);
}
Tcl_ResetResult(interp); Tcl_ResetResult(interp);
} }
@ -1066,8 +1071,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
printf(" make symbol view from current schematic\n"); printf(" make symbol view from current schematic\n");
printf(" xschem place_text\n"); printf(" xschem place_text\n");
printf(" place new text\n"); printf(" place new text\n");
printf(" xschem sleep #ms\n");
printf(" sleep some ms\n");
printf(" xschem debug n\n"); printf(" xschem debug n\n");
printf(" set debug level to n: 1, 2, 3 for C Program \n"); printf(" set debug level to n: 1, 2, 3 for C Program \n");
printf(" -1,-2,-3 for Tcl frontend\n"); printf(" -1,-2,-3 for Tcl frontend\n");
@ -1114,6 +1117,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1], "print_hilight_net") && argc == 3) { else if(!strcmp(argv[1], "print_hilight_net") && argc == 3) {
print_hilight_net(atoi(argv[2])); print_hilight_net(atoi(argv[2]));
} }
else if(!strcmp(argv[1], "display_hilights")) {
char *str = NULL;
display_hilights(&str);
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, str, NULL);
my_free(1161, &str);
}
else if(!strcmp(argv[1],"clear_netlist_dir") ) { else if(!strcmp(argv[1],"clear_netlist_dir") ) {
my_strdup(373, &netlist_dir, ""); my_strdup(373, &netlist_dir, "");
@ -1420,6 +1431,16 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp); Tcl_ResetResult(interp);
} }
else if(!strcmp(argv[1],"hilight_netname"))
{
int ret = 0;
if(argc>=3) {
ret = hilight_netname(argv[2]);
}
Tcl_ResetResult(interp);
Tcl_AppendResult(interp,ret ? "1" : "0" , NULL);
}
else if(!strcmp(argv[1],"send_to_gaw")) else if(!strcmp(argv[1],"send_to_gaw"))
{ {
enable_drill = 0; enable_drill = 0;

View File

@ -854,7 +854,7 @@ extern void read_xschem_file(FILE *fd); /* 20180912 */
extern char *read_line(FILE *fp, int dbg_level); extern char *read_line(FILE *fp, int dbg_level);
extern void read_record(int firstchar, FILE *fp); extern void read_record(int firstchar, FILE *fp);
extern void create_sch_from_sym(void); extern void create_sch_from_sym(void);
extern void descend_schematic(void); extern void descend_schematic(int instnumber);
extern void go_back(int confirm); extern void go_back(int confirm);
extern void view_unzoom(double z); extern void view_unzoom(double z);
extern void view_zoom(double z); extern void view_zoom(double z);
@ -971,8 +971,10 @@ extern void print_verilog_signals(FILE *fd);
extern void print_generic(FILE *fd, char *ent_or_comp, int symbol); extern void print_generic(FILE *fd, char *ent_or_comp, int symbol);
extern void print_verilog_param(FILE *fd, int symbol); extern void print_verilog_param(FILE *fd, int symbol);
extern void hilight_net(int to_waveform); extern void hilight_net(int to_waveform);
extern int hilight_netname(const char *name);
extern void unhilight_net(); extern void unhilight_net();
extern void draw_hilight_net(int on_window); extern void draw_hilight_net(int on_window);
extern void display_hilights(char **str);
extern void redraw_hilights(void); extern void redraw_hilights(void);
extern void prepare_netlist_structs(int for_netlist); extern void prepare_netlist_structs(int for_netlist);
extern void delete_netlist_structs(void); extern void delete_netlist_structs(void);

View File

@ -635,6 +635,7 @@ proc xschem_server {sock addr port} {
## highlight the specified net. ## highlight the specified net.
proc probe_net {net} { proc probe_net {net} {
xschem unselect_all
xschem set no_draw 1 xschem set no_draw 1
# return to top level if not already there # return to top level if not already there
while { [xschem get currentsch] } { xschem go_back } while { [xschem get currentsch] } { xschem go_back }
@ -643,15 +644,21 @@ proc probe_net {net} {
regsub {\..*} $inst {} inst regsub {\..*} $inst {} inst
regsub {[^.]+\.} $net {} net regsub {[^.]+\.} $net {} net
xschem search exact 1 name $inst xschem search exact 1 name $inst
xschem descend set full_inst [split [lindex [xschem get expandlabel [xschem selected_set]] 0] {,}]
set instnum [expr [lsearch -exact $full_inst $inst] + 1]
puts "$full_inst --> $instnum"
xschem descend $instnum
# set a [lindex [split [lindex [xschem get expandlabel {xrdec[31:0]}] 0] ,] 3]
} }
set res [xschem search exact 0 lab $net] set res [xschem hilight_netname $net]
if {$res==0 && [regexp {^net[0-9]+$} $net]} { if {$res==0 && [regexp {^net[0-9]+$} $net]} {
xschem search exact 0 lab \#$net set res [xschem hilight_netname \#$net]
} }
xschem set no_draw 0 xschem set no_draw 0
xschem redraw xschem redraw
return $res
} }
proc simulate {{callback {}}} { proc simulate {{callback {}}} {
@ -724,6 +731,25 @@ proc gaw_setup_tcp {} {
puts $gaw_fd "table_set $s.raw" puts $gaw_fd "table_set $s.raw"
} }
proc gaw_cmd {cmd} {
global gaw_fd gaw_tcp_address netlist_dir no_x
if { [catch {eval socket $gaw_tcp_address} gaw_fd] } {
puts "Problems opening socket to gaw on address $gaw_tcp_address"
unset gaw_fd
if {![info exists no_x]} {
tk_messageBox -type ok -title {Tcp socket error} \
-message [concat "Problems opening socket to gaw on address $gaw_tcp_address. " \
"If you recently closed gaw the port may be in a TIME_WAIT state for a minute or so ." \
"Close gaw, Wait a minute or two, then send waves to gaw again."]
}
return
}
chan configure $gaw_fd -blocking 1 -buffering line -encoding binary -translation binary
puts $gaw_fd "$cmd"
fileevent $gaw_fd readable gaw_echoline
close $gaw_fd; unset gaw_fd;
}
proc waves {} { proc waves {} {
## $N : netlist file full path (/home/schippes/simulations/opamp.spice) ## $N : netlist file full path (/home/schippes/simulations/opamp.spice)
## $n : netlist file full path with extension chopped (/home/schippes/simulations/opamp) ## $n : netlist file full path with extension chopped (/home/schippes/simulations/opamp)
@ -2678,7 +2704,6 @@ proc launcher {} {
## puts ">>> $launcher_program $launcher_var " ## puts ">>> $launcher_program $launcher_var "
# 20170413 # 20170413
if { ![string compare $launcher_program {}] } { set launcher_program $launcher_default_program} if { ![string compare $launcher_program {}] } { set launcher_program $launcher_default_program}
eval exec [subst $launcher_program] {[subst $launcher_var]} & eval exec [subst $launcher_program] {[subst $launcher_var]} &
} }

View File

@ -1,5 +1,6 @@
v {xschem version=2.9.6 file_version=1.1} v {xschem version=2.9.7 file_version=1.2}
G {} G {}
K {}
V {} V {}
S {} S {}
E {} E {}
@ -95,7 +96,7 @@ C {code_shown.sym} 245 -245 0 0 {name=CONTROL value="* .control
* .endc * .endc
.option savecurrents .option savecurrents
.save all .save all
.tran 5n 1000u uic .tran 5n 600u uic
* .dc VP 0 21 0.01 * .dc VP 0 21 0.01
"} "}
C {code.sym} 15 -225 0 0 {name=MODELS value=".MODEL DIODE D(IS=1.139e-08 RS=0.99 CJO=9.3e-12 VJ=1.6 M=0.411 BV=30 EG=0.7 ) C {code.sym} 15 -225 0 0 {name=MODELS value=".MODEL DIODE D(IS=1.139e-08 RS=0.99 CJO=9.3e-12 VJ=1.6 M=0.411 BV=30 EG=0.7 )
@ -180,3 +181,6 @@ C {isource_table.sym} 1140 -320 0 0 {name=G2[9..0] CTRL="V(LED)" TABLE="
} }
C {ammeter.sym} 650 -650 3 0 {name=Vsw} C {ammeter.sym} 650 -650 3 0 {name=Vsw}
C {ammeter.sym} 860 -400 2 0 {name=Vdiode} C {ammeter.sym} 860 -400 2 0 {name=Vdiode}
C {launcher.sym} 655 -165 0 0 {name=h1
descr="Simulate + gaw reload"
tclcommand="set sim(spice,default) 1; set sim(spice,1,fg) 1; set sim(spice,1,st) 0;xschem netlist; xschem simulate; gaw_cmd reload_all"}