From 9704ebd079fd7d8c94af97a49ef9f8f8c6ae2871 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 7 Jul 2018 13:23:45 +0200 Subject: Added selection of chip and pacakge on new projet in GUI --- gui/ice40/mainwindow.cc | 76 ++++++++++++++++++++++++++++++++++++++++++------- gui/ice40/mainwindow.h | 1 + ice40/arch.h | 2 +- 3 files changed, 68 insertions(+), 11 deletions(-) diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc index 6cc8bc38..f423ee37 100644 --- a/gui/ice40/mainwindow.cc +++ b/gui/ice40/mainwindow.cc @@ -178,24 +178,80 @@ void MainWindow::createMenu() taskToolBar->addAction(actionStop); } +#if defined(_MSC_VER) +void load_chipdb(); +#endif + +static const ChipInfoPOD *get_chip_info(const RelPtr *ptr) { return ptr->get(); } + +QStringList getSupportedPackages(ArchArgs::ArchArgsTypes chip) +{ + QStringList packages; +#if defined(_MSC_VER) + load_chipdb(); +#endif + 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() { - disableActions(); - ArchArgs chipArgs; - chipArgs.type = ArchArgs::HX1K; - chipArgs.package = "tq144"; - if (ctx) - delete ctx; - ctx = new Context(chipArgs); + QMap arch; + 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); + bool ok; + QString item = QInputDialog::getItem(this, "Select new context", "Chip:", arch.keys(), 0, false, &ok); + if (ok && !item.isEmpty()) { - Q_EMIT contextChanged(ctx); + chipArgs.type = (ArchArgs::ArchArgsTypes)arch.value(item); - actionLoadJSON->setEnabled(true); + QString package = QInputDialog::getItem(this, "Select package", "Package:", getSupportedPackages(chipArgs.type), + 0, false, &ok); + + if (ok && !item.isEmpty()) { + disableActions(); + chipArgs.package = package.toStdString().c_str(); + if (ctx) + delete ctx; + ctx = new Context(chipArgs); + + Q_EMIT contextChanged(ctx); + + actionLoadJSON->setEnabled(true); + } + } } void MainWindow::newContext(Context *ctx) { - std::string title = "nextpnr-ice40 - " + ctx->getChipName(); + std::string title = "nextpnr-ice40 - " + ctx->getChipName() + " ( " + chipArgs.package + " )"; setWindowTitle(title.c_str()); } diff --git a/gui/ice40/mainwindow.h b/gui/ice40/mainwindow.h index ffeb0473..8e847adc 100644 --- a/gui/ice40/mainwindow.h +++ b/gui/ice40/mainwindow.h @@ -77,6 +77,7 @@ class MainWindow : public BaseMainWindow QAction *actionStop; bool timing_driven; + ArchArgs chipArgs; }; NEXTPNR_NAMESPACE_END diff --git a/ice40/arch.h b/ice40/arch.h index c91625e9..43aa0829 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -303,7 +303,7 @@ struct PipRange struct ArchArgs { - enum + enum ArchArgsTypes { NONE, LP384, -- cgit v1.2.3