Skip to content

Commit

Permalink
Start adding infrastructure for reading bitstream
Browse files Browse the repository at this point in the history
  • Loading branch information
mmicko committed Dec 18, 2024
1 parent 7f98c33 commit de2d551
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions himbaechel/uarch/gatemate/bitstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,12 @@ void GateMateImpl::write_bitstream(const std::string &device, const std::string
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
9 changes: 9 additions & 0 deletions himbaechel/uarch/gatemate/gatemate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
GateMateArch() : HimbaechelArch("gatemate") {};
Expand Down
3 changes: 3 additions & 0 deletions himbaechel/uarch/gatemate/gatemate.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct GateMateImpl : HimbaechelAPI
void init_database(Arch *arch) override;

void init(Context *ctx) override;
void setupArchContext() override;

void pack() override;

Expand All @@ -46,6 +47,8 @@ struct GateMateImpl : HimbaechelAPI
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);
bool read_bitstream(const std::string &device, const std::string &filename);

void parse_ccf(const std::string &filename);
};

Expand Down

0 comments on commit de2d551

Please sign in to comment.