Added return code to json parsing and pcf reading
This commit is contained in:
parent
8fac26c2b7
commit
c33a039ac3
@ -797,8 +797,9 @@ void json_import(Context *ctx, string modname, JsonNode *node)
|
|||||||
}
|
}
|
||||||
}; // End Namespace JsonParser
|
}; // End Namespace JsonParser
|
||||||
|
|
||||||
void parse_json_file(std::istream &f, std::string &filename, Context *ctx)
|
bool parse_json_file(std::istream &f, std::string &filename, Context *ctx)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
using namespace JsonParser;
|
using namespace JsonParser;
|
||||||
|
|
||||||
JsonNode root(f);
|
JsonNode root(f);
|
||||||
@ -818,6 +819,10 @@ void parse_json_file(std::istream &f, std::string &filename, Context *ctx)
|
|||||||
|
|
||||||
log_info("Checksum: 0x%08x\n", ctx->checksum());
|
log_info("Checksum: 0x%08x\n", ctx->checksum());
|
||||||
log_break();
|
log_break();
|
||||||
|
return true;
|
||||||
|
} catch (log_execution_error_exception) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
extern void parse_json_file(std::istream &, std::string &, Context *);
|
extern bool parse_json_file(std::istream &, std::string &, Context *);
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
|
@ -20,7 +20,8 @@ void Worker::parsejson(const std::string &filename)
|
|||||||
std::string fn = filename;
|
std::string fn = filename;
|
||||||
std::ifstream f(fn);
|
std::ifstream f(fn);
|
||||||
try {
|
try {
|
||||||
parse_json_file(f, fn, ctx);
|
if (!parse_json_file(f, fn, ctx))
|
||||||
|
log_error("Loading design failed.\n");
|
||||||
if (!pack_design(ctx))
|
if (!pack_design(ctx))
|
||||||
log_error("Packing design failed.\n");
|
log_error("Packing design failed.\n");
|
||||||
double freq = 50e6;
|
double freq = 50e6;
|
||||||
@ -33,7 +34,6 @@ void Worker::parsejson(const std::string &filename)
|
|||||||
log_error("Routing design failed.\n");
|
log_error("Routing design failed.\n");
|
||||||
Q_EMIT log("done");
|
Q_EMIT log("done");
|
||||||
} catch (log_execution_error_exception) {
|
} catch (log_execution_error_exception) {
|
||||||
Q_EMIT log("failed");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,11 +288,13 @@ int main(int argc, char *argv[])
|
|||||||
if (vm.count("json")) {
|
if (vm.count("json")) {
|
||||||
std::string filename = vm["json"].as<std::string>();
|
std::string filename = vm["json"].as<std::string>();
|
||||||
std::ifstream f(filename);
|
std::ifstream f(filename);
|
||||||
parse_json_file(f, filename, &ctx);
|
if (!parse_json_file(f, filename, &ctx))
|
||||||
|
log_error("Loading design failed.\n");
|
||||||
|
|
||||||
if (vm.count("pcf")) {
|
if (vm.count("pcf")) {
|
||||||
std::ifstream pcf(vm["pcf"].as<std::string>());
|
std::ifstream pcf(vm["pcf"].as<std::string>());
|
||||||
apply_pcf(&ctx, pcf);
|
if (!apply_pcf(&ctx, pcf))
|
||||||
|
log_error("Loading PCF failed.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pack_design(&ctx) && !ctx.force)
|
if (!pack_design(&ctx) && !ctx.force)
|
||||||
|
13
ice40/pcf.cc
13
ice40/pcf.cc
@ -27,8 +27,9 @@ NEXTPNR_NAMESPACE_BEGIN
|
|||||||
// Read a w
|
// Read a w
|
||||||
|
|
||||||
// Apply PCF constraints to a pre-packing design
|
// Apply PCF constraints to a pre-packing design
|
||||||
void apply_pcf(Context *ctx, std::istream &in)
|
bool apply_pcf(Context *ctx, std::istream &in)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
if (!in)
|
if (!in)
|
||||||
log_error("failed to open PCF file");
|
log_error("failed to open PCF file");
|
||||||
std::string line;
|
std::string line;
|
||||||
@ -46,7 +47,8 @@ void apply_pcf(Context *ctx, std::istream &in)
|
|||||||
std::string cmd = words.at(0);
|
std::string cmd = words.at(0);
|
||||||
if (cmd == "set_io") {
|
if (cmd == "set_io") {
|
||||||
size_t args_end = 1;
|
size_t args_end = 1;
|
||||||
while (args_end < words.size() && words.at(args_end).at(0) == '-')
|
while (args_end < words.size() &&
|
||||||
|
words.at(args_end).at(0) == '-')
|
||||||
args_end++;
|
args_end++;
|
||||||
std::string cell = words.at(args_end);
|
std::string cell = words.at(args_end);
|
||||||
std::string pin = words.at(args_end + 1);
|
std::string pin = words.at(args_end + 1);
|
||||||
@ -58,7 +60,8 @@ void apply_pcf(Context *ctx, std::istream &in)
|
|||||||
if (pin_bel == BelId())
|
if (pin_bel == BelId())
|
||||||
log_error("package does not have a pin named %s\n",
|
log_error("package does not have a pin named %s\n",
|
||||||
pin.c_str());
|
pin.c_str());
|
||||||
fnd_cell->second->attrs["BEL"] = ctx->getBelName(pin_bel).str();
|
fnd_cell->second->attrs["BEL"] =
|
||||||
|
ctx->getBelName(pin_bel).str();
|
||||||
log_info("constrained '%s' to bel '%s'\n", cell.c_str(),
|
log_info("constrained '%s' to bel '%s'\n", cell.c_str(),
|
||||||
fnd_cell->second->attrs["BEL"].c_str());
|
fnd_cell->second->attrs["BEL"].c_str());
|
||||||
}
|
}
|
||||||
@ -66,6 +69,10 @@ void apply_pcf(Context *ctx, std::istream &in)
|
|||||||
log_error("unsupported pcf command '%s'\n", cmd.c_str());
|
log_error("unsupported pcf command '%s'\n", cmd.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
} catch (log_execution_error_exception) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
// Apply PCF constraints to a pre-packing design
|
// Apply PCF constraints to a pre-packing design
|
||||||
void apply_pcf(Context *ctx, std::istream &in);
|
bool apply_pcf(Context *ctx, std::istream &in);
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user