From 85d7e565a372c8f3433ca198751ff7ec39d15160 Mon Sep 17 00:00:00 2001 From: Stefan Schippers Date: Sun, 24 Mar 2024 19:34:30 +0100 Subject: [PATCH] cairo_font_scale can be changed runtime to rescale text fonts, hier_hilight_hash_lookup(() function to hilight an arbitrary hierarchic net; improved xschem list_hilights command --- doc/xschem_man/developer_info.html | 8 ++++++-- src/draw.c | 1 + src/hilight.c | 27 +++++++++++++++++++++++++-- src/save.c | 2 +- src/scheduler.c | 28 +++++++++++++++++++--------- src/xschem.h | 4 +++- src/xschem.tcl | 2 +- 7 files changed, 56 insertions(+), 16 deletions(-) diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index b5c6e8f0..ba211b3a 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -944,8 +944,12 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" 20230211_010031 {/home/.../ngspice/pv_ngspice.sch} 20221011_175308 {/home/.../ngspice/diode_ngspice.sch} 20221014_091945 {/home/.../ngspice/comp_ngspice.sch} -
  • list_hilights [sep]
  • -    Sorted list of highlight nets, separated by character 'sep' (default: space) 
    +
  • list_hilights [sep | all | all_nets | all_inst]
  • +    Sorted list of non port or non top level current level highlight nets,
    +    separated by character 'sep' (default: space)
    +    if `all_inst` is given list all instance hilights
    +    if `all_nets` is given list all net hilights
    +    if `all` is given list all hash content 
  • list_nets
  •      List all nets with type (in / out / inout / net) 
  • list_tokens str with_quotes
  • diff --git a/src/draw.c b/src/draw.c
    index 593b1b90..c44c9fe7 100644
    --- a/src/draw.c
    +++ b/src/draw.c
    @@ -4405,6 +4405,7 @@ void draw(void)
       
       if(!xctx || xctx->no_draw) return;
       cs = tclgetdoublevar("cadsnap");
    +  cairo_font_scale  = tclgetdoublevar("cairo_font_scale");
       xctx->cadhalfdotsize = CADHALFDOTSIZE * (cs < 20. ? cs : 20.) / 10.;
       xctx->crosshair_layer = tclgetintvar("crosshair_layer");
       if(xctx->crosshair_layer < 0 ) xctx->crosshair_layer = 2;
    diff --git a/src/hilight.c b/src/hilight.c
    index 23e3cf89..498cc584 100644
    --- a/src/hilight.c
    +++ b/src/hilight.c
    @@ -194,6 +194,18 @@ Hilight_hashentry *bus_hilight_hash_lookup(const char *token, int value, int wha
       return ptr2;
     }
     
    +Hilight_hashentry *hier_hilight_hash_lookup(const char *token, int value, char *path, int what)
    +{
    +  Hilight_hashentry *entry;
    +  char *oldpath = xctx->sch_path[xctx->currsch];
    +  xctx->sch_path_hash[xctx->currsch] = 0;
    +  xctx->sch_path[xctx->currsch] = path;
    +  entry = bus_hilight_hash_lookup(token, value, what);
    +  xctx->sch_path[xctx->currsch] = oldpath;
    +  xctx->sch_path_hash[xctx->currsch] = 0;
    +  return entry;
    +}
    +
     /* what:
      *  1: list only nets
      *  2: list only intances
    @@ -2259,7 +2271,7 @@ void print_hilight_net(int show)
      my_free(_ALLOC_ID_, &filetmp2);
     }
     
    -void list_hilights(void)
    +void list_hilights(int all)
     {
      int i, first = 1;
      Hilight_hashentry *entry;
    @@ -2268,6 +2280,17 @@ void list_hilights(void)
      Tcl_ResetResult(interp);
      prepare_netlist_structs(1); /* use full prepare_netlist_structs(1)  to recognize pin direction */
                                  /* when creating pins from hilight nets 20171221 */
    + if(all) {
    +   for(i=0;ihilight_table[i];
    +     for( entry=xctx->hilight_table[i]; entry; entry = entry->next) {
    +       if(all == 1 &&  entry->token[0] == ' ') continue;
    +       if(all == 2 &&  entry->token[0] != ' ') continue;
    +       Tcl_AppendResult(interp,  entry->path, "  ",
    +          entry->token, "  ", my_itoa(entry->value), "\n", NULL);
    +     }
    +   }
    + } else 
      for(i=0;ihilight_table[i];
        while(entry) {
    @@ -2278,7 +2301,7 @@ void list_hilights(void)
               entry->token[0] == '#' ? entry->token + 1 : entry->token, NULL);
            first = 0;
          }
    -     entry = entry ->next ;
    +     entry = entry ->next;
        }
      }
     }
    diff --git a/src/save.c b/src/save.c
    index 10e8a6e1..2c0a3c6f 100644
    --- a/src/save.c
    +++ b/src/save.c
    @@ -825,7 +825,7 @@ int raw_read_from_attr(Raw **rawptr, const char *type, double sweep1, double swe
             res = raw_read(tmp_filename, rawptr, type, sweep1, sweep2);
             unlink(tmp_filename);
           } else {
    -        dbg(0, "read_rawfile_from_attr(): failed to open file %s for reading\n", tmp_filename);
    +        dbg(0, "raw_read_from_attr(): failed to open file %s for reading\n", tmp_filename);
           }
         }
       }
    diff --git a/src/scheduler.c b/src/scheduler.c
    index 4af58602..c248f116 100644
    --- a/src/scheduler.c
    +++ b/src/scheduler.c
    @@ -2545,19 +2545,25 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
           my_free(_ALLOC_ID_, &res);
         }
     
    -    /* list_hilights [sep]
    -     *    Sorted list of highlight nets, separated by character 'sep' (default: space) */
    +    /* list_hilights [sep | all | all_nets | all_inst]
    +     *    Sorted list of non port or non top level current level highlight nets,
    +     *    separated by character 'sep' (default: space)
    +     *    if `all_inst` is given list all instance hilights
    +     *    if `all_nets` is given list all net hilights
    +     *    if `all` is given list all hash content */
         else if(!strcmp(argv[1], "list_hilights"))
         {
    -      const char *sep;
    +      const char *sep = "{ }";
    +      int i, all = 0;
           if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
    -      if(argc > 2) {
    -        sep = argv[2];
    -      } else {
    -        sep = "{ }";
    +      for(i = 2; i < argc; i++) {
    +        if(!strcmp(argv[i], "all")) all = 3;
    +        else if(!strcmp(argv[i], "all_inst")) all = 2;
    +        else if(!strcmp(argv[i], "all_nets")) all = 1;
    +        else sep = argv[i];
           }
    -      list_hilights();
    -      tclvareval("join [lsort -decreasing -dictionary {", tclresult(), "}] ", sep, NULL);
    +      list_hilights(all);
    +      if(!all) tclvareval("join [lsort -decreasing -dictionary {", tclresult(), "}] ", sep, NULL);
         }
     
         /* list_nets
    @@ -5409,6 +5415,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
             Tcl_ResetResult(interp);
           }
           else if(argc > 2 && atoi(argv[2]) == 2) {
    +        prepare_netlist_structs(0);
    +        hier_hilight_hash_lookup("LDCP_REF", 0, ".x17.xctrl.", XINSERT);
    +        hier_hilight_hash_lookup(" x4", 1, ".x17.xctrl.", XINSERT);
    +        propagate_hilights(1, 0, XINSERT_NOREPLACE);
             Tcl_ResetResult(interp);
           }
           else if(argc > 2 && atoi(argv[2]) == 3) {
    diff --git a/src/xschem.h b/src/xschem.h
    index 3ce176fe..42d52dd8 100644
    --- a/src/xschem.h
    +++ b/src/xschem.h
    @@ -1303,6 +1303,8 @@ extern void save_ascii_string(const char *ptr, FILE *fd, int newline);
     extern Hilight_hashentry *bus_hilight_hash_lookup(const char *token, int value, int what) ;
     /* wrapper function to hash highlighted instances, avoid clash with net names */
     extern Hilight_hashentry *inst_hilight_hash_lookup(int i, int value, int what);
    +/* wrapper to bus_hilight_hash_lookup that provides a signal path instead of using xctx->sch_path */
    +extern Hilight_hashentry *hier_hilight_hash_lookup(const char *token, int value, char *path, int what);
     extern Hilight_hashentry *hilight_lookup(const char *token, int value, int what);
     extern int search(const char *tok, const char *val, int sub, int sel, int match_case);
     extern int process_options(int argc, char **argv);
    @@ -1709,7 +1711,7 @@ extern char *str_replace(const char *str, const char *rep, const char *with, int
     extern char *escape_chars(const char *source, const char *charset);
     extern int set_different_token(char **s,const char *new, const char *old);
     extern void print_hilight_net(int show);
    -extern void list_hilights(void);
    +extern void list_hilights(int all);
     extern void change_layer();
     extern void launcher();
     extern void windowid(const char *winpath);
    diff --git a/src/xschem.tcl b/src/xschem.tcl
    index 4b920a10..1b6fe460 100644
    --- a/src/xschem.tcl
    +++ b/src/xschem.tcl
    @@ -6871,7 +6871,7 @@ set tctx::global_list {
       INITIALINSTDIR INITIALLOADDIR INITIALPROPDIR INITIALTEXTDIR XSCHEM_LIBRARY_PATH
       add_all_windows_drives auto_hilight autofocus_mainwindow
       autotrim_wires bespice_listen_port big_grid_points bus_replacement_char cadgrid cadlayers
    -  cadsnap cairo_font_name change_lw color_ps tctx::colors compare_sch constr_mv
    +  cadsnap cairo_font_name cairo_font_scale change_lw color_ps tctx::colors compare_sch constr_mv
       copy_cell crosshair_layer custom_label_prefix custom_token dark_colors dark_colorscheme
       dark_gui_colorscheme delay_flag  dim_bg dim_value disable_unique_names
       do_all_inst draw_crosshair