From 89e0cc8078ecbb57ca450cc6c8a40f6b634b8c9c Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 25 Jun 2020 15:11:47 +0000 Subject: Simplify and improve chipdb embedding/loading. --- gui/ice40/mainwindow.cc | 63 +++++++++++++++---------------------------------- 1 file changed, 19 insertions(+), 44 deletions(-) (limited to 'gui/ice40/mainwindow.cc') diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc index dc8a3a23..3dcf90ae 100644 --- a/gui/ice40/mainwindow.cc +++ b/gui/ice40/mainwindow.cc @@ -74,59 +74,34 @@ void MainWindow::createMenu() menuDesign->addAction(actionSaveAsc); } -static const ChipInfoPOD *get_chip_info(const RelPtr *ptr) { return ptr->get(); } - -static QStringList getSupportedPackages(ArchArgs::ArchArgsTypes chip) -{ - QStringList packages; - const ChipInfoPOD *chip_info; -#ifdef ICE40_HX1K_ONLY - if (chip == ArchArgs::HX1K) { - chip_info = get_chip_info(reinterpret_cast *>(chipdb_blob_1k)); - } else { - log_error("Unsupported iCE40 chip type.\n"); - } -#else - if (chip == ArchArgs::LP384) { - chip_info = get_chip_info(reinterpret_cast *>(chipdb_blob_384)); - } else if (chip == ArchArgs::LP1K || chip == ArchArgs::HX1K) { - chip_info = get_chip_info(reinterpret_cast *>(chipdb_blob_1k)); - } else if (chip == ArchArgs::UP5K) { - chip_info = get_chip_info(reinterpret_cast *>(chipdb_blob_5k)); - } else if (chip == ArchArgs::LP8K || chip == ArchArgs::HX8K) { - chip_info = get_chip_info(reinterpret_cast *>(chipdb_blob_8k)); - } else { - log_error("Unsupported iCE40 chip type.\n"); - } -#endif - - for (int i = 0; i < chip_info->num_packages; i++) { - packages << chip_info->packages_data[i].name.get(); - } - return packages; -} - void MainWindow::new_proj() { QMap arch; -#ifdef ICE40_HX1K_ONLY - arch.insert("Lattice HX1K", ArchArgs::HX1K); -#else - arch.insert("Lattice LP384", ArchArgs::LP384); - arch.insert("Lattice LP1K", ArchArgs::LP1K); - arch.insert("Lattice HX1K", ArchArgs::HX1K); - arch.insert("Lattice UP5K", ArchArgs::UP5K); - arch.insert("Lattice LP8K", ArchArgs::LP8K); - arch.insert("Lattice HX8K", ArchArgs::HX8K); -#endif + if (Arch::isAvailable(ArchArgs::LP384)) + arch.insert("Lattice LP384", ArchArgs::LP384); + if (Arch::isAvailable(ArchArgs::LP1K)) + arch.insert("Lattice LP1K", ArchArgs::LP1K); + if (Arch::isAvailable(ArchArgs::HX1K)) + arch.insert("Lattice HX1K", ArchArgs::HX1K); + if (Arch::isAvailable(ArchArgs::U4K)) + arch.insert("Lattice U4K", ArchArgs::U4K); + if (Arch::isAvailable(ArchArgs::UP5K)) + arch.insert("Lattice UP5K", ArchArgs::UP5K); + if (Arch::isAvailable(ArchArgs::LP8K)) + arch.insert("Lattice LP8K", ArchArgs::LP8K); + if (Arch::isAvailable(ArchArgs::HX8K)) + arch.insert("Lattice HX8K", ArchArgs::HX8K); + bool ok; QString item = QInputDialog::getItem(this, "Select new context", "Chip:", arch.keys(), 0, false, &ok); if (ok && !item.isEmpty()) { ArchArgs chipArgs; chipArgs.type = (ArchArgs::ArchArgsTypes)arch.value(item); - QString package = QInputDialog::getItem(this, "Select package", "Package:", getSupportedPackages(chipArgs.type), - 0, false, &ok); + QStringList packages; + for (auto package : Arch::getSupportedPackages(chipArgs.type)) + packages.append(QLatin1String(package.data(), package.size())); + QString package = QInputDialog::getItem(this, "Select package", "Package:", packages, 0, false, &ok); if (ok && !item.isEmpty()) { currentProj = ""; -- cgit v1.2.3