From f850877b1e0fa6fc36ac4624f0a1ed1473ea7b52 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 6 Aug 2024 12:20:32 +0200 Subject: [PATCH] added tcl variable top_is_subckt and related Simulation->LVS menu, that keeps top level wrapped inside a .subckt / .ends, as lvs_netlist does. However top_is_subckt does only that and will not enable lvs_format to differentiate device lines in netlist (usually used for LVS comparison). --- src/netlist.c | 8 ++++++++ src/spice_netlist.c | 4 ++-- src/xschem.tcl | 11 ++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/netlist.c b/src/netlist.c index de0fff73..58dd92db 100644 --- a/src/netlist.c +++ b/src/netlist.c @@ -618,6 +618,14 @@ void netlist_options(int i) if(!strboolcmp(str, "true")) tclsetintvar("lvs_netlist", 1); else tclsetintvar("lvs_netlist", 0); } + + str = get_tok_value(xctx->inst[i].prop_ptr, "top_is_subckt", 0); + if(str[0]) { + /* fprintf(errfp, "netlist_options(): prop_ptr=%s\n", xctx->inst[i].prop_ptr); */ + if(!strboolcmp(str, "true")) tclsetintvar("top_is_subckt", 1); + else tclsetintvar("top_is_subckt", 0); + } + str = get_tok_value(xctx->inst[i].prop_ptr, "spiceprefix", 0); if(str[0]) { /* fprintf(errfp, "netlist_options(): prop_ptr=%s\n", xctx->inst[i].prop_ptr); */ diff --git a/src/spice_netlist.c b/src/spice_netlist.c index 11322071..59512478 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -176,7 +176,7 @@ static int spice_netlist(FILE *fd, int spice_stop ) int top_sub; int lvs_ignore = tclgetboolvar("lvs_ignore"); - top_sub = tclgetboolvar("lvs_netlist"); + top_sub = tclgetboolvar("lvs_netlist") || tclgetboolvar("top_is_subckt"); if(!spice_stop) { dbg(1, "spice_netlist(): invoke prepare_netlist_structs for %s\n", xctx->current_name); xctx->prep_net_structs = 0; @@ -338,7 +338,7 @@ int global_spice_netlist(int global) /* netlister driver */ netlist_options(i); } } - top_sub = tclgetboolvar("lvs_netlist"); + top_sub = tclgetboolvar("lvs_netlist") || tclgetboolvar("top_is_subckt"); if(!top_sub) fprintf(fd,"**"); fprintf(fd,".subckt %s", get_cell(xctx->sch[xctx->currsch], 0)); pinnumber_list = sort_schematic_pins(&npins); /* sort pins according to sim_pinnumber attr */ diff --git a/src/xschem.tcl b/src/xschem.tcl index f8987930..c2ecd8ca 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -6960,7 +6960,7 @@ set tctx::global_list { incr_hilight incremental_select infowindow_text intuitive_interface keep_symbols launcher_default_program light_colors line_width live_cursor2_backannotate local_netlist_dir lvs_ignore - lvs_netlist measure_text netlist_dir netlist_show netlist_type no_ask_save + lvs_netlist measure_text netlist_dir netlist_show netlist_type no_ask_save no_change_attrs nolist_libs noprint_libs old_selected_tok only_probes path pathlist persistent_command preserve_unchanged_attrs prev_symbol ps_colors ps_paper_size rainbow_colors tctx::rcode recentfile @@ -6971,7 +6971,7 @@ set tctx::global_list { svg_font_name sym_txt symbol symbol_width tabstop tclcmd_txt tclstop text_line_default_geometry text_replace_selection text_tabs_setting textwindow_fileid textwindow_filename textwindow_w toolbar_horiz toolbar_list - toolbar_visible transparent_svg undo_type use_lab_wire unselect_partial_sel_wires + toolbar_visible top_is_subckt transparent_svg undo_type use_lab_wire unselect_partial_sel_wires use_label_prefix use_tclreadline user_wants_copy_cell verilog_2001 verilog_bitblast viewdata_fileid viewdata_filename viewdata_w tctx::vsize xschem_libs xschem_listen_port zoom_full_center @@ -7961,7 +7961,7 @@ tclcommand=\"xschem raw_read \$netlist_dir/[file tail [file rootname [xschem get $topwin.menubar.simulation.menu add cascade -label "LVS" -menu $topwin.menubar.simulation.menu.lvs menu $topwin.menubar.simulation.menu.lvs -tearoff 0 - $topwin.menubar.simulation.menu.lvs add checkbutton -label "LVS netlist: Top level is a .subckt" \ + $topwin.menubar.simulation.menu.lvs add checkbutton -label "LVS netlist + Top level is a .subckt" \ -selectcolor $selectcolor -variable lvs_netlist -command { if {$lvs_netlist == 1} { xschem set format lvs_format @@ -7969,6 +7969,10 @@ tclcommand=\"xschem raw_read \$netlist_dir/[file tail [file rootname [xschem get xschem set format {} } } + + $topwin.menubar.simulation.menu.lvs add checkbutton -label "Top level is a .subckt" \ + -selectcolor $selectcolor -variable top_is_subckt + $topwin.menubar.simulation.menu.lvs add checkbutton -label "Set 'lvs_ignore' variable" \ -selectcolor $selectcolor \ -variable lvs_ignore -command {xschem rebuild_connectivity; xschem unhilight_all} @@ -8366,6 +8370,7 @@ set_ne netlist_type spice set_ne local_netlist_dir 0 ;# if set use /simulation for netlist and sims set_ne bus_replacement_char {} ;# use {<>} to replace [] with <> in bussed signals set_ne lvs_netlist 0 +set_ne top_is_subckt 0 set_ne lvs_ignore 0 set_ne hide_empty_graphs 0 ;# if set to 1 waveform boxes will be hidden if no raw file loaded set_ne spiceprefix 1