Implement existing cell check for layout generation

Added logic to check if subcircuits are already loaded and generate layouts accordingly.
This commit is contained in:
Ahmed Nematallah 2026-05-01 22:54:33 +02:00 committed by R. Timothy Edwards
parent df4ec3ab32
commit 97fd047aab
1 changed files with 25 additions and 4 deletions

View File

@ -525,11 +525,25 @@ proc magic::netlist_to_layout {netfile library} {
# Pre-generate placeholders for all subcircuits. # Pre-generate placeholders for all subcircuits.
set curtop [cellname list self] set curtop [cellname list self]
array set existing_cells {}
foreach subckt $allsubs { foreach subckt $allsubs {
# Diagnostic output if {$subckt == $curtop || $subckt == $topname} {
puts stdout "Pre-generating subcircuit $subckt placeholder" set existing_cells($subckt) "false"
load $subckt -silent
continue
}
if {[catch {load $subckt -fail -silent}] == 0} {
puts stdout "Subcircuit $subckt successfully loaded."
set existing_cells($subckt) "true"
} else {
puts stdout "Subcircuit $subckt not found. Will generate."
set existing_cells($subckt) "false"
# Now we load it normally to create the placeholder for the generator
load $subckt -silent load $subckt -silent
} }
}
load $curtop load $curtop
# Parse the file and process all lines # Parse the file and process all lines
@ -561,7 +575,14 @@ proc magic::netlist_to_layout {netfile library} {
} else { } else {
if {[regexp -nocase {^[ \t]*\.ends} $line]} { if {[regexp -nocase {^[ \t]*\.ends} $line]} {
set insub false set insub false
if {[info exists existing_cells($subname)] && $existing_cells($subname) == "false"} {
puts stdout "Cell $subname is empty. Generating initial layout..."
magic::generate_layout_add $subname $subpins $complist $library magic::generate_layout_add $subname $subpins $complist $library
} else {
puts stdout "Cell $subname already contains layout. Skipping generation."
}
set subname "" set subname ""
set subpins "" set subpins ""
set complist {} set complist {}