diff --git a/VERSION b/VERSION index efcf0035..1376da5e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.448 +8.3.449 diff --git a/tcltk/toolkit.tcl b/tcltk/toolkit.tcl index d5663fa1..9062bb91 100644 --- a/tcltk/toolkit.tcl +++ b/tcltk/toolkit.tcl @@ -375,7 +375,30 @@ proc magic::netlist_to_layout {netfile library} { set ignorekeys {.global .ic .option .end} - # Parse the file + # Parse the file once and find all subcircuits being defined, to + # catch any issues with subcircuits being used before they are + # defined. + set allsubs {} + foreach line $fdata { + set ftokens [split $line] + set keyword [string tolower [lindex $ftokens 0]] + if {$keyword == ".subckt"} { + set subname [lindex $ftokens 1] + lappend allsubs $subname + } + } + # Generate list of pre-existing top level cells + set existing [cellname list top] + # Pre-generate placeholders for all subcircuits. + set curtop [cellname list self] + + foreach subckt $allsubs { + puts stdout "Test: pre-generating subcircuit $subckt" + load $subckt -silent + } + load $curtop + + # Parse the file and process all lines foreach line $fdata { if {$incmd} { if {[regexp -nocase {^[ \t]*\.endc} $line]} { @@ -421,7 +444,20 @@ proc magic::netlist_to_layout {netfile library} { # Add in any top-level components (not in subcircuits) if {[llength $toplist] > 0} { + # Make sure the top level cell is loaded before adding top-level + # components. + load $curtop magic::generate_layout_add $topname "" $toplist $library + } else { + # There was no top level, so load the first new top cell that + # was generated by the import. + set allcells [cellname list top] + foreach cell $allcells { + if {[lsearch $existing $cell] < 0} { + load $cell + break + } + } } # resumeall