mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
feat: "layout" section in shuttle_index
contains information about the type each each mux (analog / digital)
This commit is contained in:
+28
-3
@@ -3,14 +3,14 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from typing import List
|
from typing import List, Set
|
||||||
|
|
||||||
import git
|
import git
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from config import Config
|
from config import Config
|
||||||
from project import Project
|
from project import Project
|
||||||
from shuttle_index import ShuttleIndex, ShuttleIndexProject
|
from shuttle_index import ShuttleIndex, ShuttleIndexLayout, ShuttleIndexProject
|
||||||
|
|
||||||
|
|
||||||
def copy_print(src: str, dest: str):
|
def copy_print(src: str, dest: str):
|
||||||
@@ -30,15 +30,39 @@ class ShuttleConfig:
|
|||||||
self.projects = projects
|
self.projects = projects
|
||||||
self.script_dir = os.path.dirname(os.path.realpath(__file__))
|
self.script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
self.modules_yaml_name = modules_yaml_name
|
self.modules_yaml_name = modules_yaml_name
|
||||||
|
self.mux_config_yaml_name = os.environ.get("TT_CONFIG", "sky130.yaml")
|
||||||
if config.get("openframe", False):
|
if config.get("openframe", False):
|
||||||
self.tt_top_macro = "openframe_project_wrapper"
|
self.tt_top_macro = "openframe_project_wrapper"
|
||||||
else:
|
else:
|
||||||
self.tt_top_macro = "user_project_wrapper"
|
self.tt_top_macro = "user_project_wrapper"
|
||||||
|
|
||||||
|
self.read_mux_config_file()
|
||||||
|
total_rows: int = self.mux_config["tt"]["grid"]["y"]
|
||||||
|
total_mux_rows = total_rows // 2
|
||||||
|
self.layout: ShuttleIndexLayout = {
|
||||||
|
"muxes": [["digital"] * total_mux_rows, ["digital"] * total_mux_rows]
|
||||||
|
}
|
||||||
|
for item in self.mux_config["tt"]["analog"]:
|
||||||
|
mux_id: int
|
||||||
|
for mux_id in item["mux_id"]:
|
||||||
|
x = (mux_id >> 1) & 1
|
||||||
|
y = (
|
||||||
|
total_mux_rows // 2
|
||||||
|
- (2 * (mux_id & 1) - 1) * (mux_id >> 2)
|
||||||
|
- (mux_id & 1)
|
||||||
|
)
|
||||||
|
self.layout["muxes"][x][y] = "analog"
|
||||||
|
|
||||||
|
def read_mux_config_file(self):
|
||||||
|
with open(
|
||||||
|
f"tt-multiplexer/cfg/{self.mux_config_yaml_name}", "r"
|
||||||
|
) as mux_config_file:
|
||||||
|
self.mux_config = yaml.safe_load(mux_config_file)
|
||||||
|
|
||||||
def configure_mux(self):
|
def configure_mux(self):
|
||||||
with open(self.modules_yaml_name, "r") as modules_file:
|
with open(self.modules_yaml_name, "r") as modules_file:
|
||||||
module_config = yaml.safe_load(modules_file)
|
module_config = yaml.safe_load(modules_file)
|
||||||
configured_macros = set(
|
configured_macros: Set[str] = set(
|
||||||
map(lambda mod: mod["name"], module_config["modules"])
|
map(lambda mod: mod["name"], module_config["modules"])
|
||||||
)
|
)
|
||||||
logging.info(
|
logging.info(
|
||||||
@@ -108,6 +132,7 @@ class ShuttleConfig:
|
|||||||
"repo": list(repo.remotes[0].urls)[0],
|
"repo": list(repo.remotes[0].urls)[0],
|
||||||
"commit": repo.commit().hexsha,
|
"commit": repo.commit().hexsha,
|
||||||
"commit_date": repo.commit().committed_date,
|
"commit_date": repo.commit().committed_date,
|
||||||
|
"layout": self.layout,
|
||||||
"version": 3,
|
"version": 3,
|
||||||
"projects": project_index,
|
"projects": project_index,
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -1,4 +1,4 @@
|
|||||||
from typing import List, NotRequired, TypedDict
|
from typing import List, Literal, NotRequired, TypedDict
|
||||||
|
|
||||||
|
|
||||||
class ShuttleIndexProject(TypedDict):
|
class ShuttleIndexProject(TypedDict):
|
||||||
@@ -12,6 +12,10 @@ class ShuttleIndexProject(TypedDict):
|
|||||||
analog_pins: NotRequired[List[int]]
|
analog_pins: NotRequired[List[int]]
|
||||||
|
|
||||||
|
|
||||||
|
class ShuttleIndexLayout(TypedDict):
|
||||||
|
muxes: List[List[Literal["analog", "digital"]]]
|
||||||
|
|
||||||
|
|
||||||
class ShuttleIndex(TypedDict):
|
class ShuttleIndex(TypedDict):
|
||||||
"""TypedDict for Tiny Tapeout's shuttle_index.json file."""
|
"""TypedDict for Tiny Tapeout's shuttle_index.json file."""
|
||||||
|
|
||||||
@@ -20,4 +24,5 @@ class ShuttleIndex(TypedDict):
|
|||||||
commit: str
|
commit: str
|
||||||
commit_date: int
|
commit_date: int
|
||||||
version: int
|
version: int
|
||||||
|
layout: ShuttleIndexLayout
|
||||||
projects: List[ShuttleIndexProject]
|
projects: List[ShuttleIndexProject]
|
||||||
|
|||||||
Reference in New Issue
Block a user