Coverage for tests/rcx25/extraction_results_test.py: 100%

70 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-03-31 19:36 +0000

1# 

2# -------------------------------------------------------------------------------- 

3# SPDX-FileCopyrightText: 2024 Martin Jan Köhler and Harald Pretl 

4# Johannes Kepler University, Institute for Integrated Circuits. 

5# 

6# This file is part of KPEX 

7# (see https://github.com/martinjankoehler/klayout-pex). 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <http://www.gnu.org/licenses/>. 

21# SPDX-License-Identifier: GPL-3.0-or-later 

22# -------------------------------------------------------------------------------- 

23# 

24import allure 

25import pytest 

26import unittest 

27 

28from klayout_pex.rcx25.extraction_results import * 

29import klayout_pex_protobuf.process_parasitics_pb2 as process_parasitics_pb2 

30 

31 

32@allure.parent_suite("Unit Tests") 

33class NetCoupleKeyTest(unittest.TestCase): 

34 def test_normed_ascending(self): 

35 k = NetCoupleKey('net_bottom', 'net_top') 

36 obtained_k = k.normed() 

37 expected_k = NetCoupleKey('net_bottom', 'net_top') 

38 self.assertEqual(expected_k, obtained_k) 

39 

40 def test_normed_descending(self): 

41 k = NetCoupleKey('net_top', 'net_bottom') 

42 obtained_k = k.normed() 

43 expected_k = NetCoupleKey('net_bottom', 'net_top') 

44 self.assertEqual(expected_k, obtained_k) 

45 

46 

47@allure.parent_suite("Unit Tests") 

48class CellExtractionResultsTest(unittest.TestCase): 

49 def test_summarize_overlap(self): 

50 results = CellExtractionResults(cell_name='Cell') 

51 

52 ovk1a = OverlapKey(layer_top='m2', 

53 net_top='net_top', 

54 layer_bot='m1', 

55 net_bot='net_bot') 

56 

57 ovk1b = OverlapKey(layer_top='m2', 

58 net_top='net_top', 

59 layer_bot='m1', 

60 net_bot='net_bot') 

61 

62 ovk2 = OverlapKey(layer_top='m3', 

63 net_top='net_top', 

64 layer_bot='m1', 

65 net_bot='net_bot') 

66 

67 ovc1a = OverlapCap(key=ovk1a, 

68 cap_value=10.0, 

69 shielded_area=20.0, 

70 unshielded_area=30.0, 

71 tech_spec=None) 

72 

73 ovc1b = OverlapCap(key=ovk1b, 

74 cap_value=11.0, 

75 shielded_area=21.0, 

76 unshielded_area=31.0, 

77 tech_spec=None) 

78 

79 ovc2 = OverlapCap(key=ovk2, 

80 cap_value=12.0, 

81 shielded_area=22.0, 

82 unshielded_area=32.0, 

83 tech_spec=None) 

84 

85 results.add_overlap_cap(ovc1a) 

86 results.add_overlap_cap(ovc2) 

87 results.add_overlap_cap(ovc1b) 

88 

89 summary = results.summarize() 

90 obtained_cap_value = summary.capacitances[NetCoupleKey('net_top', 'net_bot').normed()] 

91 expected_cap_value = ovc1a.cap_value + ovc1b.cap_value + ovc2.cap_value 

92 self.assertEqual(expected_cap_value, obtained_cap_value) 

93 

94 def test_summarize_sidewall(self): 

95 results = CellExtractionResults(cell_name='Cell') 

96 

97 k1a = SidewallKey(layer='m2', 

98 net1='net1', 

99 net2='net2') 

100 

101 k1b = SidewallKey(layer='m2', 

102 net1='net2', 

103 net2='net1') 

104 

105 k2 = SidewallKey(layer='m3', 

106 net1='net1', 

107 net2='net3') 

108 

109 c1a = SidewallCap(key=k1a, 

110 cap_value=10.0, 

111 distance=20.0, 

112 length=30.0, 

113 tech_spec=None) 

114 

115 c1b = SidewallCap(key=k1b, 

116 cap_value=11.0, 

117 distance=21.0, 

118 length=31.0, 

119 tech_spec=None) 

120 

121 c2 = SidewallCap(key=k2, 

122 cap_value=12.0, 

123 distance=22.0, 

124 length=32.0, 

125 tech_spec=None) 

126 

127 results.add_sidewall_cap(c1a) 

128 results.add_sidewall_cap(c1b) 

129 results.add_sidewall_cap(c2) 

130 

131 summary = results.summarize() 

132 

133 obtained_cap_value = summary.capacitances[NetCoupleKey('net1', 'net2').normed()] 

134 expected_cap_value = c1a.cap_value + c1b.cap_value 

135 self.assertEqual(expected_cap_value, obtained_cap_value) 

136 

137 obtained_cap_value = summary.capacitances[NetCoupleKey('net1', 'net3').normed()] 

138 expected_cap_value = c2.cap_value 

139 self.assertEqual(expected_cap_value, obtained_cap_value) 

140 

141 def test_summarize_sideoverlap(self): 

142 results = CellExtractionResults(cell_name='Cell') 

143 

144 k1a = SideOverlapKey(layer_inside='m2', 

145 net_inside='net2', 

146 layer_outside='m1', 

147 net_outside='net1') 

148 

149 k1b = SideOverlapKey(layer_inside='m1', 

150 net_inside='net1', 

151 layer_outside='m2', 

152 net_outside='net2') 

153 

154 k2 = SideOverlapKey(layer_inside='m3', 

155 net_inside='net3', 

156 layer_outside='m1', 

157 net_outside='net1') 

158 

159 c1a = SideOverlapCap(key=k1a, 

160 cap_value=10.0) 

161 

162 c1b = SideOverlapCap(key=k1b, 

163 cap_value=10.0) 

164 

165 c2 = SideOverlapCap(key=k2, 

166 cap_value=10.0) 

167 

168 results.add_sideoverlap_cap(c1a) 

169 results.add_sideoverlap_cap(c1b) 

170 results.add_sideoverlap_cap(c2) 

171 

172 summary = results.summarize() 

173 

174 obtained_cap_value = summary.capacitances[NetCoupleKey('net1', 'net2').normed()] 

175 expected_cap_value = c1a.cap_value + c1b.cap_value 

176 self.assertEqual(expected_cap_value, obtained_cap_value) 

177 

178 obtained_cap_value = summary.capacitances[NetCoupleKey('net1', 'net3').normed()] 

179 expected_cap_value = c2.cap_value 

180 self.assertEqual(expected_cap_value, obtained_cap_value)