From 2bac66792f380106eeb9ef13fb75fb0d1ecf6bda Mon Sep 17 00:00:00 2001 From: Thomas Kramer <code@tkramer.ch> Date: Fri, 31 Mar 2023 13:35:35 +0200 Subject: [PATCH] pull17, magic writer: remove hardcoded technology name * instead introduce the `magscale` parameter for `MagicWriter` * use `magscale` parameter in the tech-file to set the correct scale --- lclayout/writer/magic_writer.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lclayout/writer/magic_writer.py b/lclayout/writer/magic_writer.py index d82514f..9aa5f78 100644 --- a/lclayout/writer/magic_writer.py +++ b/lclayout/writer/magic_writer.py @@ -93,7 +93,8 @@ def store_layout_to_magic_file(tech_name: str, top_cell: db.Cell, output_file: str, ignore_non_rectilinear: bool = False, - scale_factor: int = 1): + scale_factor: int = 1, + magscale: Tuple[int, int] = (1, 10)): """ Write the cell layout to a file in the Magic (.mag) format. @@ -106,6 +107,8 @@ def store_layout_to_magic_file(tech_name: str, :return: """ + assert len(magscale) == 2, "magscale must be a 2-tuple" + layer_config = [] for source_layer_name, destinations in output_map.items(): assert isinstance(destinations, str) or isinstance(destinations, List), \ @@ -126,7 +129,7 @@ def store_layout_to_magic_file(tech_name: str, mag_lines = ["magic", "# Generated by librecell", "tech {}".format(tech_name), - "magscale 1 10" if tech_name=='gf180mcuC' else "magscale 1 1", + f"magscale {magscale[0]} {magscale[1]}", "timestamp {}".format(int(time.time())) ] @@ -197,7 +200,12 @@ def store_layout_to_magic_file(tech_name: str, class MagWriter(Writer): - def __init__(self, tech_name: str, output_map: Dict[str, str], scale_factor: float = 1): + def __init__(self, + tech_name: str, + output_map: Dict[str, str], + scale_factor: float = 1, + magscale: Tuple[int, int] = (1, 10) + ): """ :param tech_name: @@ -207,6 +215,7 @@ class MagWriter(Writer): self.tech_name = tech_name self.output_map = output_map self.scale_factor = scale_factor + self.magscale = magscale def write_layout(self, layout: db.Layout, @@ -225,4 +234,6 @@ class MagWriter(Writer): top_cell, mag_out_path, ignore_non_rectilinear=False, - scale_factor=self.scale_factor) + scale_factor=self.scale_factor, + magscale=self.magscale + ) -- GitLab