Skip to content

Commit

Permalink
Raise exception when specfic messages are printed by Magic
Browse files Browse the repository at this point in the history
  • Loading branch information
kareefardi committed Oct 26, 2023
1 parent fbfe20e commit 4521072
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions openlane/steps/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import re
import shutil
from abc import abstractmethod
from typing import Literal, List, Optional, Tuple
Expand Down Expand Up @@ -113,7 +114,34 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
for gds in self.toolbox.get_macro_views(self.config, DesignFormat.GDS):
env["MACRO_GDS_FILES"] += f" {gds}"

return super().run(state_in, env=env, **kwargs)
views_updates, metrics_updates = super().run(
state_in,
env=env,
**kwargs,
)

error_patterns = [
r"DEF read.*\(Error\).*",
r"LEF read.*\(Error\).*",
r"Error while reading cell.*",
]

for line in open(self.get_log_path(), encoding="utf8"):
if "Calma output error" in line:
raise StepError(
f"Magic GDS was written with errors. Check log file of {self.id}"
)
elif "is an abstract view" in line:
raise StepError(
f"Missing GDS view for a macro. Check log file of {self.id}."
)
for pattern in error_patterns:
if re.match(pattern, line):
raise StepError(
f"Error encountered during running Magic.\nError: {line}Check the log file of {self.id}."
)

return views_updates, metrics_updates


@Step.factory.register()
Expand Down Expand Up @@ -208,7 +236,6 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
env["DIE_AREA"] = die_area

env["MAGTYPE"] = "mag"
magic_log_dir = os.path.join(self.step_dir, "magic.log")

if self.config["MACROS"] is not None:
macro_gds = []
Expand All @@ -223,7 +250,6 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
views_updates, metrics_updates = super().run(
state_in,
env=env,
log_to=magic_log_dir,
**kwargs,
)

Expand All @@ -237,12 +263,6 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
os.path.join(self.step_dir, f"{self.config['DESIGN_NAME']}.mag")
)

for line in open(magic_log_dir, encoding="utf8"):
if "Calma output error" in line:
raise StepError("Magic GDS was written with errors.")
elif "is an abstract view" in line:
raise StepError("Missing GDS view for a macro. Check step log file.")

return views_updates, metrics_updates


Expand Down

0 comments on commit 4521072

Please sign in to comment.