mirror of
https://github.com/YosysHQ/yosys
synced 2025-07-23 04:38:55 +00:00
Add clock buffer insertion pass, improve iopadmap.
A few new attributes are defined for use in cell libraries: - iopad_external_pin: marks PAD cell's external-facing pin. Pad insertion will be skipped for ports that are already connected to such a pin. - clkbuf_sink: marks an input pin as a clock pin, requesting clock buffer insertion. - clkbuf_driver: marks an output pin as a clock buffer output pin. Clock buffer insertion will be skipped for nets that are already driven by such a pin. All three are module attributes that should be set to a comma-separeted list of pin names. Clock buffer insertion itself works as follows: 1. All cell ports, starting from bottom up, can be marked as clock sinks (requesting clock buffer insertion) or as clock buffer outputs. 2. If a wire in a given module is driven by a cell port that is a clock buffer output, it is in turn also considered a clock buffer output. 3. If an input port in a non-top module is connected to a clock sink in a contained cell, it is also in turn considered a clock sink. 4. If a wire in a module is driven by a non-clock-buffer cell, and is also connected to a clock sink port in a contained cell, a clock buffer is inserted in this module. 5. For the top module, a clock buffer is also inserted on input ports connected to clock sinks, optionally with a special kind of input PAD (such as IBUFG for Xilinx). 6. Clock buffer insertion on a given wire is skipped if the clkbuf_inhibit attribute is set on it.
This commit is contained in:
parent
78b30bbb11
commit
f4c62f33ac
10 changed files with 577 additions and 93 deletions
|
@ -32,6 +32,19 @@ void split_portname_pair(std::string &port1, std::string &port2)
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> split(std::string text, const char *delim)
|
||||
{
|
||||
std::vector<std::string> list;
|
||||
char *p = strdup(text.c_str());
|
||||
char *t = strtok(p, delim);
|
||||
while (t != NULL) {
|
||||
list.push_back(t);
|
||||
t = strtok(NULL, delim);
|
||||
}
|
||||
free(p);
|
||||
return list;
|
||||
}
|
||||
|
||||
struct IopadmapPass : public Pass {
|
||||
IopadmapPass() : Pass("iopadmap", "technology mapping of i/o pads (or buffers)") { }
|
||||
void help() YS_OVERRIDE
|
||||
|
@ -64,6 +77,11 @@ struct IopadmapPass : public Pass {
|
|||
log(" of the tristate driver and the 2nd portname is the internal output\n");
|
||||
log(" buffering the external signal.\n");
|
||||
log("\n");
|
||||
log(" -ignore <celltype> <portname>[:<portname>]*\n");
|
||||
log(" Skips mapping inputs/outputs that are already connected to given\n");
|
||||
log(" ports of the given cell. Can be used multiple times. This is in\n");
|
||||
log(" addition to the cells specified as mapping targets.\n");
|
||||
log("\n");
|
||||
log(" -widthparam <param_name>\n");
|
||||
log(" Use the specified parameter name to set the port width.\n");
|
||||
log("\n");
|
||||
|
@ -88,6 +106,7 @@ struct IopadmapPass : public Pass {
|
|||
std::string toutpad_celltype, toutpad_portname, toutpad_portname2, toutpad_portname3;
|
||||
std::string tinoutpad_celltype, tinoutpad_portname, tinoutpad_portname2, tinoutpad_portname3, tinoutpad_portname4;
|
||||
std::string widthparam, nameparam;
|
||||
pool<pair<IdString, IdString>> ignore;
|
||||
bool flag_bits = false;
|
||||
|
||||
size_t argidx;
|
||||
|
@ -127,6 +146,18 @@ struct IopadmapPass : public Pass {
|
|||
split_portname_pair(tinoutpad_portname3, tinoutpad_portname4);
|
||||
continue;
|
||||
}
|
||||
if (arg == "-ignore" && argidx+2 < args.size()) {
|
||||
std::string ignore_celltype = args[++argidx];
|
||||
std::string ignore_portname = args[++argidx];
|
||||
std::string ignore_portname2;
|
||||
while (!ignore_portname.empty()) {
|
||||
split_portname_pair(ignore_portname, ignore_portname2);
|
||||
ignore.insert(make_pair(RTLIL::escape_id(ignore_celltype), RTLIL::escape_id(ignore_portname)));
|
||||
|
||||
ignore_portname = ignore_portname2;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (arg == "-widthparam" && argidx+1 < args.size()) {
|
||||
widthparam = args[++argidx];
|
||||
continue;
|
||||
|
@ -143,6 +174,28 @@ struct IopadmapPass : public Pass {
|
|||
}
|
||||
extra_args(args, argidx, design);
|
||||
|
||||
if (!inpad_portname2.empty())
|
||||
ignore.insert(make_pair(RTLIL::escape_id(inpad_celltype), RTLIL::escape_id(inpad_portname2)));
|
||||
if (!outpad_portname2.empty())
|
||||
ignore.insert(make_pair(RTLIL::escape_id(outpad_celltype), RTLIL::escape_id(outpad_portname2)));
|
||||
if (!inoutpad_portname2.empty())
|
||||
ignore.insert(make_pair(RTLIL::escape_id(inoutpad_celltype), RTLIL::escape_id(inoutpad_portname2)));
|
||||
if (!toutpad_portname3.empty())
|
||||
ignore.insert(make_pair(RTLIL::escape_id(toutpad_celltype), RTLIL::escape_id(toutpad_portname3)));
|
||||
if (!tinoutpad_portname4.empty())
|
||||
ignore.insert(make_pair(RTLIL::escape_id(tinoutpad_celltype), RTLIL::escape_id(tinoutpad_portname4)));
|
||||
|
||||
for (auto module : design->modules())
|
||||
{
|
||||
auto it = module->attributes.find("\\iopad_external_pin");
|
||||
if (it != module->attributes.end()) {
|
||||
auto value = it->second.decode_string();
|
||||
for (auto name : split(value, ",")) {
|
||||
ignore.insert(make_pair(module->name, RTLIL::escape_id(name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto module : design->selected_modules())
|
||||
{
|
||||
dict<IdString, pool<int>> skip_wires;
|
||||
|
@ -150,28 +203,11 @@ struct IopadmapPass : public Pass {
|
|||
SigMap sigmap(module);
|
||||
|
||||
for (auto cell : module->cells())
|
||||
{
|
||||
if (cell->type == RTLIL::escape_id(inpad_celltype) && cell->hasPort(RTLIL::escape_id(inpad_portname2)))
|
||||
for (auto bit : sigmap(cell->getPort(RTLIL::escape_id(inpad_portname2))))
|
||||
for (auto port : cell->connections())
|
||||
if (ignore.count(make_pair(cell->type, port.first)))
|
||||
for (auto bit : sigmap(port.second))
|
||||
skip_wire_bits.insert(bit);
|
||||
|
||||
if (cell->type == RTLIL::escape_id(outpad_celltype) && cell->hasPort(RTLIL::escape_id(outpad_portname2)))
|
||||
for (auto bit : sigmap(cell->getPort(RTLIL::escape_id(outpad_portname2))))
|
||||
skip_wire_bits.insert(bit);
|
||||
|
||||
if (cell->type == RTLIL::escape_id(inoutpad_celltype) && cell->hasPort(RTLIL::escape_id(inoutpad_portname2)))
|
||||
for (auto bit : sigmap(cell->getPort(RTLIL::escape_id(inoutpad_portname2))))
|
||||
skip_wire_bits.insert(bit);
|
||||
|
||||
if (cell->type == RTLIL::escape_id(toutpad_celltype) && cell->hasPort(RTLIL::escape_id(toutpad_portname3)))
|
||||
for (auto bit : sigmap(cell->getPort(RTLIL::escape_id(toutpad_portname3))))
|
||||
skip_wire_bits.insert(bit);
|
||||
|
||||
if (cell->type == RTLIL::escape_id(tinoutpad_celltype) && cell->hasPort(RTLIL::escape_id(tinoutpad_portname4)))
|
||||
for (auto bit : sigmap(cell->getPort(RTLIL::escape_id(tinoutpad_portname4))))
|
||||
skip_wire_bits.insert(bit);
|
||||
}
|
||||
|
||||
if (!toutpad_celltype.empty() || !tinoutpad_celltype.empty())
|
||||
{
|
||||
dict<SigBit, pair<IdString, pool<IdString>>> tbuf_bits;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue