feat: new format for shuttle_index

1. Bump "version" to 3
2. Rename "shuttle" to "name"
2. Rename "mux" to "projects", and turn it from a dict into a list
3. Project entries: add "address" (which was previously the key of the "mux" dict), remove "features" and add optional "analog_pins" with a list of analog pin assignment.
This commit is contained in:
Uri Shaked
2024-03-18 01:16:22 +02:00
parent b1a2a3bb98
commit ef5539b7a0
2 changed files with 23 additions and 15 deletions
+17 -10
View File
@@ -3,14 +3,14 @@ import json
import logging import logging
import os import os
import shutil import shutil
from typing import Dict, List from typing import List
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, ShuttleIndexMuxEntry from shuttle_index import ShuttleIndex, ShuttleIndexProject
def copy_print(src: str, dest: str): def copy_print(src: str, dest: str):
@@ -64,7 +64,7 @@ class ShuttleConfig:
logging.error("Failed to generate multiplexer placement configuration") logging.error("Failed to generate multiplexer placement configuration")
exit(1) exit(1)
mux_index: Dict[str, ShuttleIndexMuxEntry] = {} project_index: List[ShuttleIndexProject] = []
mux_index_reverse = {} mux_index_reverse = {}
with open("tt-multiplexer/cfg/modules_placed.yaml") as placed_modules_file: with open("tt-multiplexer/cfg/modules_placed.yaml") as placed_modules_file:
placed_modules = yaml.safe_load(placed_modules_file) placed_modules = yaml.safe_load(placed_modules_file)
@@ -75,17 +75,24 @@ class ShuttleConfig:
p for p in self.projects if p.info.top_module == module_name p for p in self.projects if p.info.top_module == module_name
) )
project.mux_address = mux_address project.mux_address = mux_address
mux_index[mux_address] = { project_info: ShuttleIndexProject = {
"macro": module_name, "macro": module_name,
"address": mux_address,
"x": module["x"], "x": module["x"],
"y": module["y"], "y": module["y"],
"tiles": f"{module['width']}x{module['height']}", "tiles": f"{module['width']}x{module['height']}",
"repo": project.git_url, "repo": project.git_url,
"commit": project.commit_id, "commit": project.commit_id,
"features": {
"analog": module["analog"],
},
} }
assert list(module["analog"].keys()) == list(
range(len(module["analog"]))
), f"analog pins are not contiguous for {module_name}"
if len(module["analog"]) > 0:
project_info["analog_pins"] = list(module["analog"].values())
project_index.append(project_info)
mux_index_reverse[module_name] = mux_address mux_index_reverse[module_name] = mux_address
for project in self.projects: for project in self.projects:
@@ -97,12 +104,12 @@ class ShuttleConfig:
repo = git.Repo(".") repo = git.Repo(".")
shuttle_index_data: ShuttleIndex = { shuttle_index_data: ShuttleIndex = {
"shuttle": self.config["name"], "name": self.config["name"],
"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,
"version": 2, "version": 3,
"mux": mux_index, "projects": project_index,
} }
with open("shuttle_index.json", "w") as shuttle_index_file: with open("shuttle_index.json", "w") as shuttle_index_file:
+6 -5
View File
@@ -1,22 +1,23 @@
from typing import Dict, TypedDict from typing import List, NotRequired, TypedDict
class ShuttleIndexMuxEntry(TypedDict): class ShuttleIndexProject(TypedDict):
macro: str macro: str
address: int
x: int x: int
y: int y: int
tiles: str tiles: str
repo: str repo: str
commit: str commit: str
features: dict[str, bool] analog_pins: NotRequired[List[int]]
class ShuttleIndex(TypedDict): class ShuttleIndex(TypedDict):
"""TypedDict for Tiny Tapeout's shuttle_index.json file.""" """TypedDict for Tiny Tapeout's shuttle_index.json file."""
shuttle: str name: str
repo: str repo: str
commit: str commit: str
commit_date: int commit_date: int
version: int version: int
mux: Dict[str, ShuttleIndexMuxEntry] projects: List[ShuttleIndexProject]