From 66ba05fe2c134683b567b10c0f61b5ca320521b7 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Mon, 19 Feb 2024 13:03:28 +0100 Subject: [PATCH] add xschem list_nets command --- doc/xschem_man/developer_info.html | 2 ++ src/node_hash.c | 30 ++++++++++++++++++++++++++++++ src/scheduler.c | 11 +++++++++++ src/xschem.h | 1 + 4 files changed, 44 insertions(+) diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index 3fdea1c7..0b8acef1 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -922,6 +922,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" 20221014_091945 {/home/.../ngspice/comp_ngspice.sch}
  • list_hilights [sep]
  •      Sorted list of highlight nets, separated by character 'sep' (default: space) 
    +
  • list_nets
  • +    List all nets with type (in / out / inout / net) 
  • list_tokens str with_quotes
  •     List tokens in string 'str'
        with_quotes:
    diff --git a/src/node_hash.c b/src/node_hash.c
    index 0c1b7429..3b27f010 100644
    --- a/src/node_hash.c
    +++ b/src/node_hash.c
    @@ -367,3 +367,33 @@ void print_verilog_signals(FILE *fd)
       }
       if(found) fprintf(fd, "\n" );
     }
    +
    +void list_nets(char **result)
    +{
    +  Node_hashentry *ptr;
    +  char *type = NULL;
    +  int i;
    +  int netlist_lvs_ignore=tclgetboolvar("lvs_ignore");
    +
    +  prepare_netlist_structs(1);
    +  for(i = 0; i < xctx->instances; i++) {
    +    if(skip_instance(i, 0, netlist_lvs_ignore)) continue;
    +    my_strdup(_ALLOC_ID_, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
    +    if(type && xctx->inst[i].node && IS_PIN(type)) {
    +      my_mstrcat(_ALLOC_ID_, result, 
    +        "{", get_tok_value(xctx->inst[i].prop_ptr, "lab", 0), " ", type, "}\n", NULL);
    +    }
    +  }
    +  if(type) my_free(_ALLOC_ID_, &type);
    +  for(i=0;inode_table[i];
    +    while(ptr) {
    +      if(!ptr->d.port) {
    +        my_mstrcat(_ALLOC_ID_, result, 
    +          "{", ptr->token, " ", "net", "}\n", NULL);
    +      }
    +      ptr = ptr->next;
    +    }
    +  }
    +}
    +
    diff --git a/src/scheduler.c b/src/scheduler.c
    index c537b5dd..2e0d2aed 100644
    --- a/src/scheduler.c
    +++ b/src/scheduler.c
    @@ -2419,6 +2419,17 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
           tclvareval("join [lsort -decreasing -dictionary {", tclresult(), "}] ", sep, NULL);
         }
     
    +    /* list_nets
    +     *    List all nets with type (in / out / inout / net) */
    +    else if(!strcmp(argv[1], "list_nets"))
    +    {
    +      char *result = NULL;
    +      if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
    +      list_nets(&result);
    +      Tcl_SetResult(interp, result, TCL_VOLATILE);
    +      my_free(_ALLOC_ID_, &result);
    +    }
    +
         /* list_tokens str with_quotes
          *   List tokens in string 'str'
          *   with_quotes:
    diff --git a/src/xschem.h b/src/xschem.h
    index a80b8370..c10e40b5 100644
    --- a/src/xschem.h
    +++ b/src/xschem.h
    @@ -1647,6 +1647,7 @@ extern void round_schematic_to_grid(double cadsnap);
     extern void save_selection(int what);
     extern void print_vhdl_signals(FILE *fd);
     extern void print_verilog_signals(FILE *fd);
    +extern void list_nets(char **result);
     extern void print_generic(FILE *fd, char *ent_or_comp, int symbol);
     extern void print_verilog_param(FILE *fd, int symbol);
     extern void hilight_net(int to_waveform);