mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
feat(shuttle): add logo & shuttle ID as chip art
This commit is contained in:
@@ -15,6 +15,7 @@ import yaml
|
||||
|
||||
from config import Config
|
||||
from documentation import Docs
|
||||
from logo import LogoGenerator
|
||||
from project import Project
|
||||
from rom import ROMFile
|
||||
from shuttle import ShuttleConfig
|
||||
@@ -305,6 +306,7 @@ if __name__ == "__main__":
|
||||
docs = Docs(config, projects.projects)
|
||||
shuttle = ShuttleConfig(config, projects.projects, modules_yaml_name)
|
||||
rom = ROMFile(config)
|
||||
logo = LogoGenerator("tt", config)
|
||||
|
||||
if args.list:
|
||||
shuttle.list()
|
||||
@@ -315,6 +317,7 @@ if __name__ == "__main__":
|
||||
if args.update_shuttle:
|
||||
shuttle.configure_mux()
|
||||
rom.write_rom()
|
||||
logo.gen_logo("bottom", "tt/logo/tt_logo_bottom.gds")
|
||||
if not args.test:
|
||||
docs.build_index()
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
import gdstk
|
||||
from git.repo import Repo
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
from config import Config
|
||||
|
||||
|
||||
class LogoGenerator:
|
||||
def __init__(self, tt_dir, config: Config | None = None):
|
||||
self.tt_dir = tt_dir
|
||||
self.config = config
|
||||
|
||||
def gen_logo(self, variant: str, gds_file: str, shuttle=None, commit=None):
|
||||
|
||||
assert variant in ("top", "bottom")
|
||||
if variant == "top":
|
||||
# use included bitmap
|
||||
img = Image.open(f"{self.tt_dir}/logo/tt_logo.png").convert("L")
|
||||
|
||||
elif variant == "bottom":
|
||||
# generate bitmap from shuttle ID & commit hash
|
||||
if shuttle is None:
|
||||
assert self.config is not None
|
||||
shuttle = self.config["id"]
|
||||
if commit is None:
|
||||
commit = Repo(".").commit().hexsha
|
||||
|
||||
img = Image.new("L", (200, 200), (0,))
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
font_file = f"{self.tt_dir}/logo/font/UbuntuSansMono.ttf"
|
||||
|
||||
def font(size):
|
||||
f = ImageFont.truetype(font_file, size)
|
||||
f.set_variation_by_axes([700])
|
||||
return f
|
||||
|
||||
draw.text((2, -15), shuttle, fill=255, font=font(88))
|
||||
draw.text((2, 68), commit[:8], fill=255, font=font(44))
|
||||
draw.text((2, 107), commit[8:18], fill=255, font=font(35))
|
||||
draw.text((1, 137), commit[18:29], fill=255, font=font(32))
|
||||
draw.text((1, 165), commit[29:], fill=255, font=font(32))
|
||||
|
||||
PRBOUNDARY_LAYER = 235
|
||||
PRBOUNDARY_DATATYPE = 4
|
||||
MET4_LAYER = 71
|
||||
DRAWING_DATATYPE = 20
|
||||
PIXEL_SIZE = 0.5 # um
|
||||
|
||||
lib = gdstk.Library()
|
||||
cell = lib.new_cell(f"tt_logo_{variant}")
|
||||
boundary = gdstk.rectangle(
|
||||
(0, 0),
|
||||
(img.width * PIXEL_SIZE, img.height * PIXEL_SIZE),
|
||||
layer=PRBOUNDARY_LAYER,
|
||||
datatype=PRBOUNDARY_DATATYPE,
|
||||
)
|
||||
cell.add(boundary)
|
||||
|
||||
for y in range(img.height):
|
||||
for x in range(img.width):
|
||||
color: int = img.getpixel((x, y)) # type: ignore
|
||||
if color >= 128:
|
||||
flipped_y = img.height - y - 1 # flip vertically
|
||||
rect = gdstk.rectangle(
|
||||
(x * PIXEL_SIZE, flipped_y * PIXEL_SIZE),
|
||||
((x + 1) * PIXEL_SIZE, (flipped_y + 1) * PIXEL_SIZE),
|
||||
layer=MET4_LAYER,
|
||||
datatype=DRAWING_DATATYPE,
|
||||
)
|
||||
cell.add(rect)
|
||||
|
||||
lib.write_gds(gds_file)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
try:
|
||||
if sys.argv[1] == "--top":
|
||||
LogoGenerator(".").gen_logo("top", "logo/tt_logo_top.gds")
|
||||
|
||||
elif sys.argv[1] == "--bottom":
|
||||
shuttle = sys.argv[2] # e.g. "tt10"
|
||||
commit = sys.argv[3] # e.g. "0123456789abcdef0123456789abcdef01234567"
|
||||
LogoGenerator(".").gen_logo(
|
||||
"bottom", "logo/tt_logo_bottom.gds", shuttle, commit
|
||||
)
|
||||
|
||||
except IndexError:
|
||||
print(
|
||||
f"Usage:\n {sys.argv[0]} --top\n {sys.argv[0]} --bottom <shuttle> <commit>",
|
||||
file=sys.stderr,
|
||||
)
|
||||
@@ -0,0 +1,96 @@
|
||||
-------------------------------
|
||||
UBUNTU FONT LICENCE Version 1.0
|
||||
-------------------------------
|
||||
|
||||
PREAMBLE
|
||||
This licence allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely. The fonts, including any derivative works, can be
|
||||
bundled, embedded, and redistributed provided the terms of this licence
|
||||
are met. The fonts and derivatives, however, cannot be released under
|
||||
any other licence. The requirement for fonts to remain under this
|
||||
licence does not require any document created using the fonts or their
|
||||
derivatives to be published under this licence, as long as the primary
|
||||
purpose of the document is not to be a vehicle for the distribution of
|
||||
the fonts.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this licence and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Original Version" refers to the collection of Font Software components
|
||||
as received under this licence.
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to
|
||||
a new environment.
|
||||
|
||||
"Copyright Holder(s)" refers to all individuals and companies who have a
|
||||
copyright ownership of the Font Software.
|
||||
|
||||
"Substantially Changed" refers to Modified Versions which can be easily
|
||||
identified as dissimilar to the Font Software by users of the Font
|
||||
Software comparing the Original Version with the Modified Version.
|
||||
|
||||
To "Propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification and with or without charging
|
||||
a redistribution fee), making available to the public, and in some
|
||||
countries other activities as well.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
This licence does not grant any rights under trademark law and all such
|
||||
rights are reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of the Font Software, to propagate the Font Software, subject to
|
||||
the below conditions:
|
||||
|
||||
1) Each copy of the Font Software must contain the above copyright
|
||||
notice and this licence. These can be included either as stand-alone
|
||||
text files, human-readable headers or in the appropriate machine-
|
||||
readable metadata fields within text or binary files as long as those
|
||||
fields can be easily viewed by the user.
|
||||
|
||||
2) The font name complies with the following:
|
||||
(a) The Original Version must retain its name, unmodified.
|
||||
(b) Modified Versions which are Substantially Changed must be renamed to
|
||||
avoid use of the name of the Original Version or similar names entirely.
|
||||
(c) Modified Versions which are not Substantially Changed must be
|
||||
renamed to both (i) retain the name of the Original Version and (ii) add
|
||||
additional naming elements to distinguish the Modified Version from the
|
||||
Original Version. The name of such Modified Versions must be the name of
|
||||
the Original Version, with "derivative X" where X represents the name of
|
||||
the new work, appended to that name.
|
||||
|
||||
3) The name(s) of the Copyright Holder(s) and any contributor to the
|
||||
Font Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except (i) as required by this licence, (ii) to
|
||||
acknowledge the contribution(s) of the Copyright Holder(s) or (iii) with
|
||||
their explicit written permission.
|
||||
|
||||
4) The Font Software, modified or unmodified, in part or in whole, must
|
||||
be distributed entirely under this licence, and must not be distributed
|
||||
under any other licence. The requirement for fonts to remain under this
|
||||
licence does not affect any document created using the Font Software,
|
||||
except any version of the Font Software extracted from a document
|
||||
created using the Font Software may only be distributed under this
|
||||
licence.
|
||||
|
||||
TERMINATION
|
||||
This licence becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER
|
||||
DEALINGS IN THE FONT SOFTWARE.
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
version="1.1"
|
||||
id="Layer_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 200 200"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="tt_logo.svg"
|
||||
width="200"
|
||||
height="200"
|
||||
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
|
||||
inkscape:export-filename="tt_logo.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
||||
id="defs1" /><sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:zoom="4.97"
|
||||
inkscape:cx="100"
|
||||
inkscape:cy="100"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1216"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_1" />
|
||||
<rect
|
||||
style="fill:#000000;stroke-width:14.2701;stroke-linecap:round;stroke-linejoin:round"
|
||||
id="rect1"
|
||||
width="200"
|
||||
height="200"
|
||||
x="0"
|
||||
y="0" /><g
|
||||
id="g1"
|
||||
transform="matrix(0.75075075,0,0,0.7513148,-156.00601,-72.426747)"
|
||||
style="fill:#ffffff">
|
||||
<path
|
||||
d="m 341,96.4 c -44.5,0 -83.9,21.9 -108.1,55.5 -7.9,11 -14.2,23.2 -18.5,36.4 h 21.6 52.1 v 90.1 h 39.3 v -24.3 h 22.7 v 87.8 c -3,0.3 -6.1,0.4 -9.2,0.4 -62.2,0 -112.8,-50.6 -112.8,-112.8 0,-10.3 1.4,-20.2 4,-29.6 h -21 c -2.2,9.5 -3.3,19.4 -3.3,29.6 0,73.4 59.7,133.1 133.1,133.1 3.1,0 6.1,-0.1 9.2,-0.3 1.7,-0.1 3.4,-0.3 5.1,-0.5 0.1,0 0.3,0 0.4,0 11.8,-1.3 23.1,-4.1 33.8,-8.3 v 0 c 0,0 0,0 0,0 V 254.1 H 428 V 217.7 H 327.5 V 188.2 H 366 V 151.8 H 259.3 c 20.5,-21.6 49.6,-35.1 81.7,-35.1 62.2,0 112.8,50.6 112.8,112.8 0,40.1 -21,75.4 -52.6,95.4 v 23.4 c 43.3,-22 73,-67 73,-118.8 C 474.1,156.1 414.4,96.4 341,96.4 Z"
|
||||
id="path1"
|
||||
style="fill:#ffffff" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,16 @@
|
||||
VERSION 5.7 ;
|
||||
NOWIREEXTENSIONATPIN ON ;
|
||||
DIVIDERCHAR "/" ;
|
||||
BUSBITCHARS "[]" ;
|
||||
MACRO tt_logo_bottom
|
||||
CLASS BLOCK ;
|
||||
FOREIGN tt_logo_bottom ;
|
||||
ORIGIN 0.000 0.000 ;
|
||||
SIZE 100.000 BY 100.000 ;
|
||||
OBS
|
||||
LAYER met4 ;
|
||||
RECT 0.000 0.000 100.000 100.000 ;
|
||||
END
|
||||
END tt_logo_bottom
|
||||
END LIBRARY
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
`default_nettype none
|
||||
|
||||
module tt_logo_bottom ();
|
||||
endmodule
|
||||
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
VERSION 5.7 ;
|
||||
NOWIREEXTENSIONATPIN ON ;
|
||||
DIVIDERCHAR "/" ;
|
||||
BUSBITCHARS "[]" ;
|
||||
MACRO tt_logo_top
|
||||
CLASS BLOCK ;
|
||||
FOREIGN tt_logo_top ;
|
||||
ORIGIN 0.000 0.000 ;
|
||||
SIZE 100.000 BY 100.000 ;
|
||||
OBS
|
||||
LAYER met4 ;
|
||||
RECT 0.000 0.000 100.000 100.000 ;
|
||||
END
|
||||
END tt_logo_top
|
||||
END LIBRARY
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
`default_nettype none
|
||||
|
||||
module tt_logo_top ();
|
||||
endmodule
|
||||
+18
@@ -203,6 +203,20 @@ class ShuttleConfig:
|
||||
f"tt-multiplexer/ol2/tt_top/verilog/{name}.v",
|
||||
)
|
||||
|
||||
def copy_logo_macro(self, name: str):
|
||||
copy_print(
|
||||
f"tt/logo/{name}.gds",
|
||||
f"tt-multiplexer/ol2/tt_top/gds/{name}.gds",
|
||||
)
|
||||
copy_print(
|
||||
f"tt/logo/{name}.lef",
|
||||
f"tt-multiplexer/ol2/tt_top/lef/{name}.lef",
|
||||
)
|
||||
copy_print(
|
||||
f"tt/logo/{name}.v",
|
||||
f"tt-multiplexer/ol2/tt_top/verilog/{name}.v",
|
||||
)
|
||||
|
||||
def copy_macros(self):
|
||||
logging.info("copying macros to tt_top:")
|
||||
copy_print_glob("projects/*/*.gds", "tt-multiplexer/ol2/tt_top/gds")
|
||||
@@ -250,6 +264,10 @@ class ShuttleConfig:
|
||||
self.copy_mux_macro("pg/tt_pg_3v3_2", "tt_pg_3v3_2")
|
||||
self.copy_mux_macro("asw/tt_asw_3v3", "tt_asw_3v3")
|
||||
|
||||
# Copy logo & shuttle ID
|
||||
self.copy_logo_macro("tt_logo_top")
|
||||
self.copy_logo_macro("tt_logo_bottom")
|
||||
|
||||
def copy_final_results(self):
|
||||
macros = ["tt_um_chip_rom", "tt_ctrl", "tt_mux", "tt_top"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user