nextpnr/himbaechel/uarch/gatemate/gatemate.cc

82 lines
2.5 KiB
C++
Raw Normal View History

2024-12-10 22:48:07 +08:00
/*
* nextpnr -- Next Generation Place and Route
*
* Copyright (C) 2024 The Project Peppercorn Authors.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
2024-12-16 23:58:46 +08:00
#include "gatemate.h"
2024-12-10 22:48:07 +08:00
#define GEN_INIT_CONSTIDS
#define HIMBAECHEL_CONSTIDS "uarch/gatemate/constids.inc"
#include "himbaechel_constids.h"
NEXTPNR_NAMESPACE_BEGIN
GateMateImpl::~GateMateImpl() {};
void GateMateImpl::init_database(Arch *arch)
{
const ArchArgs &args = arch->args;
init_uarch_constids(arch);
arch->load_chipdb(stringf("gatemate/chipdb-%s.bin", args.device.c_str()));
2024-12-17 02:21:32 +08:00
arch->set_package("FBGA324");
2024-12-10 22:48:07 +08:00
arch->set_speed_grade("DEFAULT");
}
2024-12-18 15:56:54 +08:00
void GateMateImpl::init(Context *ctx) { HimbaechelAPI::init(ctx); }
2024-12-16 18:19:56 +08:00
delay_t GateMateImpl::estimateDelay(WireId src, WireId dst) const
{
int sx, sy, dx, dy;
tile_xy(ctx->chip_info, src.tile, sx, sy);
tile_xy(ctx->chip_info, dst.tile, dx, dy);
2024-12-16 23:58:46 +08:00
return 100 * (std::abs(dx - sx) / 4 + std::abs(dy - sy) / 4 + 2);
2024-12-16 18:19:56 +08:00
}
void GateMateImpl::postRoute()
{
const ArchArgs &args = ctx->args;
if (args.options.count("out")) {
2024-12-18 15:56:54 +08:00
write_bitstream(args.device, args.options.at("out"));
2024-12-16 18:19:56 +08:00
}
}
void GateMateImpl::setupArchContext()
{
const ArchArgs &args = ctx->args;
if (args.options.count("read")) {
if (!read_bitstream(args.device, args.options.at("read")))
log_error("Loading bitstream failed.\n");
}
}
2024-12-10 22:48:07 +08:00
struct GateMateArch : HimbaechelArch
{
GateMateArch() : HimbaechelArch("gatemate") {};
bool match_device(const std::string &device) override
{
return device.size() > 6 && device.substr(0, 6) == "CCGM1A";
}
std::unique_ptr<HimbaechelAPI> create(const std::string &device, const dict<std::string, std::string> &args)
{
return std::make_unique<GateMateImpl>();
}
} gateMateArch;
NEXTPNR_NAMESPACE_END