Ensure all cells are loaded into memory in netlist_to_spice to avoid file corruption during save

Added logic to ensure all cells are loaded into memory to prevent corruption when saving files. This is a fix for a minor edge case when generating "netlist_to_spice" for a file that already has a netlist, and which contains cells containing other cells. Followed by "writeall force". This causes unloaded files (that are still referenced) to be loaded during save with "ignoreTech" being true, and thus disregarding the scale, corrupting all coordinates if a scale is used.

This was caused by skipping regenerating cells that already had a .mag file
This commit is contained in:
Ahmed Nematallah 2026-05-03 05:12:21 +02:00 committed by GitHub
parent 3485e2af1a
commit 9622fc63d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -536,6 +536,12 @@ proc magic::netlist_to_layout {netfile library} {
if {[catch {load $subckt -fail -silent}] == 0} {
puts stdout "Subcircuit $subckt successfully loaded."
set existing_cells($subckt) "true"
# Make sure to load all cells into memory to avoid
# corruption when saving all files (files get loaded
# without taking the scale into account)
select top cell
expand
} else {
puts stdout "Subcircuit $subckt not found. Will generate."
set existing_cells($subckt) "false"