add command `xschem raw rename old_node new_node`

This commit is contained in:
stefan schippers 2025-03-08 21:14:46 +01:00
parent f1901e055c
commit 2f1643368e
4 changed files with 37 additions and 9 deletions

View File

@ -1200,8 +1200,9 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> push_undo</kbd></li><pre>
Push current state on undo stack </pre>
<li><kbd> raw what ...</kbd></li><pre>
what = add | clear | datasets | index | info | loaded | list | new | points | rawfile | del |
read | set | sim_type | switch | switch_back | table_read | value | values | pos_at | vars |
what = add | clear | datasets | index | info | loaded | list |
new | points | rawfile | del | read | set | rename |
sim_type | switch | switch_back | table_read | value | values | pos_at | vars |
xschem raw read filename [type [sweep1 sweep2]]
if sweep1, sweep2 interval is given in 'read' subcommand load only the interval
@ -1216,6 +1217,9 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
xschem raw del name
delete named vector from current raw file
xschem raw rename old_name new_name
rename a node in the loaded raw file.
xschem raw info
print information about loaded raw files and show the currently active one.
@ -1292,7 +1296,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
new dataset do not start with a header row.
Lines beginning with '#' are comments and ignored
time var_a var_b var_c
time var_a var_b var_cnode in the loaded raw file.
# this is a comment, ignored
0.0 0.0 1.8 0.3
&lt;single empty line: ignored&gt;

View File

@ -1074,6 +1074,22 @@ int raw_read(const char *f, Raw **rawptr, const char *type, int no_warning, doub
return 0;
}
int raw_renamevar(const char *old_name, const char *new_name)
{
int n, ret = 0;
Raw *raw = xctx->raw;
Int_hashentry *entry;
n = get_raw_index(old_name, &entry);
if(n < 0) return ret;
dbg(1, "n=%d, %s \n", n, entry->token);
int_hash_lookup(&raw->table, entry->token, 0, XDELETE);
my_strdup2(_ALLOC_ID_, &raw->names[n], new_name);
int_hash_lookup(&raw->table, raw->names[n], n, XINSERT); /* update hash table */
ret = 1;
return ret;
}
int raw_deletevar(const char *name)
{
int ret = 0;

View File

@ -4004,8 +4004,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
case 'r': /*----------------------------------------------*/
/* raw what ...
* what = add | clear | datasets | index | info | loaded | list | new | points | rawfile | del |
* read | set | sim_type | switch | switch_back | table_read | value | values | pos_at | vars |
* what = add | clear | datasets | index | info | loaded | list |
* new | points | rawfile | del | read | set | rename |
* sim_type | switch | switch_back | table_read | value | values | pos_at | vars |
*
* xschem raw read filename [type [sweep1 sweep2]]
* if sweep1, sweep2 interval is given in 'read' subcommand load only the interval
@ -4020,6 +4021,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
* xschem raw del name
* delete named vector from current raw file
*
* xschem raw rename old_name new_name
* rename a node in the loaded raw file.
*
* xschem raw info
* print information about loaded raw files and show the currently active one.
*
@ -4096,7 +4100,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
* new dataset do not start with a header row.
* Lines beginning with '#' are comments and ignored
*
* time var_a var_b var_c
* time var_a var_b var_cnode in the loaded raw file.
* # this is a comment, ignored
* 0.0 0.0 1.8 0.3
* <single empty line: ignored>
@ -4164,9 +4168,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
update_op();
}
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
} else if(argc > 3 && !strcmp(argv[2], "del")) {
ret = raw_deletevar(argv[3]);
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
} else if(argc > 2 && !strcmp(argv[2], "clear")) {
if(argc > 4) {
ret = extra_rawfile(3, argv[3], argv[4], -1.0, -1.0);
@ -4199,6 +4200,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_SetResult(interp, dtoa(val), TCL_VOLATILE);
}
}
} else if(argc > 3 && !strcmp(argv[2], "del")) {
ret = raw_deletevar(argv[3]);
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
} else if(argc > 4 && !strcmp(argv[2], "rename")) {
ret = raw_renamevar(argv[3], argv[4]);
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
} else if(argc > 3 && !strcmp(argv[2], "index")) {
/* xschem raw index v(ldcp) */
int idx;

View File

@ -1259,6 +1259,7 @@ extern int embed_rawfile(const char *rawfile);
extern int read_rawfile_from_attr(const char *b64s, size_t length, const char *type);
extern int raw_read_from_attr(Raw **rawptr, const char *type, double sweep1, double sweep2);
extern int raw_add_vector(const char *varname, const char *expr, int sweep_idx);
extern int raw_renamevar(const char *old_name, const char *new_name);
extern int raw_deletevar(const char *name);
extern int new_rawfile(const char *name, const char *type, const char *sweepvar,
double start, double end, double step);