@@ -13,6 +13,7 @@ proc relative_rectangle { rect offset } {
1313 [expr [lindex $rect 3] - [lindex $offset 1]]]
1414}
1515
16+ # tclint-disable-next-line command-args
1617if [package vcompare 8.6 $tcl_version ] {
1718 proc lmap {_var list body} {
1819 upvar 1 $_var var
@@ -26,11 +27,13 @@ namespace eval lef {
2627variable lefOut stdout
2728variable def_units 2000
2829
30+ # tclint-disable-next-line redefined-builtin
2931proc open { file_name } {
3032 variable lefOut
3133 set lefOut [::open $file_name w]
3234}
3335
36+ # tclint-disable-next-line redefined-builtin
3437proc close { } {
3538 variable lefOut
3639 if { $lefOut != " stdout" } {
@@ -69,6 +72,7 @@ proc get_height { cell } {
6972 return [expr [lindex [dict get $cell die_area] 3] - [lindex [dict get $cell die_area] 1]]
7073}
7174
75+ # tclint-disable line-length
7276proc read_macros { file_name } {
7377 variable cells
7478 variable def_units
@@ -247,6 +251,7 @@ proc read_macros { file_name } {
247251
248252 ::close $ch
249253}
254+ # tclint-enable line-length
250255
251256proc get_blockage_layers { design } {
252257 if { [dict exists $design blockage_layers] } {
@@ -267,6 +272,7 @@ proc write_header { } {
267272proc write_footer { } {
268273
269274}
275+ # tclint-disable-next-line line-length
270276# Read a LEF from a file into a dictionary with the name of the cell as the key and the following entries
271277# - cell_class
272278# - origin
@@ -288,13 +294,13 @@ proc write_footer { } {
288294# - shape
289295# - ports: a list of lists of shapes that make up a physical connection
290296# - layer
291- # - rect
297+ # - rect
292298# - mask?
293299# - obstructions
294300# - layer: a dictionaries with layer_name as the key
295- # - rect
301+ # - rect
296302# - mask?
297- #
303+ #
298304proc write { design } {
299305 set def_units [dict get $design units]
300306
@@ -306,7 +312,9 @@ proc write { design } {
306312 out " ORIGIN 0.0 0.0 ;"
307313 }
308314 out " FOREIGN [ dict get $design foreign ref] [ dict get $design foreign origin] ;"
309- out " SIZE [ expr 1.0 * [lindex [dict get $design die_area] 2] / $def_units ] BY [ expr 1.0 * [lindex [dict get $design die_area] 3] / $def_units ] ;"
315+ out [concat \
316+ " SIZE [ expr 1.0 * [lindex [dict get $design die_area] 2] / $def_units ]" \
317+ " BY [ expr 1.0 * [lindex [dict get $design die_area] 3] / $def_units ] ;" ]
310318 out " SYMMETRY [ dict get $design symmetry] ;"
311319 if { [dict exists $design site] } {
312320 out " SITE [ dict get $design site] ;"
@@ -336,7 +344,10 @@ proc write { design } {
336344 set rect [absolute_rectangle [dict get $shape rect] $offset ]
337345
338346 if { [dict exists $shape mask] } {
339- out " RECT MASK [ dict get $shape mask] [ lmap x $rect { expr 1.0 * $x / $def_units }] ;"
347+ out [concat \
348+ " RECT MASK [ dict get $shape mask] " \
349+ " [ lmap x $rect { expr { 1.0 * $x / $def_units } }] " \
350+ " ;" ]
340351 } else {
341352 out " RECT [ lmap x $rect { expr 1.0 * $x / $def_units }] ;"
342353 }
@@ -354,7 +365,10 @@ proc write { design } {
354365 dict for {layer_name obstructions} [dict get $design obstructions] {
355366 lappend blocked_layers $layer_name
356367 }
357- set sheet " 0 0 [ expr 1.0 * [lindex [dict get $design die_area] 2] / $def_units ] [ expr 1.0 * [lindex [dict get $design die_area] 3] / $def_units ]"
368+ set sheet [concat \
369+ 0 0 \
370+ [expr 1.0 * [lindex [dict get $design die_area] 2] / $def_units ] \
371+ [expr 1.0 * [lindex [dict get $design die_area] 3] / $def_units ]]
358372 foreach layer_name [get_blockage_layers $design ] {
359373 if { [dict exists $design layers $layer_name drw] } {
360374 set drw " DESIGNRULEWIDTH [ dict get $design layers $layer_name drw] "
@@ -369,7 +383,10 @@ proc write { design } {
369383 out " LAYER $layer_name ;"
370384 foreach obs $obstructions {
371385 if { [dict exists $obs mask] } {
372- out " RECT MASK [ dict get $obs mask] [ lmap x [dict get $obs rect] { expr 1.0 * $x / $def_units }] ;"
386+ out [concat \
387+ " RECT MASK [ dict get $obs mask] " \
388+ " [ lmap x [dict get $obs rect] { expr { 1.0 * $x / $def_units } }]" \
389+ " ;" ]
373390 } else {
374391 out " RECT [ lmap x [dict get $obs rect] { expr 1.0 * $x / $def_units }] ;"
375392 }
@@ -449,11 +466,13 @@ variable def_units
449466variable defOut stdout
450467variable designs {}
451468
469+ # tclint-disable-next-line redefined-builtin
452470proc open { file_name } {
453471 variable defOut
454472 set defOut [::open $file_name w]
455473}
456474
475+ # tclint-disable-next-line redefined-builtin
457476proc close { } {
458477 variable defOut
459478 if { $defOut != " stdout" } {
@@ -499,39 +518,41 @@ proc out { args } {
499518# - shapes : list of rectangles (or polygons)
500519# - (rect|polygon)
501520# - physical_viarules: dict with the name of the viarule as the key
502- # - rule
503- # - cutsize
504- # - layers
505- # - cutspacing
506- # - enclosure
507- # - rowcol
521+ # - rule
522+ # - cutsize
523+ # - layers
524+ # - cutspacing
525+ # - enclosure
526+ # - rowcol
508527# - components: dict with the instance name of the component as the key
509528# - inst_name
510529# - cell_name
511530# - (fixed|placed)?
512531# - orientation
513532# - nets: dict with the name of the net as the key
514533# - use: SIGNAL | POWER | GROUND
515- # - connections: list of instance pin pairs
516- # - routes: list of dictionaries
517- # - layer
518- # - points: list of points, where a point can be an XY location or the name of a VIA
534+ # - connections: list of instance pin pairs
535+ # - routes: list of dictionaries
536+ # - layer
537+ # - points: list of points, where a point can be an XY location or the name of a VIA
519538# - special_nets: dict with the name of the net as the key
520- # - use: SIGNAL | POWER | GROUND
521- # - connections: list of instance pin pairs
522- # - routes: list of dictioaries
523- # - layer
524- # - width
525- # - shape
539+ # - use: SIGNAL | POWER | GROUND
540+ # - connections: list of instance pin pairs
541+ # - routes: list of dictioaries
542+ # - layer
543+ # - width
544+ # - shape
526545# - points: list of points, where a point can be an XY location or the name of a VIA
527- #
546+ #
528547
529548proc shift_point { point x y } {
530549 return [list [expr [lindex $point 0] + $x ] [expr [lindex $point 1] + $y ]]
531550}
532551
533552proc shift_rect { rect x y } {
534- return [list [expr [lindex $rect 0] + $x ] [expr [lindex $rect 1] + $y ] [expr [lindex $rect 2] + $x ] [expr [lindex $rect 3] + $y ]]
553+ return [concat \
554+ [list [expr [lindex $rect 0] + $x ] [expr [lindex $rect 1] + $y ]] \
555+ [list [expr [lindex $rect 2] + $x ] [expr [lindex $rect 3] + $y ]]]
535556}
536557
537558proc shift_origin { design x y } {
@@ -719,24 +740,35 @@ proc write { design } {
719740 }
720741
721742 out " "
722- out " DIEAREA ( [ lrange [dict get $design die_area] 0 1] ) ( [ lrange [dict get $design die_area] 2 3] ) ;"
743+ out [concat \
744+ " DIEAREA ( [ lrange [dict get $design die_area] 0 1] )" \
745+ " ( [ lrange [dict get $design die_area] 2 3] ) ;" ]
723746
724747 if { [dict exists $design tracks] } {
725748
726749 }
727750
728751 if { [dict exists $design rows] } {
729752 foreach idx [lsort -integer [dict keys $design rows]] {
730- out -nonewline " ROW ROW_$idx [ dict keys $design rows $idx site] [ dict keys $design rows $idx start] [ dict keys $design rows $idx height] [ dict keys $design rows $idx orientation] "
731- out " DO [ dict keys $design rows $idx num_sites] BY 1 STEP [ dict keys $design rows $idx site_width] 0 ;"
753+ out -nonewline [concat \
754+ " ROW ROW_$idx " \
755+ [dict get $design rows $idx site] \
756+ [dict get $design rows $idx start] \
757+ [dict get $design rows $idx height] \
758+ [dict get $design rows $idx orientation]]
759+ out [concat \
760+ " DO [ dict get $design rows $idx num_sites] BY 1 STEP " \
761+ " [ dict get $design rows $idx site_width] 0 ;" ]
732762 }
733763 }
734764
735765 if { [dict exists $design pins] } {
736766 out " "
737767 out " PINS [ dict size [dict get $design pins] ] ;"
738768 dict for {pin_name pin} [dict get $design pins] {
739- out -nonewline " - $pin_name + NET [ dict get $pin net_name] + DIRECTION [ dict get $pin direction] "
769+ out -nonewline [concat \
770+ " - $pin_name + NET [ dict get $pin net_name] " \
771+ " + DIRECTION [ dict get $pin direction] " ]
740772 if { [dict exists $pin use] } {
741773 out -nonewline " + USE [ dict get $pin use] "
742774 }
@@ -834,7 +866,9 @@ proc write { design } {
834866 set mask " "
835867 }
836868 if { [llength $point ] == 2 } {
837- out -nonewline " + $type [ dict get $route layer] [ get_line_width [dict get $route layer] [ list $first_point $point ] ] "
869+ out -nonewline [concat \
870+ " + $type [ dict get $route layer] " \
871+ " [ get_line_width [dict get $route layer] [ list $first_point $point ] ] " ]
838872 out -nonewline $shape
839873 out -nonewline $points
840874 out -nonewline $mask
@@ -865,14 +899,19 @@ proc write { design } {
865899 }
866900 if { [dict exists $net routes] } {
867901 set route [lindex [dict get $net routes] 0]
868- out -nonewline " + ROUTED [ dict get $route layer] [ expr round([dict get $route width] )] + SHAPE [ dict get $route shape] "
902+ out -nonewline [concat \
903+ " + ROUTED [ dict get $route layer] " \
904+ " [ expr round([dict get $route width] )] " \
905+ " + SHAPE [ dict get $route shape] " ]
869906 foreach point [dict get $route points] {
870907 out -nonewline " $point "
871908 }
872909 out " "
873910
874911 foreach route [lrange [dict get $net routes] 1 end] {
875- out " NEW [ dict get $route layer] [ expr round([dict get $route width] )] + SHAPE [ dict get $route shape] "
912+ out [concat \
913+ " NEW [ dict get $route layer] [ expr round([dict get $route width] )]" \
914+ " + SHAPE [ dict get $route shape] " ]
876915 foreach point [dict get $route points] {
877916 out -nonewline " $point "
878917 }
0 commit comments