cellhelp.py: Cells can have tags

Tags are added to the list of properties when exporting to `cells.json`.
This commit is contained in:
Krystine Sherwin 2024-09-05 16:51:26 +12:00
parent 9ce6952131
commit b1025dbaa6
No known key found for this signature in database
2 changed files with 18 additions and 6 deletions

View File

@ -766,6 +766,7 @@ struct SimHelper {
string code;
string group;
string ver;
string tags;
};
static bool is_code_getter(string name) {
@ -1013,12 +1014,20 @@ struct HelpPass : public Pass {
for (auto &output : ct.outputs)
outputs.push_back(output.str());
json.name("outputs"); json.value(outputs);
dict<string, bool> prop_dict = {
{"is_evaluable", ct.is_evaluable},
{"is_combinatorial", ct.is_combinatorial},
{"is_synthesizable", ct.is_synthesizable},
};
json.name("properties"); json.value(prop_dict);
vector<string> properties;
// CellType properties
if (ct.is_evaluable) properties.push_back("is_evaluable");
if (ct.is_combinatorial) properties.push_back("is_combinatorial");
if (ct.is_synthesizable) properties.push_back("is_synthesizable");
// SimHelper properties
size_t last = 0; size_t next = 0;
while ((next = ch.tags.find(", ", last)) != string::npos) {
properties.push_back(ch.tags.substr(last, next-last));
last = next + 2;
}
auto final_tag = ch.tags.substr(last);
if (final_tag.size()) properties.push_back(final_tag);
json.name("properties"); json.value(properties);
json.end_object();
}
json.end_object();

View File

@ -14,13 +14,16 @@ class SimHelper:
code: list[str]
group: str = ""
ver: str = "1"
tags: list[str]
def __init__(self) -> None:
self.desc = []
self.tags = []
def __str__(self) -> str:
printed_fields = [
"name", "title", "ports", "source", "desc", "code", "group", "ver",
"tags",
]
# generate C++ struct
val = f"cell_help[{json.dumps(self.name)}] = "