From 1336e25e6877f2a0eb6dad2bcc811706f35c08ef Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 20 Feb 2024 17:17:38 +0100 Subject: [PATCH] added xschem raw_query set node n value [dset] command to change loaded raw data --- doc/xschem_man/developer_info.html | 12 ++++++----- doc/xschem_man/graphs.html | 2 +- src/scheduler.c | 34 +++++++++++++++++++++++++++--- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index 0b8acef1..6713c0c5 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -547,6 +547,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" +
  • abort_operation
  • @@ -1093,18 +1094,18 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
        
  • push_undo
  •     Push current state on undo stack 
  • raw what [rawfile type] [sweep1 sweep2]
  • -       what = read | clear | info | switch | switch_back
    +   what = read | clear | info | switch | switch_back
        Load / clear / switch additional raw files
        if sweep1, sweep2 interval is given in 'read' subcommand load only the interval
        sweep1 <= sweep_var < sweep2 
  • raw_clear
  •     Unload all simulation raw files 
    -
  • raw_query loaded|value|index|values|datasets|vars|list
  • +   
  • raw_query loaded|value|index|values|datasets|vars|list|set
  •     xschem raw_query list: get list of saved simulation variables
        xschem raw_query vars: get number of simulation variables
        xschem raw_query datasets: get number of datasets (simulation runs)
        xschem raw_query value node n [dataset]: return n-th value of 'node' in raw file
    -     If n is egiven as empty string {} return value at cursor b, dataset not used in this case
    +   If n is given as empty string {} return value at cursor b, dataset not used in this case
        xschem raw_query loaded: return hierarchy level
        where raw file was loaded or -1 if no raw loaded
        xschem raw_query rawfile: return raw filename 
    @@ -1114,7 +1115,9 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
        xschem raw_query values node [dset] : print all simulation
        values of 'node' for dataset 'dset' (default dset=0)
        xschem raw_query points [dset] : print simulation points for
    -   dataset 'dset' (default: all dataset points combined)
    + dataset 'dset' (default: all dataset points combined) + xschem raw_query set node n value [dataset] : change loaded raw file data node[n] to value +
  • raw_read [file] [sim] [sweep1 sweep2]
  •     If a raw file is already loaded delete from memory
        then load specified file and analysis 'sim' (dc, ac, tran, op, ...)
    @@ -1512,7 +1515,6 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
     
     
     
    -
     
     
      
    diff --git a/doc/xschem_man/graphs.html b/doc/xschem_man/graphs.html
    index 37101587..fdbce825 100644
    --- a/doc/xschem_man/graphs.html
    +++ b/doc/xschem_man/graphs.html
    @@ -265,7 +265,7 @@ The following syntax:
      

    The graph dialog box has a Sweep textbox where you can write the X-axis variable. By default xschem uses the first variable in the raw file for the X-axis, and this is the sweep variable the simulation was done, so time for transients, frequency for AC sims, voltage or current sweep - for DC sims. Example below shows a cmos latch where a DC simulation has vbeen done sweeping the voltage generator + for DC sims. Example below shows a cmos latch where a DC simulation has been done sweeping the voltage generator on the a input from 0 to 3V.


    If v(a) v(z) is specified in the Sweep textbox (or a z) the z signal diff --git a/src/scheduler.c b/src/scheduler.c index 2e0d2aed..56d38610 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -3418,7 +3418,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg break; case 'r': /*----------------------------------------------*/ /* raw what [rawfile type] [sweep1 sweep2] - * what = read | clear | info | switch | switch_back + * what = read | clear | info | switch | switch_back * Load / clear / switch additional raw files * if sweep1, sweep2 interval is given in 'read' subcommand load only the interval * sweep1 <= sweep_var < sweep2 */ @@ -3477,12 +3477,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_ResetResult(interp); } - /* raw_query loaded|value|index|values|datasets|vars|list + /* raw_query loaded|value|index|values|datasets|vars|list|set * xschem raw_query list: get list of saved simulation variables * xschem raw_query vars: get number of simulation variables * xschem raw_query datasets: get number of datasets (simulation runs) * xschem raw_query value node n [dataset]: return n-th value of 'node' in raw file - * If n is egiven as empty string {} return value at cursor b, dataset not used in this case + * If n is given as empty string {} return value at cursor b, dataset not used in this case * xschem raw_query loaded: return hierarchy level * where raw file was loaded or -1 if no raw loaded * xschem raw_query rawfile: return raw filename @@ -3493,6 +3493,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg * values of 'node' for dataset 'dset' (default dset=0) * xschem raw_query points [dset] : print simulation points for * dataset 'dset' (default: all dataset points combined) + * xschem raw_query set node n value [dataset] : change loaded raw file data node[n] to value + * */ else if(!strcmp(argv[1], "raw_query")) { @@ -3568,6 +3570,32 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg if(i > 0) Tcl_AppendResult(interp, "\n", NULL); Tcl_AppendResult(interp, raw->names[i], NULL); } + /* 0 1 2 3 4 5 6 + * xschem raw_query set node n value [dataset] */ + } else if(argc > 5 && !strcmp(argv[2], "set")) { + int dataset = -1, ofs = 0; + int point = atoi(argv[4]); + const char *node = argv[3]; + int idx = -1; + if(argc > 6) dataset = atoi(argv[6]); + idx = get_raw_index(node); + if(idx >= 0) { + if( dataset < xctx->raw->datasets && + ( (dataset >=0 && point >= 0 && point < raw->npoints[dataset]) || + (dataset == -1 && point >= 0 && point < raw->allpoints) ) + ) { + if(dataset != -1) { + for(i = 0; i < dataset; ++i) { + ofs += xctx->raw->npoints[i]; + } + if(ofs + point < xctx->raw->allpoints) { + point += ofs; + } + } + xctx->raw->values[idx][point] = (SPICE_DATA) atof(argv[5]); + Tcl_SetResult(interp, dtoa(xctx->raw->values[idx][point]), TCL_VOLATILE); + } + } } } }