basic support for few small primitives

This commit is contained in:
Miodrag Milanovic 2023-04-19 13:54:51 +02:00 committed by myrtle
parent 2a35f0292a
commit 7ac3d0d901
2 changed files with 50 additions and 3 deletions

View File

@ -259,10 +259,9 @@ struct MachXO2Bitgen
std::vector<std::string> tiles; std::vector<std::string> tiles;
Loc loc = ctx->getBelLocation(bel); Loc loc = ctx->getBelLocation(bel);
if (name == "EHXPLL_L") { if (name == "LPLL") {
tiles.push_back(ctx->get_tile_by_type_loc(loc.y-1, loc.x-1, "GPLL_L0")); tiles.push_back(ctx->get_tile_by_type_loc(loc.y-1, loc.x-1, "GPLL_L0"));
//tiles.push_back(ctx->get_tile_by_type_loc(loc.y, loc.x, "CIB_PIC_T_DUMMY")); } else if (name == "RPLL") {
} else if (name == "EHXPLL_R") {
tiles.push_back(ctx->get_tile_by_type_loc(loc.y+1, loc.x-1, "GPLL_R0")); tiles.push_back(ctx->get_tile_by_type_loc(loc.y+1, loc.x-1, "GPLL_R0"));
} else { } else {
NPNR_ASSERT_FALSE_STR("bad PLL loc " + name); NPNR_ASSERT_FALSE_STR("bad PLL loc " + name);
@ -695,6 +694,33 @@ struct MachXO2Bitgen
write_bram(ci); write_bram(ci);
} else if (ci->type == id_EHXPLLJ) { } else if (ci->type == id_EHXPLLJ) {
write_pll(ci); write_pll(ci);
} else if (ci->type == id_GSR) {
cc.tiles[ctx->get_tile_by_type("CFG0")].add_enum(
"GSR.GSRMODE", str_or_default(ci->params, id_MODE, "ACTIVE_LOW"));
cc.tiles[ctx->get_tile_by_type("CFG0")].add_enum("GSR.SYNCMODE",
str_or_default(ci->params, id_SYNCMODE, "ASYNC"));
} else if (ci->type == id_JTAGF) {
cc.tiles[ctx->get_tile_by_type("CFG0")].add_enum("JTAG.ER1",
str_or_default(ci->params, id_ER1, "ENABLED"));
cc.tiles[ctx->get_tile_by_type("CFG0")].add_enum("JTAG.ER2",
str_or_default(ci->params, id_ER2, "ENABLED"));
} else if (ci->type == id_TSALL) {
cc.tiles[ctx->get_tile_by_type("CFG0")].add_enum(
"TSALL.MODE", str_or_default(ci->params, id_MODE, "TSALL"));
cc.tiles[ctx->get_tile_by_type("CFG0")].add_enum(
"TSALL.TSALL", str_or_default(ci->params, id_TSALL, "TSALL"));
} else if (ci->type == id_START) {
cc.tiles[ctx->get_tile_by_type("CIB_CFG0")].add_enum(
"START.STARTCLK", str_or_default(ci->params, id_STARTCLK, "STARTCLK"));
} else if (ci->type == id_CLKDIVC) {
Loc loc = ctx->getBelLocation(ci->bel);
bool t = loc.y < 2;
std::string clkdiv = (t ? "T": "B") + std::string("CLKDIV") + std::to_string(loc.z);
std::string tile = ctx->get_tile_by_type(t ? "PIC_T_DUMMY_VIQ" : "PIC_B_DUMMY_VIQ_VREF");
cc.tiles[tile].add_enum(clkdiv + ".DIV", str_or_default(ci->params, id_DIV, "2.0"));
cc.tiles[tile].add_enum(clkdiv + ".GSR", str_or_default(ci->params, id_GSR, "DISABLED"));
} else {
NPNR_ASSERT_FALSE("unsupported cell type");
} }
} }
} }

View File

@ -1068,6 +1068,26 @@ class MachXO2Packer
} }
} }
// Miscellaneous packer tasks
void pack_misc()
{
for (auto &cell : ctx->cells) {
CellInfo *ci = cell.second.get();
if (ci->type.in(id_GSR, id_SGSR)) {
ci->params[id_MODE] = std::string("ACTIVE_LOW");
ci->params[id_SYNCMODE] = ci->type == id_SGSR ? std::string("SYNC") : std::string("ASYNC");
ci->type = id_GSR;
for (BelId bel : ctx->getBels()) {
if (ctx->getBelType(bel) != id_GSR)
continue;
ci->attrs[id_BEL] = ctx->getBelName(bel).str(ctx);
}
} else if (ci->type.in(id_TSALL)) {
ci->renamePort(id_TSALL, id_TSALLI);
}
}
}
// Preplace PLL // Preplace PLL
void preplace_plls() void preplace_plls()
{ {
@ -1357,6 +1377,7 @@ class MachXO2Packer
pack_io(); pack_io();
preplace_plls(); preplace_plls();
pack_ebr(); pack_ebr();
pack_misc();
pack_constants(); pack_constants();
pack_dram(); pack_dram();
pack_carries(); pack_carries();