diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2018-08-06 19:32:17 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2018-08-06 19:32:17 +0200 |
commit | fffaaa613f498cb83f8d885e5a8b75dc41a9c157 (patch) | |
tree | 325deb17a71813a6316b5ecec253a4e3155d4733 /ice40 | |
parent | 9510c444c93fdb8923d77651562fb698e59dea5f (diff) | |
download | nextpnr-fffaaa613f498cb83f8d885e5a8b75dc41a9c157.tar.gz nextpnr-fffaaa613f498cb83f8d885e5a8b75dc41a9c157.tar.bz2 nextpnr-fffaaa613f498cb83f8d885e5a8b75dc41a9c157.zip |
Added project loader
Diffstat (limited to 'ice40')
-rw-r--r-- | ice40/arch.h | 1 | ||||
-rw-r--r-- | ice40/project.cc | 71 |
2 files changed, 72 insertions, 0 deletions
diff --git a/ice40/arch.h b/ice40/arch.h index d3076416..bc968b74 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -411,6 +411,7 @@ struct Arch : BaseCtx std::string getChipName() const; IdString archId() const { return id("ice40"); } + ArchArgs archArgs() const { return args; } IdString archArgsToId(ArchArgs args) const; IdString belTypeToId(BelType type) const; diff --git a/ice40/project.cc b/ice40/project.cc new file mode 100644 index 00000000..53401d63 --- /dev/null +++ b/ice40/project.cc @@ -0,0 +1,71 @@ +/* + * nextpnr -- Next Generation Place and Route + * + * Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com> + * + * 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. + * + */ + +#include <boost/filesystem/convenience.hpp> +#include "project.h" +#include "log.h" +#include <fstream> +#include "pcf.h" + +NEXTPNR_NAMESPACE_BEGIN + +void ProjectHandler::saveArch(Context *ctx, pt::ptree &root) +{ + root.put("project.arch.package", ctx->archArgs().package); + // if(!pcfFilename.empty()) + // root.put("project.input.pcf", pcfFilename); +} + +std::unique_ptr<Context> ProjectHandler::createContext(pt::ptree &root) +{ + ArchArgs chipArgs; + std::string arch_type = root.get<std::string>("project.arch.type"); + if (arch_type == "lp384") { + chipArgs.type = ArchArgs::LP384; + } + if (arch_type == "lp1k") { + chipArgs.type = ArchArgs::LP1K; + } + if (arch_type == "lp8k") { + chipArgs.type = ArchArgs::LP8K; + } + if (arch_type == "hx1k") { + chipArgs.type = ArchArgs::HX1K; + } + if (arch_type == "hx8k") { + chipArgs.type = ArchArgs::HX8K; + } + if (arch_type == "up5k") { + chipArgs.type = ArchArgs::UP5K; + } + chipArgs.package = root.get<std::string>("project.arch.package"); + + return std::unique_ptr<Context>(new Context(chipArgs)); +} + +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)) + log_error("Loading PCF failed.\n"); +} + +NEXTPNR_NAMESPACE_END |