Skip to content

Commit

Permalink
undo handling errors of magic. in a separate branch now
Browse files Browse the repository at this point in the history
  • Loading branch information
kareefardi committed Oct 26, 2023
1 parent 9af1774 commit 7bb36e2
Showing 1 changed file with 9 additions and 29 deletions.
38 changes: 9 additions & 29 deletions openlane/steps/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# 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 @@ -114,34 +113,7 @@ 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}"

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.*",
]

error_found = False
for line in open(self.get_log_path(), encoding="utf8"):
if "Calma output error" in line:
error_found = True
elif "is an abstract view" in line:
error_found = True
for pattern in error_patterns:
if re.match(pattern, line):
error_found = True
break
if error_found is True:
raise StepError(
f"Error encountered during running Magic.\nError: {line}Check the log file of {self.id}."
)

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


@Step.factory.register()
Expand Down Expand Up @@ -236,6 +208,7 @@ 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 @@ -250,6 +223,7 @@ 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 @@ -263,6 +237,12 @@ 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 7bb36e2

Please sign in to comment.