Skip to content

Commit 4ce03bc

Browse files
authored
Merge pull request #292 from The-OpenROAD-Project/fix_ioplacer_tapcell
ioPlacer/tapcell fixes
2 parents 24f08c6 + f3ad895 commit 4ce03bc

File tree

5 files changed

+172
-60
lines changed

5 files changed

+172
-60
lines changed

src/ioPlacer

src/tapcell/src/tapcell.tcl

Lines changed: 58 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ proc tapcell { args } {
490490
}
491491

492492
set end_master [$db findMaster $endcap_master]
493+
if { $end_master == "NULL" } {
494+
ord::error "\[ERROR\] Master $endcap_master not found"
495+
}
493496
set end_width [$end_master getWidth]
494497
set min_row_width [expr 2*$end_width]
495498

@@ -565,8 +568,8 @@ proc tapcell { args } {
565568
set site_x [[$row getSite] getWidth]
566569
set endcapwidth [expr $endcap_cpp*$site_x]
567570

568-
if { ![string match [$master getConstName] $endcap_master] } {
569-
puts "\[ERROR\] Master $endcap_master not found"
571+
if { $master == "NULL" } {
572+
ord::error "\[ERROR\] Master $endcap_master not found"
570573
}
571574

572575
set row_name [$row getName]
@@ -577,35 +580,31 @@ proc tapcell { args } {
577580

578581
if {$no_cell_at_top_bottom == true} {
579582
if {$top_bottom == 1} {
580-
if {[string match "MX" $ori]} {
583+
if { $ori == "MX" } {
581584
set master [$db findMaster $cnrcap_nwin_master]
582585

583-
if { ![string match [$master getConstName] $cnrcap_nwin_master] } {
584-
puts "\[ERROR\] Master $cnrcap_nwin_master not found"
585-
exit 1
586+
if { $master == "NULL" } {
587+
ord::error "\[ERROR\] Master $cnrcap_nwin_master not found"
586588
}
587589
} else {
588590
set master [$db findMaster $cnrcap_nwout_master]
589591

590-
if { ![string match [$master getConstName] $cnrcap_nwout_master] } {
591-
puts "\[ERROR\] Master $cnrcap_nwout_master not found"
592-
exit 1
592+
if { $master == "NULL" } {
593+
ord::error "\[ERROR\] Master $cnrcap_nwout_master not found"
593594
}
594595
}
595596
} elseif {$top_bottom == -1} {
596-
if {[string match "R0" $ori]} {
597+
if { $ori == "R0" } {
597598
set master [$db findMaster $cnrcap_nwin_master]
598599

599-
if { ![string match [$master getConstName] $cnrcap_nwin_master] } {
600-
puts "\[ERROR\] Master $cnrcap_nwin_master not found"
601-
exit 1
600+
if { $master == "NULL" } {
601+
ord::error "\[ERROR\] Master $cnrcap_nwin_master not found"
602602
}
603603
} else {
604604
set master [$db findMaster $cnrcap_nwout_master]
605605

606-
if { ![string match [$master getConstName] $cnrcap_nwout_master] } {
607-
puts "\[ERROR\] Master $cnrcap_nwout_master not found"
608-
exit 1
606+
if { $master == "NULL" } {
607+
ord::error "\[ERROR\] Master $cnrcap_nwout_master not found"
609608
}
610609
}
611610
} else {
@@ -635,13 +634,13 @@ proc tapcell { args } {
635634
set blocked_region [tapcell::in_blocked_region $llx $row $blockages $halo_x $halo_y [$master getWidth] $endcapwidth]
636635
if {$add_boundary_cell == true && $blocked_region == true} {
637636
if {[tapcell::right_above_below_macros $blockages $row $halo_x $halo_y] == 1} {
638-
if {[string match "MX" $ori]} {
637+
if { $ori == "MX" } {
639638
set master [$db findMaster $cnrcap_nwin_master]
640639
} else {
641640
set master [$db findMaster $cnrcap_nwout_master]
642641
}
643642
} else {
644-
if {[string match "R0" $ori]} {
643+
if { $ori == "R0" } {
645644
set master [$db findMaster $cnrcap_nwin_master]
646645
} else {
647646
set master [$db findMaster $cnrcap_nwout_master]
@@ -662,13 +661,13 @@ proc tapcell { args } {
662661
set blocked_region [tapcell::in_blocked_region $loc_2_x $row $blockages $halo_x $halo_y [$master getWidth] $endcapwidth]
663662
if {$add_boundary_cell == true && $blocked_region == true} {
664663
if {[tapcell::right_above_below_macros $blockages $row $halo_x $halo_y] == 1} {
665-
if {[string match "MX" $ori]} {
664+
if { $ori == "MX" } {
666665
set master [$db findMaster $cnrcap_nwin_master]
667666
} else {
668667
set master [$db findMaster $cnrcap_nwout_master]
669668
}
670669
} else {
671-
if {[string match "R0" $ori]} {
670+
if { $ori == "R0" } {
672671
set master [$db findMaster $cnrcap_nwin_master]
673672
} else {
674673
set master [$db findMaster $cnrcap_nwout_master]
@@ -684,10 +683,10 @@ proc tapcell { args } {
684683
set inst2_name "PHY_${cnt}"
685684
set inst2 [odb::dbInst_create $block $master $inst2_name]
686685
set right_ori $ori
687-
if {[string match "MX" $ori]} {
686+
if { $ori == "MX" } {
688687
set right_ori "R180"
689688
} else {
690-
if {[string match "R0" $ori]} {
689+
if { $ori == "R0"} {
691690
set right_ori "MY"
692691
}
693692
}
@@ -746,47 +745,49 @@ proc tapcell { args } {
746745
set endcapwidth [expr $endcap_cpp*$site_x]
747746
for {set x [expr $llx+$offset]} {$x < [expr $urx-$endcap_cpp*$site_x]} {set x [expr $x+$pitch]} {
748747
set master [$db findMaster $tapcell_master]
748+
if { $master == "NULL" } {
749+
ord::error "\[ERROR\] Master $tapcell_master not found"
750+
}
751+
749752
set inst_name "PHY_${cnt}"
750753
set tap_width [$master getWidth]
751754
set tap_urx [expr $x + $tap_width]
752755
set end_llx [expr $urx - $endcap_width]
753756

754-
if { [string match [$master getConstName] $tapcell_master] } {
755-
if {$add_boundary_cell == true} {
756-
set blocked_region false
757-
set blocked_region [tapcell::in_blocked_region $x $row $blockages $halo_x $halo_y [$master getWidth] $endcapwidth]
758-
if {$blocked_region == true} {
759-
continue
760-
}
757+
if {$add_boundary_cell == true} {
758+
set blocked_region false
759+
set blocked_region [tapcell::in_blocked_region $x $row $blockages $halo_x $halo_y [$master getWidth] $endcapwidth]
760+
if {$blocked_region == true} {
761+
continue
761762
}
763+
}
762764

763-
set x_tmp [expr {ceil (1.0*$x/$site_x)*$site_x}]
764-
set row_orig_fix [expr { $llx % $site_x }]
765-
set x [expr { int($x_tmp + $row_orig_fix) }]
766-
set x_end [expr $x + $site_x]
765+
set x_tmp [expr {ceil (1.0*$x/$site_x)*$site_x}]
766+
set row_orig_fix [expr { $llx % $site_x }]
767+
set x [expr { int($x_tmp + $row_orig_fix) }]
768+
set x_end [expr $x + $site_x]
767769

768-
if {($x != $min_x) && ($x_end != $max_x)} {
769-
if { $tap_urx > $end_llx } {
770-
puts "\[WARNING\] Tapcell at position ($x, $lly) will cause overlap with endcap. Skipping..."
771-
continue
772-
}
770+
if {($x != $min_x) && ($x_end != $max_x)} {
771+
if { $tap_urx > $end_llx } {
772+
puts "\[WARNING\] Tapcell at position ($x, $lly) will cause overlap with endcap. Skipping..."
773+
continue
774+
}
773775

774-
set min_dist [expr 2 * $site_x]
775-
set max_tap_urx [expr $end_llx - $min_dist]
776+
set min_dist [expr 2 * $site_x]
777+
set max_tap_urx [expr $end_llx - $min_dist]
776778

777-
while { $tap_urx > $max_tap_urx } {
778-
set tap_urx [expr $tap_urx - $site_x]
779-
set x [expr $x - $site_x]
780-
}
781-
set inst [odb::dbInst_create $block $master $inst_name]
782-
$inst setOrient $ori
779+
while { $tap_urx > $max_tap_urx } {
780+
set tap_urx [expr $tap_urx - $site_x]
781+
set x [expr $x - $site_x]
782+
}
783+
set inst [odb::dbInst_create $block $master $inst_name]
784+
$inst setOrient $ori
783785

784-
$inst setLocation $x $lly
785-
$inst setPlacementStatus LOCKED
786+
$inst setLocation $x $lly
787+
$inst setPlacementStatus LOCKED
786788

787-
incr cnt
788-
incr tapcell_count
789-
}
789+
incr cnt
790+
incr tapcell_count
790791
}
791792
}
792793
}
@@ -821,7 +822,7 @@ proc tapcell { args } {
821822

822823
if {$topbottom_chk == 1} {
823824
# top
824-
if {[string match "MX" $ori]} {
825+
if { $ori == "MX" } {
825826
set master [$db findMaster $tap_nwintie_master]
826827
set tb2_master [$db findMaster $tap_nwin2_master]
827828
set tb3_master [$db findMaster $tap_nwin3_master]
@@ -832,7 +833,7 @@ proc tapcell { args } {
832833
}
833834
} elseif {$topbottom_chk == -1} {
834835
# bottom
835-
if {[string match "R0" $ori]} {
836+
if { $ori == "R0" } {
836837
set master [$db findMaster $tap_nwintie_master]
837838
set tb2_master [$db findMaster $tap_nwin2_master]
838839
set tb3_master [$db findMaster $tap_nwin3_master]
@@ -939,7 +940,7 @@ proc tapcell { args } {
939940

940941
if {($row_lly >= $blockage_ury)} {
941942
# If row is at top of macro
942-
if {[string match "R0" $ori]} {
943+
if { $ori == "R0" } {
943944
set incnr_master [$db findMaster $incnrcap_nwin_master]
944945
set tb2_master [$db findMaster $tap_nwin2_master]
945946
set tb3_master [$db findMaster $tap_nwin3_master]
@@ -970,7 +971,7 @@ proc tapcell { args } {
970971
} else {
971972
# Insert cell at northwest corner
972973
set inst1 [odb::dbInst_create $block $incnr_master $inst1_name]
973-
if {[string match "R0" $ori]} {
974+
if { $ori == "R0" } {
974975
set cell_orient "MY"
975976
} else {
976977
set cell_orient "R180"
@@ -1047,7 +1048,7 @@ proc tapcell { args } {
10471048
}
10481049
} elseif {($row_ury <= $blockage_lly)} {
10491050
# If row is at bottom of macro
1050-
if {[string match "MX" $ori]} {
1051+
if { $ori == "MX" } {
10511052
set incnr_master [$db findMaster $incnrcap_nwin_master]
10521053
set tb2_master [$db findMaster $tap_nwin2_master]
10531054
set tb3_master [$db findMaster $tap_nwin3_master]
@@ -1078,7 +1079,7 @@ proc tapcell { args } {
10781079
} else {
10791080
# Insert cell at southwest corner
10801081
set inst1 [odb::dbInst_create $block $incnr_master $inst1_name]
1081-
if {[string match "R0" $ori]} {
1082+
if { $ori == "R0"} {
10821083
set cell_orient "MY"
10831084
} else {
10841085
set cell_orient "R180"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
3+
################################################################################
4+
## Authors: Mateus Fogaca, Eder Matheus Monteiro
5+
## (Advisor: Ricardo Reis)
6+
##
7+
## BSD 3-Clause License
8+
##
9+
## Copyright (c) 2019, Federal University of Rio Grande do Sul (UFRGS)
10+
## All rights reserved.
11+
##
12+
## Redistribution and use in source and binary forms, with or without
13+
## modification, are permitted provided that the following conditions are met:
14+
##
15+
## * Redistributions of source code must retain the above copyright notice, this
16+
## list of conditions and the following disclaimer.
17+
##
18+
## * Redistributions in binary form must reproduce the above copyright notice,
19+
## this list of conditions and the following disclaimer in the documentation
20+
## and#or other materials provided with the distribution.
21+
##
22+
## * Neither the name of the copyright holder nor the names of its
23+
## contributors may be used to endorse or promote products derived from
24+
## this software without specific prior written permission.
25+
##
26+
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27+
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28+
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29+
## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
30+
## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31+
## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32+
## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33+
## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34+
## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35+
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36+
## POSSIBILITY OF SUCH DAMAGE.
37+
################################################################################
38+
39+
GREEN=0
40+
RED=2
41+
42+
if [ "$#" -ne 2 ]; then
43+
exit 2
44+
fi
45+
46+
binary=$1
47+
testdir=$2
48+
49+
ln -s ../test_rows_origin/input.* .
50+
51+
$binary -no_init < run.tcl > test.log 2>&1
52+
53+
rm ./input.lef
54+
rm ./input.def
55+
56+
grep -q "Master FILLCELL_X1x not found" ./test.log
57+
status=$?
58+
59+
mkdir -p ../../results/test_invalid_cells/
60+
cp test.log ../../results/test_invalid_cells/tapcell.log
61+
62+
if [ $status -eq 0 ]; then
63+
exit $GREEN
64+
else
65+
echo " - [ERROR] Test failed. Check $testdir/src/check_invalid_cells/test.log"
66+
exit $RED
67+
fi
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
################################################################################
2+
## Authors: Vitor Bandeira, Eder Matheus Monteiro e Isadora Oliveira
3+
## (Advisor: Ricardo Reis)
4+
##
5+
## BSD 3-Clause License
6+
##
7+
## Copyright (c) 2019, Federal University of Rio Grande do Sul (UFRGS)
8+
## All rights reserved.
9+
##
10+
## Redistribution and use in source and binary forms, with or without
11+
## modification, are permitted provided that the following conditions are met:
12+
##
13+
## * Redistributions of source code must retain the above copyright notice, this
14+
## list of conditions and the following disclaimer.
15+
##
16+
## * Redistributions in binary form must reproduce the above copyright notice,
17+
## this list of conditions and the following disclaimer in the documentation
18+
## and#or other materials provided with the distribution.
19+
##
20+
## * Neither the name of the copyright holder nor the names of its
21+
## contributors may be used to endorse or promote products derived from
22+
## this software without specific prior written permission.
23+
##
24+
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25+
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26+
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27+
## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28+
## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29+
## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30+
## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31+
## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32+
## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33+
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34+
## POSSIBILITY OF SUCH DAMAGE.
35+
################################################################################
36+
37+
read_lef "input.lef"
38+
read_def "input.def"
39+
40+
tapcell -endcap_cpp "1" -distance "25" -tapcell_master "FILLCELL_X1x" -endcap_master "FILLCELL_X1x"
41+
42+
write_def "tap.def"
43+
44+
exit

src/tapcell/test/src/test_rows_origin/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ $binary -no_init < run.tcl > test.log 2>&1
5050

5151
report=$(grep -e '---- #Tapcells inserted:' ./test.log)
5252

53-
mkdir -p ../../results/test_cells_inserted/
54-
cp test.log ../../results/test_cells_inserted/tapcell.log
53+
mkdir -p ../../results/test_rows_origin/
54+
cp test.log ../../results/test_rows_origin/tapcell.log
5555

5656
if grep -q -e "$report" golden.cells;
5757
then

0 commit comments

Comments
 (0)