From 3be76a837d20fb81814067cebdd45f482cbcbb33 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 8 Jul 2020 13:22:59 +0200 Subject: Support 4K parts directly --- ice40/arch.cc | 27 ++++++++++++++++++++++----- ice40/arch.h | 1 + ice40/main.cc | 10 ++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) (limited to 'ice40') diff --git a/ice40/arch.cc b/ice40/arch.cc index be346fd7..b20245fc 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -55,7 +55,7 @@ static const ChipInfoPOD *get_chip_info(ArchArgs::ArchArgsTypes chip) chipdb = "ice40/chipdb-u4k.bin"; } else if (chip == ArchArgs::UP5K) { chipdb = "ice40/chipdb-5k.bin"; - } else if (chip == ArchArgs::LP8K || chip == ArchArgs::HX8K) { + } else if (chip == ArchArgs::LP8K || chip == ArchArgs::HX8K || chip == ArchArgs::HX4K) { chipdb = "ice40/chipdb-8k.bin"; } else { log_error("Unknown chip\n"); @@ -73,8 +73,17 @@ std::vector Arch::getSupportedPackages(ArchArgs::ArchArgsTypes chip { const ChipInfoPOD *chip_info = get_chip_info(chip); std::vector packages; - for (int i = 0; i < chip_info->num_packages; i++) - packages.push_back(chip_info->packages_data[i].name.get()); + for (int i = 0; i < chip_info->num_packages; i++) { + std::string name = chip_info->packages_data[i].name.get(); + if (chip == ArchArgs::HX4K) + { + if (name.find(":4k") != std::string::npos) + name = name.substr(0, name.size()-3); + else + continue; + } + packages.push_back(name); + } return packages; } @@ -82,15 +91,19 @@ std::vector Arch::getSupportedPackages(ArchArgs::ArchArgsTypes chip Arch::Arch(ArchArgs args) : args(args) { - fast_part = (args.type == ArchArgs::HX8K || args.type == ArchArgs::HX1K); + fast_part = (args.type == ArchArgs::HX8K || args.type == ArchArgs::HX4K || args.type == ArchArgs::HX1K); chip_info = get_chip_info(args.type); if (chip_info == nullptr) log_error("Unsupported iCE40 chip type.\n"); package_info = nullptr; + std::string package_name = args.package; + if (args.type == ArchArgs::HX4K) + package_name += ":4k"; + for (int i = 0; i < chip_info->num_packages; i++) { - if (chip_info->packages_data[i].name.get() == args.package) { + if (chip_info->packages_data[i].name.get() == package_name) { package_info = &(chip_info->packages_data[i]); break; } @@ -121,6 +134,8 @@ std::string Arch::getChipName() const return "Lattice U4K"; } else if (args.type == ArchArgs::LP8K) { return "Lattice LP8K"; + } else if (args.type == ArchArgs::HX4K) { + return "Lattice HX4K"; } else if (args.type == ArchArgs::HX8K) { return "Lattice HX8K"; } else { @@ -144,6 +159,8 @@ IdString Arch::archArgsToId(ArchArgs args) const return id("u4k"); if (args.type == ArchArgs::LP8K) return id("lp8k"); + if (args.type == ArchArgs::HX4K) + return id("hx4k"); if (args.type == ArchArgs::HX8K) return id("hx8k"); return IdString(); diff --git a/ice40/arch.h b/ice40/arch.h index 0d8e7d76..9197dcd2 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -387,6 +387,7 @@ struct ArchArgs LP1K, LP8K, HX1K, + HX4K, HX8K, UP5K, U4K diff --git a/ice40/main.cc b/ice40/main.cc index 497d580b..fedd0918 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -59,6 +59,8 @@ po::options_description Ice40CommandHandler::getArchOptions() if (Arch::isAvailable(ArchArgs::HX1K)) specific.add_options()("hx1k", "set device type to iCE40HX1K"); if (Arch::isAvailable(ArchArgs::HX8K)) + specific.add_options()("hx4k", "set device type to iCE40HX4K"); + if (Arch::isAvailable(ArchArgs::HX4K)) specific.add_options()("hx8k", "set device type to iCE40HX8K"); if (Arch::isAvailable(ArchArgs::UP5K)) specific.add_options()("up5k", "set device type to iCE40UP5K"); @@ -142,6 +144,11 @@ std::unique_ptr Ice40CommandHandler::createContext(std::unordered_map Ice40CommandHandler::createContext(std::unordered_map