From a5d3376f8a3d11bbb90b8334b946821c4857c70d Mon Sep 17 00:00:00 2001 From: Ben Bowers Date: Wed, 10 Jul 2024 08:16:11 -0400 Subject: [PATCH] added writer for DENSITY --- lef21/src/write.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lef21/src/write.rs b/lef21/src/write.rs index c0baa01..baaaac7 100644 --- a/lef21/src/write.rs +++ b/lef21/src/write.rs @@ -203,9 +203,10 @@ impl<'wr> LefWriter<'wr> { self.indent -= 1; self.write_line(format_args_f!("{End} "))?; } - - // DENSTITY and PROPERTIES would go here - // if mac.density.is_some() { } + if let Some(ref v) = mac.density { + self.write_density(v)?; + } + // PROPERTIES would go here // if mac.properties.is_some() { } self.indent -= 1; @@ -354,6 +355,23 @@ impl<'wr> LefWriter<'wr> { self.write_line(format_args_f!("{Symmetry} {symmstr} ;"))?; Ok(()) } + + /// Write the DENSITY construct which includes LAYER and density RECT statements. + fn write_density(&mut self, dens_geoms: &Vec) -> LefResult<()> { + use LefKey::{Density, End, Layer, Rect}; + self.write_line(format_args_f!("{Density} "))?; + self.indent += 1; + for layer_geom_set in dens_geoms.iter() { + self.write_line(format_args_f!("{Layer} {layer_geom_set.layer_name} ; "))?; + for dens_rect in layer_geom_set.geometries.iter() { + self.write_line(format_args_f!("{Rect} {dens_rect.pt1} {dens_rect.pt2} {dens_rect.density_value} ; "))?; + } + } + self.indent -= 1; + self.write_line(format_args_f!("{End} "))?; + Ok(()) + } + /// Write the [LefMacroClass] enumerations. /// Note most sub-types use their macro-generated [Display] implementations. fn write_macro_class(&mut self, class: &LefMacroClass) -> LefResult<()> {