diff options
-rw-r--r-- | machxo2/arch.cc | 49 | ||||
-rw-r--r-- | machxo2/arch.h | 5 | ||||
-rw-r--r-- | machxo2/examples/mitertest.sh | 2 | ||||
-rw-r--r-- | machxo2/examples/simple.sh | 2 | ||||
-rw-r--r-- | machxo2/examples/simtest.sh | 2 | ||||
-rw-r--r-- | machxo2/main.cc | 18 |
6 files changed, 64 insertions, 14 deletions
diff --git a/machxo2/arch.cc b/machxo2/arch.cc index 5d1cb0cb..0a3f345f 100644 --- a/machxo2/arch.cc +++ b/machxo2/arch.cc @@ -29,14 +29,6 @@ NEXTPNR_NAMESPACE_BEGIN -// --------------------------------------------------------------- - -Arch::Arch(ArchArgs args) : chipName("generic"), args(args) -{ - // Dummy for empty decals - // decal_graphics[IdString()]; -} - // ----------------------------------------------------------------------- void IdString::initialize_arch(const BaseCtx *ctx) { @@ -74,8 +66,49 @@ static const ChipInfoPOD *get_chip_info(ArchArgs::ArchArgsTypes chip) return ptr->get(); } +// --------------------------------------------------------------- + +Arch::Arch(ArchArgs args) : args(args) +{ + chip_info = get_chip_info(args.type); + if (chip_info == nullptr) + log_error("Unsupported MachXO2 chip type.\n"); + if (chip_info->const_id_count != DB_CONST_ID_COUNT) + log_error("Chip database 'bba' and nextpnr code are out of sync; please rebuild (or contact distribution " + "maintainer)!\n"); + + package_info = nullptr; + for (int i = 0; i < chip_info->num_packages; i++) { + if (args.package == chip_info->package_info[i].name.get()) { + package_info = &(chip_info->package_info[i]); + break; + } + } + if (!package_info) + log_error("Unsupported package '%s' for '%s'.\n", args.package.c_str(), getChipName().c_str()); +} + bool Arch::isAvailable(ArchArgs::ArchArgsTypes chip) { return get_chip_info(chip) != nullptr; } +std::string Arch::getChipName() const +{ + if (args.type == ArchArgs::LCMXO2_256HC) { + return "LCMXO2-256HC"; + } else if (args.type == ArchArgs::LCMXO2_640HC) { + return "LCMXO2-640HC"; + } else if (args.type == ArchArgs::LCMXO2_1200HC) { + return "LCMXO2-1200HC"; + } else if (args.type == ArchArgs::LCMXO2_2000HC) { + return "LCMXO2-2000HC"; + } else if (args.type == ArchArgs::LCMXO2_4000HC) { + return "LCMXO2-4000HC"; + } else if (args.type == ArchArgs::LCMXO2_7000HC) { + return "LCMXO2-7000HC"; + } else { + log_error("Unknown chip\n"); + } +} + // --------------------------------------------------------------- BelId Arch::getBelByName(IdString name) const diff --git a/machxo2/arch.h b/machxo2/arch.h index ec7939f4..762412e2 100644 --- a/machxo2/arch.h +++ b/machxo2/arch.h @@ -255,7 +255,8 @@ struct CellTiming struct Arch : BaseCtx { - std::string chipName; + const ChipInfoPOD *chip_info; + const PackageInfoPOD *package_info; // Placeholders to be removed. std::unordered_map<Loc, BelId> bel_by_loc; @@ -275,7 +276,7 @@ struct Arch : BaseCtx static bool isAvailable(ArchArgs::ArchArgsTypes chip); - std::string getChipName() const { return chipName; } + std::string getChipName() const; IdString archId() const { return id("machxo2"); } ArchArgs archArgs() const { return args; } diff --git a/machxo2/examples/mitertest.sh b/machxo2/examples/mitertest.sh index aea5bfff..5190af31 100644 --- a/machxo2/examples/mitertest.sh +++ b/machxo2/examples/mitertest.sh @@ -68,7 +68,7 @@ set -ex ${YOSYS:-yosys} -p "read_verilog blinky.v synth_machxo2 -noiopad -json blinky.json show -format png -prefix blinky" -${NEXTPNR:-../../nextpnr-machxo2} $NEXTPNR_MODE --1200 --no-iobs --json blinky.json --write ${1}blinky.json +${NEXTPNR:-../../nextpnr-machxo2} $NEXTPNR_MODE --1200 --package QFN32 --no-iobs --json blinky.json --write ${1}blinky.json ${YOSYS:-yosys} -p "read_verilog -lib +/machxo2/cells_sim.v read_json ${1}blinky.json clean -purge diff --git a/machxo2/examples/simple.sh b/machxo2/examples/simple.sh index 91fa4b91..c977bf1a 100644 --- a/machxo2/examples/simple.sh +++ b/machxo2/examples/simple.sh @@ -26,7 +26,7 @@ set -ex ${YOSYS:-yosys} -p "read_verilog blinky.v synth_machxo2 -json blinky.json show -format png -prefix blinky" -${NEXTPNR:-../../nextpnr-machxo2} $NEXTPNR_MODE --1200 --no-iobs --json blinky.json --write ${1}blinky.json +${NEXTPNR:-../../nextpnr-machxo2} $NEXTPNR_MODE --1200 --package QFN32 --no-iobs --json blinky.json --write ${1}blinky.json ${YOSYS:-yosys} -p "read_verilog -lib +/machxo2/cells_sim.v read_json ${1}blinky.json clean -purge diff --git a/machxo2/examples/simtest.sh b/machxo2/examples/simtest.sh index ff35bbd6..53f2e728 100644 --- a/machxo2/examples/simtest.sh +++ b/machxo2/examples/simtest.sh @@ -26,7 +26,7 @@ set -ex ${YOSYS:-yosys} -p "read_verilog blinky.v synth_machxo2 -json blinky.json show -format png -prefix blinky" -${NEXTPNR:-../../nextpnr-machxo2} $NEXTPNR_MODE --1200 --no-iobs --json blinky.json --write ${1}blinky.json +${NEXTPNR:-../../nextpnr-machxo2} $NEXTPNR_MODE --1200 --package QFN32 --no-iobs --json blinky.json --write ${1}blinky.json ${YOSYS:-yosys} -p "read_verilog -lib +/machxo2/cells_sim.v read_json ${1}blinky.json clean -purge diff --git a/machxo2/main.cc b/machxo2/main.cc index 92a60d38..5a5c7f82 100644 --- a/machxo2/main.cc +++ b/machxo2/main.cc @@ -58,7 +58,7 @@ po::options_description MachXO2CommandHandler::getArchOptions() if (Arch::isAvailable(ArchArgs::LCMXO2_7000HC)) specific.add_options()("7000", "set device type to LCMXO2-7000HC"); - specific.add_options()("package", po::value<std::string>(), "select device package (defaults to QFN32)"); + specific.add_options()("package", po::value<std::string>(), "select device package"); specific.add_options()("speed", po::value<int>(), "select device speedgrade (1 to 6 inclusive)"); specific.add_options()("override-basecfg", po::value<std::string>(), @@ -76,6 +76,22 @@ void MachXO2CommandHandler::customBitstream(Context *ctx) {} std::unique_ptr<Context> MachXO2CommandHandler::createContext(std::unordered_map<std::string, Property> &values) { ArchArgs chipArgs; + chipArgs.type = ArchArgs::NONE; + if (vm.count("256")) + chipArgs.type = ArchArgs::LCMXO2_256HC; + if (vm.count("640")) + chipArgs.type = ArchArgs::LCMXO2_640HC; + if (vm.count("1200")) + chipArgs.type = ArchArgs::LCMXO2_1200HC; + if (vm.count("2000")) + chipArgs.type = ArchArgs::LCMXO2_2000HC; + if (vm.count("4000")) + chipArgs.type = ArchArgs::LCMXO2_4000HC; + if (vm.count("7000")) + chipArgs.type = ArchArgs::LCMXO2_7000HC; + if (vm.count("package")) + chipArgs.package = vm["package"].as<std::string>(); + if (values.find("arch.name") != values.end()) { std::string arch_name = values["arch.name"].as_string(); if (arch_name != "machxo2") |