nexus: Add ES2 device names and --list-devices

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2022-09-15 12:27:36 +02:00
parent 79aad0988a
commit 7ca3ba3835
3 changed files with 42 additions and 1 deletions

View File

@ -58,7 +58,9 @@ Arch::Arch(ArchArgs args) : args(args)
log_error("Unknown device string '%s' (expected device name like 'LIFCL-40-8SG72C')\n", args.device.c_str());
device = args.device.substr(0, last_sep);
speed = args.device.substr(last_sep + 1, 1);
auto package_end = args.device.find_last_of("0123456789");
auto package_end = args.device.find_last_of("0123456789", args.device.substr(args.device.size() - 3) == "ES2"
? args.device.size() - 3
: std::string::npos);
if (package_end == std::string::npos || package_end < last_sep)
log_error("Unknown device string '%s' (expected device name like 'LIFCL-40-8SG72C')\n", args.device.c_str());
package = args.device.substr(last_sep + 2, (package_end - (last_sep + 2)) + 1);
@ -67,6 +69,9 @@ Arch::Arch(ArchArgs args) : args(args)
// Check for 'ES' part
if (rating.size() > 1 && rating.substr(1) == "ES") {
variant = "ES";
} else if (rating.size() > 1 && rating.substr(1) == "ES2") {
// ES2 devices are production-equivalent from nextpnr's and bitstream point of view
variant = "";
} else {
variant = "";
}
@ -194,6 +199,35 @@ Arch::Arch(ArchArgs args) : args(args)
}
}
void Arch::list_devices()
{
std::vector<std::string> families{
"LIFCL",
};
log("Supported devices: \n");
for (auto fam : families) {
std::string chipdb = stringf("nexus/chipdb-%s.bin", fam.c_str());
auto db_ptr = reinterpret_cast<const RelPtr<DatabasePOD> *>(get_chipdb(chipdb));
if (!db_ptr)
continue; // chipdb not available
// enumerate chips
for (auto &chip : db_ptr->get()->chips) {
// enumerate packages
for (auto &pkg : chip.packages) {
// enumerate suffices
for (auto speedgrade : {"7", "8", "9"}) { // TODO: these might depend on family
for (auto rating : {"I", "C"}) {
for (auto suffix : {"", "ES", "ES2"}) {
log(" %s-%s%s%s%s\n", chip.device_name.get(), speedgrade, pkg.short_name.get(), rating,
suffix);
}
}
}
}
}
}
}
// -----------------------------------------------------------------------
std::string Arch::getChipName() const { return args.device; }

View File

@ -1522,6 +1522,8 @@ struct Arch : BaseArch<ArchRanges>
// -------------------------------------------------
void write_fasm(std::ostream &out) const;
// -------------------------------------------------
static void list_devices();
};
NEXTPNR_NAMESPACE_END

View File

@ -48,6 +48,7 @@ po::options_description NexusCommandHandler::getArchOptions()
{
po::options_description specific("Architecture specific options");
specific.add_options()("device", po::value<std::string>(), "device name");
specific.add_options()("list-devices", "list all supported device names");
specific.add_options()("fasm", po::value<std::string>(), "fasm file to write");
specific.add_options()("pdc", po::value<std::string>(), "physical constraints file");
specific.add_options()("no-post-place-opt", "disable post-place repacking (debugging use only)");
@ -73,6 +74,10 @@ void NexusCommandHandler::customBitstream(Context *ctx)
std::unique_ptr<Context> NexusCommandHandler::createContext(dict<std::string, Property> &values)
{
ArchArgs chipArgs;
if (vm.count("list-devices")) {
Arch::list_devices();
exit(0);
}
if (!vm.count("device")) {
log_error("device must be specified on the command line (e.g. --device LIFCL-40-9BG400CES)\n");
}