diff --git a/src/hammer-vlsi/pcb/generic/__init__.py b/src/hammer-vlsi/pcb/generic/__init__.py index 40995b3dd..9c678d2cb 100644 --- a/src/hammer-vlsi/pcb/generic/__init__.py +++ b/src/hammer-vlsi/pcb/generic/__init__.py @@ -34,6 +34,7 @@ def steps(self) -> List[HammerToolStep]: self.create_footprint_csv, self.create_footprint, self.create_bom_builder_pindata_txt, + self.create_mechanical_drawing, self.create_schematic_symbols ] return self.make_steps_from_methods(steps) @@ -47,6 +48,11 @@ def output_footprint_filename(self) -> str: def output_footprint_csv_filename(self) -> str: return os.path.join(self.run_dir, "{top}-pads.csv".format(top=self.top_module)) + @property + def output_mechanical_drawing_filename(self) -> str: + # change this when supporting other types + return os.path.join(self.run_dir, "{top}-pads.svg".format(top=self.top_module)) + @property def output_schematic_symbol_filename(self) -> str: # change this when supporting other types @@ -273,6 +279,92 @@ def create_footprint(self) -> bool: return True + def create_mechanical_drawing(self) -> bool: + """ + Create an SVG-based mechanical drawing of the bump-out. + + :return: True if successful + """ + + bumps, assignments = self.get_bumps_and_assignments() + + # Use post-shrink pitch + + # TODO fixme this is just copied/pasted from eagle + die_w_um = self.technology.get_post_shrink_length(Decimal(7500)) + die_h_um = die_w_um + + # Some input values and a conversion factor + canvas_w_px = Decimal(10000) + margin_px = Decimal(10) + die_w_px = canvas_w_px - (2*margin_px) + px_per_um = die_w_px / die_w_um + + # Calculate the rest of the canvas size + die_h_px = die_h_um * px_per_um + canvas_h_px = die_h_px + (2*margin_px) + + # Some other things we need to calculate + pitch_um = self.technology.get_post_shrink_length(bumps.pitch) + pitch_px = pitch_um * px_per_um + opening_um = self.bump_pad_opening_diameter + opening_px = opening_um * px_per_um + + offset_px = margin_px + opening_px / Decimal(2) + + # Header + output = """ + +""".format(width=canvas_w_px,height=canvas_h_px) + + # Styles + output += """ + +""" + + # Die + output += "\n".format(x=margin_px, y=margin_px, w=die_w_px, h=die_h_px) + + # A1 marker + x0 = die_w_px - pitch_px + x1 = die_w_px + y0 = 2*margin_px + y1 = y0 + pitch_px + output += "\n".format(x0=x0, x1=x1, y0=y0, y1=y1) + + for bump in assignments: + x = offset_px + bump.x * pitch_px + y = canvas_h_px - (offset_px + bump.y * pitch_px) + r = opening_px * Decimal("0.5") # radius + l = opening_px * Decimal("0.9") # 90% of the diameter + name = bump.name + classes = "" # none for now + output += "\n".format(x=x, y=y, r=r, classes=classes) + output += "{name}\n".format(x=x, y=y, l=l, name=name) + + output += "\n" + + with open(self.output_mechanical_drawing_filename, "w") as f: + f.write(output) + + return True + + def create_schematic_symbols(self) -> bool: """ Create the schematic symbol type requested by pcb.generic.schematic_symbol_type. Currently only supports