2018-07-09 18:02:31 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 David Shah <david@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 "bitstream.h"
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include <streambuf>
|
|
|
|
|
2018-08-01 21:58:38 +08:00
|
|
|
#include "config.h"
|
2018-07-24 18:22:57 +08:00
|
|
|
#include "io.h"
|
2018-07-09 18:02:31 +08:00
|
|
|
#include "log.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
2018-07-11 20:27:15 +08:00
|
|
|
#define fmt_str(x) (static_cast<const std::ostringstream &>(std::ostringstream() << x).str())
|
2018-07-10 17:24:30 +08:00
|
|
|
|
2018-07-09 18:02:31 +08:00
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
// Convert an absolute wire name to a relative Trellis one
|
|
|
|
static std::string get_trellis_wirename(Context *ctx, Location loc, WireId wire)
|
|
|
|
{
|
|
|
|
std::string basename = ctx->locInfo(wire)->wire_data[wire.index].name.get();
|
|
|
|
std::string prefix2 = basename.substr(0, 2);
|
|
|
|
if (prefix2 == "G_" || prefix2 == "L_" || prefix2 == "R_")
|
|
|
|
return basename;
|
|
|
|
if (loc == wire.location)
|
|
|
|
return basename;
|
|
|
|
std::string rel_prefix;
|
|
|
|
if (wire.location.y < loc.y)
|
2018-08-01 21:58:38 +08:00
|
|
|
rel_prefix += "N" + std::to_string(loc.y - wire.location.y);
|
2018-07-09 18:02:31 +08:00
|
|
|
if (wire.location.y > loc.y)
|
2018-08-01 21:58:38 +08:00
|
|
|
rel_prefix += "S" + std::to_string(wire.location.y - loc.y);
|
2018-07-09 18:02:31 +08:00
|
|
|
if (wire.location.x > loc.x)
|
2018-08-01 21:58:38 +08:00
|
|
|
rel_prefix += "E" + std::to_string(wire.location.x - loc.x);
|
2018-07-09 18:02:31 +08:00
|
|
|
if (wire.location.x < loc.x)
|
2018-08-01 21:58:38 +08:00
|
|
|
rel_prefix += "W" + std::to_string(loc.x - wire.location.x);
|
2018-07-09 18:02:31 +08:00
|
|
|
return rel_prefix + "_" + basename;
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::vector<bool> int_to_bitvector(int val, int size)
|
|
|
|
{
|
|
|
|
std::vector<bool> bv;
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
bv.push_back((val & (1 << i)) != 0);
|
|
|
|
}
|
|
|
|
return bv;
|
|
|
|
}
|
|
|
|
|
2018-07-10 17:24:30 +08:00
|
|
|
// Get the PIO tile corresponding to a PIO bel
|
2018-08-01 21:58:38 +08:00
|
|
|
static std::string get_pio_tile(Context *ctx, BelId bel)
|
2018-07-10 17:24:30 +08:00
|
|
|
{
|
|
|
|
static const std::set<std::string> pioabcd_l = {"PICL1", "PICL1_DQS0", "PICL1_DQS3"};
|
|
|
|
static const std::set<std::string> pioabcd_r = {"PICR1", "PICR1_DQS0", "PICR1_DQS3"};
|
|
|
|
static const std::set<std::string> pioa_b = {"PICB0", "EFB0_PICB0", "EFB2_PICB0"};
|
|
|
|
static const std::set<std::string> piob_b = {"PICB1", "EFB1_PICB1", "EFB3_PICB1"};
|
|
|
|
|
|
|
|
std::string pio_name = ctx->locInfo(bel)->bel_data[bel.index].name.get();
|
|
|
|
if (bel.location.y == 0) {
|
|
|
|
if (pio_name == "PIOA") {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(0, bel.location.x, "PIOT0");
|
2018-07-10 17:24:30 +08:00
|
|
|
} else if (pio_name == "PIOB") {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(0, bel.location.x + 1, "PIOT1");
|
2018-07-10 17:24:30 +08:00
|
|
|
} else {
|
|
|
|
NPNR_ASSERT_FALSE("bad PIO location");
|
|
|
|
}
|
|
|
|
} else if (bel.location.y == ctx->chip_info->height - 1) {
|
|
|
|
if (pio_name == "PIOA") {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(bel.location.y, bel.location.x, pioa_b);
|
2018-07-10 17:24:30 +08:00
|
|
|
} else if (pio_name == "PIOB") {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(bel.location.y, bel.location.x + 1, piob_b);
|
2018-07-10 17:24:30 +08:00
|
|
|
} else {
|
|
|
|
NPNR_ASSERT_FALSE("bad PIO location");
|
|
|
|
}
|
|
|
|
} else if (bel.location.x == 0) {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(bel.location.y + 1, bel.location.x, pioabcd_l);
|
2018-07-10 17:24:30 +08:00
|
|
|
} else if (bel.location.x == ctx->chip_info->width - 1) {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(bel.location.y + 1, bel.location.x, pioabcd_r);
|
2018-07-10 17:24:30 +08:00
|
|
|
} else {
|
|
|
|
NPNR_ASSERT_FALSE("bad PIO location");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the PIC tile corresponding to a PIO bel
|
2018-08-01 21:58:38 +08:00
|
|
|
static std::string get_pic_tile(Context *ctx, BelId bel)
|
2018-07-10 17:24:30 +08:00
|
|
|
{
|
|
|
|
static const std::set<std::string> picab_l = {"PICL0", "PICL0_DQS2"};
|
|
|
|
static const std::set<std::string> piccd_l = {"PICL2", "PICL2_DQS1", "MIB_CIB_LR"};
|
|
|
|
static const std::set<std::string> picab_r = {"PICR0", "PICR0_DQS2"};
|
|
|
|
static const std::set<std::string> piccd_r = {"PICR2", "PICR2_DQS1", "MIB_CIB_LR_A"};
|
|
|
|
|
|
|
|
static const std::set<std::string> pica_b = {"PICB0", "EFB0_PICB0", "EFB2_PICB0"};
|
|
|
|
static const std::set<std::string> picb_b = {"PICB1", "EFB1_PICB1", "EFB3_PICB1"};
|
|
|
|
|
|
|
|
std::string pio_name = ctx->locInfo(bel)->bel_data[bel.index].name.get();
|
|
|
|
if (bel.location.y == 0) {
|
|
|
|
if (pio_name == "PIOA") {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(1, bel.location.x, "PICT0");
|
2018-07-10 17:24:30 +08:00
|
|
|
} else if (pio_name == "PIOB") {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(1, bel.location.x + 1, "PICT1");
|
2018-07-10 17:24:30 +08:00
|
|
|
} else {
|
|
|
|
NPNR_ASSERT_FALSE("bad PIO location");
|
|
|
|
}
|
|
|
|
} else if (bel.location.y == ctx->chip_info->height - 1) {
|
|
|
|
if (pio_name == "PIOA") {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(bel.location.y, bel.location.x, pica_b);
|
2018-07-10 17:24:30 +08:00
|
|
|
} else if (pio_name == "PIOB") {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(bel.location.y, bel.location.x + 1, picb_b);
|
2018-07-10 17:24:30 +08:00
|
|
|
} else {
|
|
|
|
NPNR_ASSERT_FALSE("bad PIO location");
|
|
|
|
}
|
|
|
|
} else if (bel.location.x == 0) {
|
|
|
|
if (pio_name == "PIOA" || pio_name == "PIOB") {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(bel.location.y, bel.location.x, picab_l);
|
2018-07-10 17:24:30 +08:00
|
|
|
} else if (pio_name == "PIOC" || pio_name == "PIOD") {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(bel.location.y + 2, bel.location.x, piccd_l);
|
2018-07-10 17:24:30 +08:00
|
|
|
} else {
|
|
|
|
NPNR_ASSERT_FALSE("bad PIO location");
|
|
|
|
}
|
|
|
|
} else if (bel.location.x == ctx->chip_info->width - 1) {
|
|
|
|
if (pio_name == "PIOA" || pio_name == "PIOB") {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(bel.location.y, bel.location.x, picab_r);
|
2018-07-10 17:24:30 +08:00
|
|
|
} else if (pio_name == "PIOC" || pio_name == "PIOD") {
|
2018-08-01 21:58:38 +08:00
|
|
|
return ctx->getTileByTypeAndLocation(bel.location.y + 2, bel.location.x, piccd_r);
|
2018-07-10 17:24:30 +08:00
|
|
|
} else {
|
|
|
|
NPNR_ASSERT_FALSE("bad PIO location");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
NPNR_ASSERT_FALSE("bad PIO location");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-01 21:58:38 +08:00
|
|
|
void write_bitstream(Context *ctx, std::string base_config_file, std::string text_config_file)
|
2018-07-09 18:02:31 +08:00
|
|
|
{
|
2018-08-01 21:58:38 +08:00
|
|
|
ChipConfig cc;
|
2018-07-10 17:24:30 +08:00
|
|
|
|
|
|
|
std::set<std::string> cib_tiles = {"CIB", "CIB_LR", "CIB_LR_S", "CIB_EFB0", "CIB_EFB1"};
|
|
|
|
|
2018-07-09 18:02:31 +08:00
|
|
|
if (!base_config_file.empty()) {
|
|
|
|
std::ifstream config_file(base_config_file);
|
|
|
|
if (!config_file) {
|
|
|
|
log_error("failed to open base config file '%s'\n", base_config_file.c_str());
|
|
|
|
}
|
2018-08-01 21:58:38 +08:00
|
|
|
config_file >> cc;
|
2018-07-09 18:02:31 +08:00
|
|
|
} else {
|
|
|
|
cc.chip_name = ctx->getChipName();
|
|
|
|
// TODO: .bit metadata
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add all set, configurable pips to the config
|
|
|
|
for (auto pip : ctx->getPips()) {
|
2018-08-05 22:32:12 +08:00
|
|
|
if (ctx->getBoundPipNet(pip) != nullptr) {
|
2018-07-27 00:48:07 +08:00
|
|
|
if (ctx->getPipClass(pip) == 0) { // ignore fixed pips
|
2018-08-01 21:58:38 +08:00
|
|
|
std::string tile = ctx->getPipTilename(pip);
|
2018-07-09 18:02:31 +08:00
|
|
|
std::string source = get_trellis_wirename(ctx, pip.location, ctx->getPipSrcWire(pip));
|
|
|
|
std::string sink = get_trellis_wirename(ctx, pip.location, ctx->getPipDstWire(pip));
|
2018-07-11 17:08:12 +08:00
|
|
|
cc.tiles[tile].add_arc(sink, source);
|
2018-07-09 18:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-24 18:22:57 +08:00
|
|
|
// Find bank voltages
|
|
|
|
std::unordered_map<int, IOVoltage> bankVcc;
|
2018-07-25 03:25:33 +08:00
|
|
|
std::unordered_map<int, bool> bankLvds;
|
|
|
|
|
2018-07-24 18:22:57 +08:00
|
|
|
for (auto &cell : ctx->cells) {
|
|
|
|
CellInfo *ci = cell.second.get();
|
|
|
|
if (ci->bel != BelId() && ci->type == ctx->id("TRELLIS_IO")) {
|
|
|
|
int bank = ctx->getPioBelBank(ci->bel);
|
2018-07-25 04:26:26 +08:00
|
|
|
std::string dir = str_or_default(ci->params, ctx->id("DIR"), "INPUT");
|
2018-07-24 18:22:57 +08:00
|
|
|
std::string iotype = str_or_default(ci->attrs, ctx->id("IO_TYPE"), "LVCMOS33");
|
2018-07-25 04:26:26 +08:00
|
|
|
|
|
|
|
if (dir != "INPUT") {
|
|
|
|
IOVoltage vcc = get_vccio(ioType_from_str(iotype));
|
|
|
|
if (bankVcc.find(bank) != bankVcc.end()) {
|
|
|
|
// TODO: strong and weak constraints
|
|
|
|
if (bankVcc[bank] != vcc) {
|
|
|
|
log_error("Error processing '%s': incompatible IO voltages %s and %s on bank %d.",
|
|
|
|
cell.first.c_str(ctx), iovoltage_to_str(bankVcc[bank]).c_str(),
|
|
|
|
iovoltage_to_str(vcc).c_str(), bank);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bankVcc[bank] = vcc;
|
2018-07-24 18:22:57 +08:00
|
|
|
}
|
|
|
|
}
|
2018-07-25 04:26:26 +08:00
|
|
|
|
2018-07-25 03:25:33 +08:00
|
|
|
if (iotype == "LVDS")
|
|
|
|
bankLvds[bank] = true;
|
2018-07-24 18:22:57 +08:00
|
|
|
}
|
|
|
|
}
|
2018-07-09 18:02:31 +08:00
|
|
|
|
2018-07-24 18:22:57 +08:00
|
|
|
// Set all bankref tiles to appropriate VccIO
|
2018-08-01 21:58:38 +08:00
|
|
|
for (int y = 0; y < ctx->getGridDimY(); y++) {
|
|
|
|
for (int x = 0; x < ctx->getGridDimX(); x++) {
|
|
|
|
auto tiles = ctx->getTilesAtLocation(y, x);
|
|
|
|
for (auto tile : tiles) {
|
|
|
|
std::string type = tile.second;
|
|
|
|
if (type.find("BANKREF") != std::string::npos && type != "BANKREF8") {
|
|
|
|
int bank = std::stoi(type.substr(7));
|
|
|
|
if (bankVcc.find(bank) != bankVcc.end())
|
|
|
|
cc.tiles[tile.first].add_enum("BANK.VCCIO", iovoltage_to_str(bankVcc[bank]));
|
|
|
|
if (bankLvds[bank]) {
|
|
|
|
cc.tiles[tile.first].add_enum("BANK.DIFF_REF", "ON");
|
|
|
|
cc.tiles[tile.first].add_enum("BANK.LVDSO", "ON");
|
|
|
|
}
|
|
|
|
}
|
2018-07-25 03:25:33 +08:00
|
|
|
}
|
2018-07-09 18:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Configure slices
|
|
|
|
for (auto &cell : ctx->cells) {
|
|
|
|
CellInfo *ci = cell.second.get();
|
|
|
|
if (ci->bel == BelId()) {
|
|
|
|
log_warning("found unplaced cell '%s' during bitstream gen\n", ci->name.c_str(ctx));
|
|
|
|
}
|
|
|
|
BelId bel = ci->bel;
|
|
|
|
if (ci->type == ctx->id("TRELLIS_SLICE")) {
|
2018-08-01 21:58:38 +08:00
|
|
|
std::string tname = ctx->getTileByTypeAndLocation(bel.location.y, bel.location.x, "PLC2");
|
2018-07-09 18:02:31 +08:00
|
|
|
std::string slice = ctx->locInfo(bel)->bel_data[bel.index].name.get();
|
|
|
|
int lut0_init = int_or_default(ci->params, ctx->id("LUT0_INITVAL"));
|
|
|
|
int lut1_init = int_or_default(ci->params, ctx->id("LUT1_INITVAL"));
|
|
|
|
cc.tiles[tname].add_word(slice + ".K0.INIT", int_to_bitvector(lut0_init, 16));
|
|
|
|
cc.tiles[tname].add_word(slice + ".K1.INIT", int_to_bitvector(lut1_init, 16));
|
2018-07-09 18:55:56 +08:00
|
|
|
cc.tiles[tname].add_enum(slice + ".MODE", str_or_default(ci->params, ctx->id("MODE"), "LOGIC"));
|
|
|
|
cc.tiles[tname].add_enum(slice + ".GSR", str_or_default(ci->params, ctx->id("GSR"), "ENABLED"));
|
|
|
|
cc.tiles[tname].add_enum(slice + ".REG0.SD", str_or_default(ci->params, ctx->id("REG0_SD"), "0"));
|
|
|
|
cc.tiles[tname].add_enum(slice + ".REG1.SD", str_or_default(ci->params, ctx->id("REG1_SD"), "0"));
|
|
|
|
cc.tiles[tname].add_enum(slice + ".REG0.REGSET",
|
|
|
|
str_or_default(ci->params, ctx->id("REG0_REGSET"), "RESET"));
|
|
|
|
cc.tiles[tname].add_enum(slice + ".REG1.REGSET",
|
|
|
|
str_or_default(ci->params, ctx->id("REG1_REGSET"), "RESET"));
|
|
|
|
cc.tiles[tname].add_enum(slice + ".CEMUX", str_or_default(ci->params, ctx->id("CEMUX"), "1"));
|
2018-10-01 01:39:49 +08:00
|
|
|
|
|
|
|
if (ci->sliceInfo.using_dff) {
|
|
|
|
NetInfo *lsrnet = nullptr;
|
|
|
|
if (ci->ports.find(ctx->id("LSR")) != ci->ports.end() && ci->ports.at(ctx->id("LSR")).net != nullptr)
|
|
|
|
lsrnet = ci->ports.at(ctx->id("LSR")).net;
|
|
|
|
if (ctx->getBoundWireNet(ctx->getWireByName(
|
|
|
|
ctx->id(fmt_str("X" << bel.location.x << "/Y" << bel.location.y << "/LSR0")))) == lsrnet) {
|
|
|
|
cc.tiles[tname].add_enum("LSR0.SRMODE",
|
|
|
|
str_or_default(ci->params, ctx->id("SRMODE"), "LSR_OVER_CE"));
|
|
|
|
cc.tiles[tname].add_enum("LSR0.LSRMUX", str_or_default(ci->params, ctx->id("LSRMUX"), "LSR"));
|
|
|
|
} else if (ctx->getBoundWireNet(ctx->getWireByName(ctx->id(
|
|
|
|
fmt_str("X" << bel.location.x << "/Y" << bel.location.y << "/LSR1")))) == lsrnet) {
|
|
|
|
cc.tiles[tname].add_enum("LSR1.SRMODE",
|
|
|
|
str_or_default(ci->params, ctx->id("SRMODE"), "LSR_OVER_CE"));
|
|
|
|
cc.tiles[tname].add_enum("LSR1.LSRMUX", str_or_default(ci->params, ctx->id("LSRMUX"), "LSR"));
|
|
|
|
}
|
2018-07-17 22:45:39 +08:00
|
|
|
}
|
2018-10-01 00:42:47 +08:00
|
|
|
|
|
|
|
if (str_or_default(ci->params, ctx->id("MODE"), "LOGIC") == "CCU2") {
|
|
|
|
cc.tiles[tname].add_enum(slice + ".CCU2.INJECT1_0",
|
|
|
|
str_or_default(ci->params, ctx->id("INJECT1_0"), "YES"));
|
|
|
|
cc.tiles[tname].add_enum(slice + ".CCU2.INJECT1_1",
|
|
|
|
str_or_default(ci->params, ctx->id("INJECT1_1"), "YES"));
|
|
|
|
}
|
|
|
|
|
2018-10-02 00:45:35 +08:00
|
|
|
if (str_or_default(ci->params, ctx->id("MODE"), "LOGIC") == "DPRAM" && slice == "SLICEA") {
|
2018-10-02 01:20:14 +08:00
|
|
|
cc.tiles[tname].add_enum(slice + ".WREMUX", str_or_default(ci->params, ctx->id("WREMUX"), "WRE"));
|
2018-10-02 00:45:35 +08:00
|
|
|
|
|
|
|
// FIXME: WCKMUX
|
|
|
|
NPNR_ASSERT(str_or_default(ci->params, ctx->id("WCKMUX"), "WCK") == "WCK");
|
|
|
|
}
|
|
|
|
|
2018-10-01 00:42:47 +08:00
|
|
|
// Tie unused inputs high
|
|
|
|
for (auto input : {id_A0, id_B0, id_C0, id_D0, id_A1, id_B1, id_C1, id_D1}) {
|
|
|
|
if (ci->ports.find(input) == ci->ports.end() || ci->ports.at(input).net == nullptr) {
|
|
|
|
cc.tiles[tname].add_enum(slice + "." + input.str(ctx) + "MUX", "1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: CLKMUX
|
2018-07-09 18:55:56 +08:00
|
|
|
} else if (ci->type == ctx->id("TRELLIS_IO")) {
|
2018-07-10 17:24:30 +08:00
|
|
|
std::string pio = ctx->locInfo(bel)->bel_data[bel.index].name.get();
|
|
|
|
std::string iotype = str_or_default(ci->attrs, ctx->id("IO_TYPE"), "LVCMOS33");
|
|
|
|
std::string dir = str_or_default(ci->params, ctx->id("DIR"), "INPUT");
|
2018-08-01 21:58:38 +08:00
|
|
|
std::string pio_tile = get_pio_tile(ctx, bel);
|
|
|
|
std::string pic_tile = get_pic_tile(ctx, bel);
|
2018-07-10 17:24:30 +08:00
|
|
|
cc.tiles[pio_tile].add_enum(pio + ".BASE_TYPE", dir + "_" + iotype);
|
|
|
|
cc.tiles[pic_tile].add_enum(pio + ".BASE_TYPE", dir + "_" + iotype);
|
2018-07-24 18:57:54 +08:00
|
|
|
if (is_differential(ioType_from_str(iotype))) {
|
|
|
|
// Explicitly disable other pair
|
|
|
|
std::string other;
|
|
|
|
if (pio == "PIOA")
|
|
|
|
other = "PIOB";
|
|
|
|
else if (pio == "PIOC")
|
|
|
|
other = "PIOD";
|
|
|
|
else
|
|
|
|
log_error("cannot place differential IO at location %s\n", pio.c_str());
|
2018-07-26 01:45:38 +08:00
|
|
|
// cc.tiles[pio_tile].add_enum(other + ".BASE_TYPE", "_NONE_");
|
|
|
|
// cc.tiles[pic_tile].add_enum(other + ".BASE_TYPE", "_NONE_");
|
2018-07-24 18:57:54 +08:00
|
|
|
cc.tiles[pio_tile].add_enum(other + ".PULLMODE", "NONE");
|
|
|
|
cc.tiles[pio_tile].add_enum(pio + ".PULLMODE", "NONE");
|
|
|
|
}
|
2018-07-11 20:27:15 +08:00
|
|
|
if (dir != "INPUT" &&
|
|
|
|
(ci->ports.find(ctx->id("T")) == ci->ports.end() || ci->ports.at(ctx->id("T")).net == nullptr)) {
|
2018-07-10 17:24:30 +08:00
|
|
|
// Tie tristate low if unconnected for outputs or bidir
|
|
|
|
std::string jpt = fmt_str("X" << bel.location.x << "/Y" << bel.location.y << "/JPADDT" << pio.back());
|
2018-07-15 01:50:23 +08:00
|
|
|
WireId jpt_wire = ctx->getWireByName(ctx->id(jpt));
|
2018-07-10 17:24:30 +08:00
|
|
|
PipId jpt_pip = *ctx->getPipsUphill(jpt_wire).begin();
|
|
|
|
WireId cib_wire = ctx->getPipSrcWire(jpt_pip);
|
2018-07-11 20:27:15 +08:00
|
|
|
std::string cib_tile =
|
2018-08-01 21:58:38 +08:00
|
|
|
ctx->getTileByTypeAndLocation(cib_wire.location.y, cib_wire.location.x, cib_tiles);
|
2018-07-10 17:24:30 +08:00
|
|
|
std::string cib_wirename = ctx->locInfo(cib_wire)->wire_data[cib_wire.index].name.get();
|
|
|
|
cc.tiles[cib_tile].add_enum("CIB." + cib_wirename + "MUX", "0");
|
|
|
|
}
|
2018-07-24 18:57:54 +08:00
|
|
|
if (dir == "INPUT" && !is_differential(ioType_from_str(iotype))) {
|
2018-07-10 18:31:58 +08:00
|
|
|
cc.tiles[pio_tile].add_enum(pio + ".HYSTERESIS", "ON");
|
|
|
|
}
|
2018-09-30 00:36:08 +08:00
|
|
|
} else if (ci->type == ctx->id("DCCA")) {
|
|
|
|
// Nothing to do
|
2018-07-09 18:55:56 +08:00
|
|
|
} else {
|
|
|
|
NPNR_ASSERT_FALSE("unsupported cell type");
|
2018-07-09 18:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Configure chip
|
|
|
|
if (!text_config_file.empty()) {
|
|
|
|
std::ofstream out_config(text_config_file);
|
2018-08-01 21:58:38 +08:00
|
|
|
out_config << cc;
|
2018-07-09 18:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_END
|