2018-06-13 18:30:15 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Clifford Wolf <clifford@clifford.at>
|
2018-06-17 17:49:57 +08:00
|
|
|
* Copyright (C) 2018 David Shah <david@symbioticeda.com>
|
2018-06-13 18:30:15 +08:00
|
|
|
*
|
|
|
|
* 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 "pcf.h"
|
|
|
|
#include <sstream>
|
|
|
|
#include "log.h"
|
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
// Read a w
|
|
|
|
|
|
|
|
// Apply PCF constraints to a pre-packing design
|
2018-06-18 20:06:37 +08:00
|
|
|
void apply_pcf(Context *ctx, std::istream &in)
|
2018-06-13 18:30:15 +08:00
|
|
|
{
|
|
|
|
if (!in)
|
|
|
|
log_error("failed to open PCF file");
|
|
|
|
std::string line;
|
|
|
|
while (std::getline(in, line)) {
|
|
|
|
size_t cstart = line.find("#");
|
|
|
|
if (cstart != std::string::npos)
|
|
|
|
line = line.substr(0, cstart);
|
|
|
|
std::stringstream ss(line);
|
|
|
|
std::vector<std::string> words;
|
|
|
|
std::string tmp;
|
|
|
|
while (ss >> tmp)
|
|
|
|
words.push_back(tmp);
|
|
|
|
if (words.size() == 0)
|
|
|
|
continue;
|
|
|
|
std::string cmd = words.at(0);
|
|
|
|
if (cmd == "set_io") {
|
|
|
|
size_t args_end = 1;
|
|
|
|
while (args_end < words.size() && words.at(args_end).at(0) == '-')
|
|
|
|
args_end++;
|
|
|
|
std::string cell = words.at(args_end);
|
|
|
|
std::string pin = words.at(args_end + 1);
|
2018-06-18 20:06:37 +08:00
|
|
|
auto fnd_cell = ctx->cells.find(cell);
|
|
|
|
if (fnd_cell == ctx->cells.end()) {
|
2018-06-13 18:30:15 +08:00
|
|
|
log_warning("unmatched pcf constraint %s\n", cell.c_str());
|
|
|
|
} else {
|
2018-06-18 20:06:37 +08:00
|
|
|
BelId pin_bel = ctx->getPackagePinBel(pin);
|
2018-06-13 18:30:15 +08:00
|
|
|
if (pin_bel == BelId())
|
|
|
|
log_error("package does not have a pin named %s\n",
|
|
|
|
pin.c_str());
|
|
|
|
fnd_cell->second->attrs["BEL"] =
|
2018-06-18 20:06:37 +08:00
|
|
|
ctx->getBelName(pin_bel).str();
|
2018-06-13 18:30:15 +08:00
|
|
|
log_info("constrained '%s' to bel '%s'\n", cell.c_str(),
|
|
|
|
fnd_cell->second->attrs["BEL"].c_str());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log_error("unsupported pcf command '%s'\n", cmd.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_END
|