aboutsummaryrefslogtreecommitdiffstats
path: root/ice40
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-08-08 20:14:18 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-08-08 20:14:18 +0200
commit61bce47f3cb7b4adf1d5292b3c431ca4048ad038 (patch)
tree18ff4129f05a457f0afaf8edcef90fe73252ad24 /ice40
parentb326b03a5261a824f428fe0811a5376c8758b929 (diff)
downloadnextpnr-61bce47f3cb7b4adf1d5292b3c431ca4048ad038.tar.gz
nextpnr-61bce47f3cb7b4adf1d5292b3c431ca4048ad038.tar.bz2
nextpnr-61bce47f3cb7b4adf1d5292b3c431ca4048ad038.zip
Use settings for json and pcf
Diffstat (limited to 'ice40')
-rw-r--r--ice40/main.cc5
-rw-r--r--ice40/pcf.cc3
-rw-r--r--ice40/pcf.h2
-rw-r--r--ice40/project.cc10
4 files changed, 12 insertions, 8 deletions
diff --git a/ice40/main.cc b/ice40/main.cc
index 2818a3ad..8bab360d 100644
--- a/ice40/main.cc
+++ b/ice40/main.cc
@@ -79,8 +79,9 @@ void Ice40CommandHandler::validate()
void Ice40CommandHandler::customAfterLoad(Context *ctx)
{
if (vm.count("pcf")) {
- std::ifstream pcf(vm["pcf"].as<std::string>());
- if (!apply_pcf(ctx, pcf))
+ std::string filename = vm["pcf"].as<std::string>();
+ std::ifstream pcf(filename);
+ if (!apply_pcf(ctx, filename, pcf))
log_error("Loading PCF failed.\n");
}
}
diff --git a/ice40/pcf.cc b/ice40/pcf.cc
index 410fa1c9..d9fc4e68 100644
--- a/ice40/pcf.cc
+++ b/ice40/pcf.cc
@@ -27,7 +27,7 @@ NEXTPNR_NAMESPACE_BEGIN
// Read a w
// Apply PCF constraints to a pre-packing design
-bool apply_pcf(Context *ctx, std::istream &in)
+bool apply_pcf(Context *ctx, std::string filename, std::istream &in)
{
try {
if (!in)
@@ -66,6 +66,7 @@ bool apply_pcf(Context *ctx, std::istream &in)
log_error("unsupported pcf command '%s'\n", cmd.c_str());
}
}
+ ctx->settings.emplace(ctx->id("project/input/pcf"), filename);
return true;
} catch (log_execution_error_exception) {
return false;
diff --git a/ice40/pcf.h b/ice40/pcf.h
index 315f6270..ecc81e59 100644
--- a/ice40/pcf.h
+++ b/ice40/pcf.h
@@ -27,7 +27,7 @@
NEXTPNR_NAMESPACE_BEGIN
// Apply PCF constraints to a pre-packing design
-bool apply_pcf(Context *ctx, std::istream &in);
+bool apply_pcf(Context *ctx, std::string filename, std::istream &in);
NEXTPNR_NAMESPACE_END
diff --git a/ice40/project.cc b/ice40/project.cc
index d1f1674a..8ca10e36 100644
--- a/ice40/project.cc
+++ b/ice40/project.cc
@@ -25,11 +25,13 @@
NEXTPNR_NAMESPACE_BEGIN
-void ProjectHandler::saveArch(Context *ctx, pt::ptree &root)
+void ProjectHandler::saveArch(Context *ctx, pt::ptree &root, std::string path)
{
root.put("project.arch.package", ctx->archArgs().package);
- // if(!pcfFilename.empty())
- // root.put("project.input.pcf", pcfFilename);
+ if (ctx->settings.find(ctx->id("project/input/pcf")) != ctx->settings.end()) {
+ std::string fn = ctx->settings[ctx->id("project/input/pcf")];
+ root.put("project.input.pcf", make_relative(fn, path).string());
+ }
}
std::unique_ptr<Context> ProjectHandler::createContext(pt::ptree &root)
@@ -64,7 +66,7 @@ void ProjectHandler::loadArch(Context *ctx, pt::ptree &root, std::string path)
auto input = root.get_child("project").get_child("input");
boost::filesystem::path pcf = boost::filesystem::path(path) / input.get<std::string>("pcf");
std::ifstream f(pcf.string());
- if (!apply_pcf(ctx, f))
+ if (!apply_pcf(ctx, input.get<std::string>("pcf"), f))
log_error("Loading PCF failed.\n");
}