add ev_precision xschemrc setting (set ev_precision 5) to change significant digits returned by TCL ev procedure and xschem expr_eng() expression parser. Default is 4 significant digits.

This commit is contained in:
stefan schippers 2026-03-20 00:47:52 +01:00
parent 1695f81947
commit 7bdb6855c7
4 changed files with 16 additions and 6 deletions

View File

@ -237,7 +237,7 @@ void eval_expr_clear_table(void)
static int kklex()
{
int c;
int eng = tclgetintvar("ev_precision");
if(!str) { return 0; }
if(strstr(str, "expr(") == str) {
lex_state = 1;
@ -251,7 +251,7 @@ static int kklex()
lex_state = 1;
str += 9;
dbg(dbglev, "lex(): EXPR_ENG\n");
engineering = 5;
engineering = eng;
return EXPR;
}

View File

@ -683,9 +683,11 @@ proc ev7 {args} {
## evaluate expression. if expression has errors or does not evaluate return expression as is
proc ev {args} {
global ev_precision
if {[info exists ev_precision]} {set pr $ev_precision} else {set pr 4}
set i [join $args]
if {![catch {uplevel #0 expr $i} res]} {
return [format %.4g $res]
return [format %.${pr}g $res]
} else {
# puts stderr "proc ev: $res"
return $args
@ -9373,7 +9375,7 @@ set tctx::global_list {
dim_bg dim_value disable_unique_names do_all_inst draw_crosshair draw_grid draw_grid_axes
draw_window edit_prop_pos edit_prop_size edit_symbol_prop_new_sel editprop_sympath
en_hilight_conn_inst enable_dim_bg enable_stretch env(PDK) env(PDK_ROOT)
enter_text_default_geometry erc_open_net_is_error erc_shorted_output_is_error
enter_text_default_geometry erc_open_net_is_error erc_shorted_output_is_error ev_precision
file_chooser(regex) file_chooser(action) file_chooser(dirs)
filetmp
fix_broken_tiled_fill flat_netlist fullscreen gaw_fd gaw_tcp_address graph_autoload graph_bus
@ -11015,6 +11017,7 @@ set_ne graph_use_ctrl_key 0;# if set forces to use Control key to operate on gra
set_ne spiceprefix 1
set_ne verilog_2001 1
set_ne verilog_bitblast 0
set_ne ev_precision 4
set_ne search_schematic 0
# if set to 1 search symbols (if not in any of the XSCHEM_LIBRARY_PATH directories) in [pwd]
# instead of in the directory of currently loaded schematic.

View File

@ -156,6 +156,10 @@
#### Allowed values: spice, verilog, vhdl, tedax, default: spice
# set netlist_type spice
#### significant digits of the TCL 'ev' procedure, used to round numbers in netlists and shown device values.
#### default: 4
# set ev_precision 6
#### Some netlisting options (these are the defaults)
# set verilog_2001 1

View File

@ -1,4 +1,4 @@
v {xschem version=3.4.4 file_version=1.2
v {xschem version=3.4.8RC file_version=1.3
*
* This file is part of XSCHEM,
* a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit
@ -19,7 +19,8 @@ v {xschem version=3.4.4 file_version=1.2
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
}
G {type=netlist_commands
G {}
K {type=netlist_commands
template="name=s1 only_toplevel=false value=blabla"
format="
@value
@ -29,6 +30,7 @@ spectre_format="
"}
V {}
S {}
F {}
E {}
L 4 20 30 60 30 {}
L 4 20 40 40 40 {}
@ -48,3 +50,4 @@ L 4 10 100 100 100 {}
L 4 10 0 10 100 {}
L 4 10 0 100 0 {}
T {@name} 15 -25 0 0 0.3 0.3 {}
T {expr_eng(10000000000.0 / 3.0)} 15 -55 0 0 0.3 0.3 {}