From 8aac6db44b0ede432cdf1723b8a53ed827aa649d Mon Sep 17 00:00:00 2001 From: David Shah Date: Tue, 16 Oct 2018 14:37:24 +0100 Subject: ecp5: Add support for correct tile naming in all variants Signed-off-by: David Shah --- ecp5/arch.cc | 30 +++++++++++++++++++++++++++--- ecp5/arch.h | 6 ++++++ ecp5/bitstream.cc | 34 +++++++++++++++++++++++++++++++++- ecp5/main.cc | 18 ++++++++++++++++++ 4 files changed, 84 insertions(+), 4 deletions(-) diff --git a/ecp5/arch.cc b/ecp5/arch.cc index ba7a9e0b..b674e1b7 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -77,11 +77,11 @@ Arch::Arch(ArchArgs args) : args(args) log_error("Unsupported ECP5 chip type.\n"); } #else - if (args.type == ArchArgs::LFE5U_25F) { + if (args.type == ArchArgs::LFE5U_25F || args.type == ArchArgs::LFE5UM_25F || args.type == ArchArgs::LFE5UM5G_25F) { chip_info = get_chip_info(reinterpret_cast *>(chipdb_blob_25k)); - } else if (args.type == ArchArgs::LFE5U_45F) { + } else if (args.type == ArchArgs::LFE5U_45F || args.type == ArchArgs::LFE5UM_45F || args.type == ArchArgs::LFE5UM5G_45F) { chip_info = get_chip_info(reinterpret_cast *>(chipdb_blob_45k)); - } else if (args.type == ArchArgs::LFE5U_85F) { + } else if (args.type == ArchArgs::LFE5U_85F || args.type == ArchArgs::LFE5UM_85F || args.type == ArchArgs::LFE5UM5G_85F) { chip_info = get_chip_info(reinterpret_cast *>(chipdb_blob_85k)); } else { log_error("Unsupported ECP5 chip type.\n"); @@ -111,6 +111,18 @@ std::string Arch::getChipName() const return "LFE5U-45F"; } else if (args.type == ArchArgs::LFE5U_85F) { return "LFE5U-85F"; + } else if (args.type == ArchArgs::LFE5UM_25F) { + return "LFE5UM-25F"; + } else if (args.type == ArchArgs::LFE5UM_45F) { + return "LFE5UM-45F"; + } else if (args.type == ArchArgs::LFE5UM_85F) { + return "LFE5UM-85F"; + } else if (args.type == ArchArgs::LFE5UM5G_25F) { + return "LFE5UM5G-25F"; + } else if (args.type == ArchArgs::LFE5UM5G_45F) { + return "LFE5UM5G-45F"; + } else if (args.type == ArchArgs::LFE5UM5G_85F) { + return "LFE5UM5G-85F"; } else { log_error("Unknown chip\n"); } @@ -126,6 +138,18 @@ IdString Arch::archArgsToId(ArchArgs args) const return id("lfe5u_45f"); if (args.type == ArchArgs::LFE5U_85F) return id("lfe5u_85f"); + if (args.type == ArchArgs::LFE5UM_25F) + return id("lfe5um_25f"); + if (args.type == ArchArgs::LFE5UM_45F) + return id("lfe5um_45f"); + if (args.type == ArchArgs::LFE5UM_85F) + return id("lfe5um_85f"); + if (args.type == ArchArgs::LFE5UM5G_25F) + return id("lfe5um5g_25f"); + if (args.type == ArchArgs::LFE5UM5G_45F) + return id("lfe5um5g_45f"); + if (args.type == ArchArgs::LFE5UM5G_85F) + return id("lfe5um5g_85f"); return IdString(); } diff --git a/ecp5/arch.h b/ecp5/arch.h index 9eac3c9f..35c8df19 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -392,6 +392,12 @@ struct ArchArgs LFE5U_25F, LFE5U_45F, LFE5U_85F, + LFE5UM_25F, + LFE5UM_45F, + LFE5UM_85F, + LFE5UM5G_25F, + LFE5UM5G_45F, + LFE5UM5G_85F, } type = NONE; std::string package; int speed = 6; diff --git a/ecp5/bitstream.cc b/ecp5/bitstream.cc index 79a6e5f5..7f4e8052 100644 --- a/ecp5/bitstream.cc +++ b/ecp5/bitstream.cc @@ -279,6 +279,37 @@ std::vector get_bram_tiles(Context *ctx, BelId bel) return tiles; } +void fix_tile_names(Context *ctx, ChipConfig &cc) { + // Remove the V prefix/suffix on certain tiles if device is a SERDES variant + if (ctx->args.type == ArchArgs::LFE5UM_25F || ctx->args.type == ArchArgs::LFE5UM_45F || ctx->args.type == ArchArgs::LFE5UM_85F || + ctx->args.type == ArchArgs::LFE5UM5G_25F || ctx->args.type == ArchArgs::LFE5UM5G_45F || ctx->args.type == ArchArgs::LFE5UM5G_85F) { + std::map tiletype_xform; + for (const auto &tile : cc.tiles) { + std::string newname = tile.first; + auto vcib = tile.first.find("VCIB"); + if (vcib != std::string::npos) { + // Remove the V + newname.erase(vcib); + tiletype_xform[tile.first] = newname; + } else if (tile.first.back() == 'V') { + // BMID_0V or BMID_2V + if (tile.first.at(tile.first.size() - 2) == '0') { + newname.at(tile.first.size() - 1) = 'H'; + tiletype_xform[tile.first] = newname; + } else if (tile.first.at(tile.first.size() - 2) == '2') { + newname.pop_back(); + tiletype_xform[tile.first] = newname; + } + } + } + // Apply the name changes + for (auto xform : tiletype_xform) { + cc.tiles[xform.second] = cc.tiles.at(xform.first); + cc.tiles.erase(xform.first); + } + } +} + void write_bitstream(Context *ctx, std::string base_config_file, std::string text_config_file) { ChipConfig cc; @@ -588,7 +619,8 @@ void write_bitstream(Context *ctx, std::string base_config_file, std::string tex NPNR_ASSERT_FALSE("unsupported cell type"); } } - + // Fixup tile names + fix_tile_names(ctx, cc); // Configure chip if (!text_config_file.empty()) { std::ofstream out_config(text_config_file); diff --git a/ecp5/main.cc b/ecp5/main.cc index 5ad5a9bf..e71b0983 100644 --- a/ecp5/main.cc +++ b/ecp5/main.cc @@ -50,6 +50,12 @@ po::options_description ECP5CommandHandler::getArchOptions() specific.add_options()("25k", "set device type to LFE5U-25F"); specific.add_options()("45k", "set device type to LFE5U-45F"); specific.add_options()("85k", "set device type to LFE5U-85F"); + specific.add_options()("um-25k", "set device type to LFE5UM-25F"); + specific.add_options()("um-45k", "set device type to LFE5UM-45F"); + specific.add_options()("um-85k", "set device type to LFE5UM-85F"); + specific.add_options()("um5g-25k", "set device type to LFE5UM5G-25F"); + specific.add_options()("um5g-45k", "set device type to LFE5UM5G-45F"); + specific.add_options()("um5g-85k", "set device type to LFE5UM5G-85F"); specific.add_options()("package", po::value(), "select device package (defaults to CABGA381)"); specific.add_options()("basecfg", po::value(), "base chip configuration in Trellis text format"); specific.add_options()("textcfg", po::value(), "textual configuration in Trellis format to write"); @@ -84,6 +90,18 @@ std::unique_ptr ECP5CommandHandler::createContext() chipArgs.type = ArchArgs::LFE5U_45F; if (vm.count("85k")) chipArgs.type = ArchArgs::LFE5U_85F; + if (vm.count("um-25k")) + chipArgs.type = ArchArgs::LFE5UM_25F; + if (vm.count("um-45k")) + chipArgs.type = ArchArgs::LFE5UM_45F; + if (vm.count("um-85k")) + chipArgs.type = ArchArgs::LFE5UM_85F; + if (vm.count("um5g-25k")) + chipArgs.type = ArchArgs::LFE5UM5G_25F; + if (vm.count("um5g-45k")) + chipArgs.type = ArchArgs::LFE5UM5G_45F; + if (vm.count("um5g-85k")) + chipArgs.type = ArchArgs::LFE5UM5G_85F; if (vm.count("package")) chipArgs.package = vm["package"].as(); else -- cgit v1.2.3