Start adding infrastructure for reading bitstream

This commit is contained in:
Miodrag Milanovic 2024-12-18 10:44:25 +01:00
parent 7f98c33d6b
commit de2d551035
3 changed files with 20 additions and 0 deletions

View File

@ -148,4 +148,12 @@ void GateMateImpl::write_bitstream(const std::string &device, const std::string
be.write_bitstream(); be.write_bitstream();
} }
bool GateMateImpl::read_bitstream(const std::string &device, const std::string &filename)
{
std::ifstream in(filename);
if (!in)
log_error("failed to open file %s for reading (%s)\n", filename.c_str(), strerror(errno));
return false;
}
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -56,6 +56,15 @@ void GateMateImpl::postRoute()
} }
} }
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");
}
}
struct GateMateArch : HimbaechelArch struct GateMateArch : HimbaechelArch
{ {
GateMateArch() : HimbaechelArch("gatemate") {}; GateMateArch() : HimbaechelArch("gatemate") {};

View File

@ -36,6 +36,7 @@ struct GateMateImpl : HimbaechelAPI
void init_database(Arch *arch) override; void init_database(Arch *arch) override;
void init(Context *ctx) override; void init(Context *ctx) override;
void setupArchContext() override;
void pack() override; void pack() override;
@ -46,6 +47,8 @@ struct GateMateImpl : HimbaechelAPI
void drawBel(std::vector<GraphicElement> &g, GraphicElement::style_t style, IdString bel_type, Loc loc) override; void drawBel(std::vector<GraphicElement> &g, GraphicElement::style_t style, IdString bel_type, Loc loc) override;
void write_bitstream(const std::string &device, const std::string &filename); void write_bitstream(const std::string &device, const std::string &filename);
bool read_bitstream(const std::string &device, const std::string &filename);
void parse_ccf(const std::string &filename); void parse_ccf(const std::string &filename);
}; };