nextpnr/xc7/main.cc

118 lines
3.7 KiB
C++
Raw Normal View History

2018-08-12 05:35:49 +08:00
/*
* nextpnr -- Next Generation Place and Route
*
* Copyright (C) 2018 Clifford Wolf <clifford@symbioticeda.com>
* 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.
*
*/
#ifdef MAIN_EXECUTABLE
#include <fstream>
#include "command.h"
#include "design_utils.h"
#include "jsonparse.h"
#include "log.h"
#include "pcf.h"
#include "timing.h"
2018-08-13 10:07:33 +08:00
#include "xdl.h"
2018-08-12 05:35:49 +08:00
USING_NEXTPNR_NAMESPACE
2018-08-12 06:00:31 +08:00
class Xc7CommandHandler : public CommandHandler
2018-08-12 05:35:49 +08:00
{
public:
2018-08-12 06:00:31 +08:00
Xc7CommandHandler(int argc, char **argv);
virtual ~Xc7CommandHandler(){};
2018-08-12 05:35:49 +08:00
std::unique_ptr<Context> createContext() override;
void setupArchContext(Context *ctx) override;
void validate() override;
void customAfterLoad(Context *ctx) override;
2018-08-13 10:07:33 +08:00
void customBitstream(Context *ctx) override;
2018-08-12 05:35:49 +08:00
protected:
po::options_description getArchOptions();
};
2018-08-12 06:00:31 +08:00
Xc7CommandHandler::Xc7CommandHandler(int argc, char **argv) : CommandHandler(argc, argv) {}
2018-08-12 05:35:49 +08:00
2018-08-12 06:00:31 +08:00
po::options_description Xc7CommandHandler::getArchOptions()
2018-08-12 05:35:49 +08:00
{
po::options_description specific("Architecture specific options");
2018-08-12 06:00:31 +08:00
specific.add_options()("xc7z020", "set device type to xc7z020");
2018-11-04 06:18:26 +08:00
// specific.add_options()("package", po::value<std::string>(), "set device package");
2018-08-12 07:01:08 +08:00
specific.add_options()("pcf", po::value<std::string>(), "PCF constraints file to ingest");
2018-08-12 06:00:31 +08:00
specific.add_options()("xdl", po::value<std::string>(), "XDL file to write");
2018-11-04 06:18:26 +08:00
// specific.add_options()("tmfuzz", "run path delay estimate fuzzer");
2018-08-12 05:35:49 +08:00
return specific;
}
2018-08-12 06:00:31 +08:00
void Xc7CommandHandler::validate()
2018-08-12 05:35:49 +08:00
{
conflicting_options(vm, "read", "json");
2018-11-04 06:18:26 +08:00
// if ((vm.count("lp384") + vm.count("lp1k") + vm.count("lp8k") + vm.count("hx1k") + vm.count("hx8k") +
// vm.count("up5k")) > 1)
// log_error("Only one device type can be set\n");
2018-08-12 05:35:49 +08:00
}
2018-08-12 06:00:31 +08:00
void Xc7CommandHandler::customAfterLoad(Context *ctx)
2018-08-12 05:35:49 +08:00
{
2018-08-12 07:01:08 +08:00
if (vm.count("pcf")) {
2018-11-04 06:17:53 +08:00
std::string filename = vm["pcf"].as<std::string>();
std::ifstream pcf(filename);
if (!apply_pcf(ctx, filename, pcf))
log_error("Loading PCF failed.\n");
2018-08-12 07:01:08 +08:00
}
2018-08-12 05:35:49 +08:00
}
2018-08-13 10:07:33 +08:00
void Xc7CommandHandler::customBitstream(Context *ctx)
{
if (vm.count("xdl")) {
std::string filename = vm["xdl"].as<std::string>();
std::ofstream f(filename);
write_xdl(ctx, f);
}
}
2018-08-12 06:00:31 +08:00
void Xc7CommandHandler::setupArchContext(Context *ctx)
2018-08-12 05:35:49 +08:00
{
2018-11-04 06:18:26 +08:00
// if (vm.count("tmfuzz"))
// ice40DelayFuzzerMain(ctx);
2018-08-12 05:35:49 +08:00
}
2018-08-12 06:00:31 +08:00
std::unique_ptr<Context> Xc7CommandHandler::createContext()
2018-08-12 05:35:49 +08:00
{
2018-08-12 06:53:55 +08:00
if (vm.count("z020")) {
chipArgs.type = ArchArgs::Z020;
chipArgs.package = "clg400";
2018-08-12 05:35:49 +08:00
}
if (chipArgs.type == ArchArgs::NONE) {
2018-08-12 06:53:55 +08:00
chipArgs.type = ArchArgs::Z020;
chipArgs.package = "clg400";
2018-08-12 05:35:49 +08:00
}
if (vm.count("package"))
chipArgs.package = vm["package"].as<std::string>();
2018-08-12 05:35:49 +08:00
return std::unique_ptr<Context>(new Context(chipArgs));
}
int main(int argc, char *argv[])
{
2018-08-12 06:00:31 +08:00
Xc7CommandHandler handler(argc, argv);
2018-08-12 05:35:49 +08:00
return handler.exec();
}
#endif