From ca7e944d7a58bc305f0efce4da757520a6a86041 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 14 Jun 2019 08:55:11 +0200 Subject: restore arch info for ecp5 --- ecp5/main.cc | 115 ++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 91 insertions(+), 24 deletions(-) (limited to 'ecp5/main.cc') diff --git a/ecp5/main.cc b/ecp5/main.cc index 355e346d..0620b8b7 100644 --- a/ecp5/main.cc +++ b/ecp5/main.cc @@ -98,9 +98,20 @@ void ECP5CommandHandler::customBitstream(Context *ctx) write_bitstream(ctx, basecfg, textcfg); } +static std::string speedString(ArchArgs::SpeedGrade speed) +{ + switch(speed){ + case ArchArgs::SPEED_6: return "6"; + case ArchArgs::SPEED_7: return "7"; + case ArchArgs::SPEED_8: return "8"; + case ArchArgs::SPEED_8_5G: return "8"; + } + return ""; +} + std::unique_ptr ECP5CommandHandler::createContext(std::unordered_map &values) { - chipArgs.type = ArchArgs::LFE5U_45F; + chipArgs.type = ArchArgs::NONE; if (vm.count("25k")) chipArgs.type = ArchArgs::LFE5U_25F; @@ -122,36 +133,92 @@ std::unique_ptr ECP5CommandHandler::createContext(std::unordered_map(); - else + + if (vm.count("speed")) { + int speed = vm["speed"].as(); + switch (speed) { + case 6: + chipArgs.speed = ArchArgs::SPEED_6; + break; + case 7: + chipArgs.speed = ArchArgs::SPEED_7; + break; + case 8: + chipArgs.speed = ArchArgs::SPEED_8; + break; + default: + log_error("Unsupported speed grade '%d'\n", speed); + } + } else { + chipArgs.speed = ArchArgs::SPEED_6; + } + if (values.find("arch.name")!=values.end()) { + std::string arch_name = values["arch.name"].str; + if (arch_name != "ecp5") + log_error("Unsuported architecture '%s'.\n", arch_name.c_str()); + } + if (values.find("arch.type")!=values.end()) { + std::string arch_type = values["arch.type"].str; + if (chipArgs.type != ArchArgs::NONE) + log_error("Overriding architecture is unsuported.\n"); + + if (arch_type == "lfe5u_25f") + chipArgs.type = ArchArgs::LFE5U_25F; + if (arch_type == "lfe5u_45f") + chipArgs.type = ArchArgs::LFE5U_45F; + if (arch_type == "lfe5u_85f") + chipArgs.type = ArchArgs::LFE5U_85F; + if (arch_type == "lfe5um_25f") + chipArgs.type = ArchArgs::LFE5UM_25F; + if (arch_type == "lfe5um_45f") + chipArgs.type = ArchArgs::LFE5UM_45F; + if (arch_type == "lfe5um_85f") + chipArgs.type = ArchArgs::LFE5UM_85F; + if (arch_type == "lfe5um5g_25f") + chipArgs.type = ArchArgs::LFE5UM5G_25F; + if (arch_type == "lfe5um5g_45f") + chipArgs.type = ArchArgs::LFE5UM5G_45F; + if (arch_type == "lfe5um5g_85f") + chipArgs.type = ArchArgs::LFE5UM5G_85F; + + if (chipArgs.type == ArchArgs::NONE) + log_error("Unsuported FPGA type '%s'.\n",arch_type.c_str()); + } + if (values.find("arch.package")!=values.end()) { + if (vm.count("package")) + log_error("Overriding architecture is unsuported.\n"); + chipArgs.package = values["arch.package"].str; + } + if (values.find("arch.speed")!=values.end()) { + std::string arch_speed = values["arch.speed"].str; + if (arch_speed == "6") + chipArgs.speed = ArchArgs::SPEED_6; + else if (arch_speed == "7") + chipArgs.speed = ArchArgs::SPEED_7; + else if (arch_speed == "8") + chipArgs.speed = ArchArgs::SPEED_8; + else + log_error("Unsuported speed '%s'.\n",arch_speed.c_str()); + } + if (chipArgs.type == ArchArgs::NONE) + chipArgs.type = ArchArgs::LFE5U_45F; + + if (chipArgs.package.empty()) chipArgs.package = "CABGA381"; + if (chipArgs.type == ArchArgs::LFE5UM5G_25F || chipArgs.type == ArchArgs::LFE5UM5G_45F || chipArgs.type == ArchArgs::LFE5UM5G_85F) { - if (vm.count("speed") && vm["speed"].as() != 8) + if (chipArgs.speed != ArchArgs::SPEED_8) log_error("Only speed grade 8 is available for 5G parts\n"); - chipArgs.speed = ArchArgs::SPEED_8_5G; - } else { - if (vm.count("speed")) { - int speed = vm["speed"].as(); - switch (speed) { - case 6: - chipArgs.speed = ArchArgs::SPEED_6; - break; - case 7: - chipArgs.speed = ArchArgs::SPEED_7; - break; - case 8: - chipArgs.speed = ArchArgs::SPEED_8; - break; - default: - log_error("Unsupported speed grade '%d'\n", speed); - } - } else { - chipArgs.speed = ArchArgs::SPEED_6; - } + else + chipArgs.speed = ArchArgs::SPEED_8_5G; } + auto ctx = std::unique_ptr(new Context(chipArgs)); + for(auto &val : values) + ctx->settings[ctx->id(val.first)] = val.second; ctx->settings[ctx->id("arch.package")] = ctx->archArgs().package; - ctx->settings[ctx->id("arch.speed")] = std::to_string(ctx->archArgs().speed); + ctx->settings[ctx->id("arch.speed")] = speedString(ctx->archArgs().speed); return ctx; } -- cgit v1.2.3