Skip to content

Commit fad52ab

Browse files
committedMay 24, 2017
Add aliases for common sets of gate types to "abc -g"
1 parent dca3b3c commit fad52ab

File tree

1 file changed

+74
-2
lines changed

1 file changed

+74
-2
lines changed
 

Diff for: ‎passes/techmap/abc.cc

+74-2
Original file line numberDiff line numberDiff line change
@@ -1314,10 +1314,21 @@ struct AbcPass : public Pass {
13141314
// log(" (ignored when used with -liberty or -lut)\n");
13151315
// log("\n");
13161316
log(" -g type1,type2,...\n");
1317-
log(" Map the the specified list of gate types. Supported gates types are:\n");
1317+
log(" Map to the specified list of gate types. Supported gates types are:\n");
13181318
log(" AND, NAND, OR, NOR, XOR, XNOR, ANDNOT, ORNOT, MUX, AOI3, OAI3, AOI4, OAI4.\n");
13191319
log(" (The NOT gate is always added to this list automatically.)\n");
13201320
log("\n");
1321+
log(" The following aliases can be used to reference common sets of gate types:\n");
1322+
log(" simple: AND OR XOR MUX\n");
1323+
log(" cmos2: NAND NOR\n");
1324+
log(" cmos3: NAND NOR AOI3 OAI3\n");
1325+
log(" cmos: NAND NOR AOI3 OAI3 AOI4 OAI4\n");
1326+
log(" gates: AND NAND OR NOR XOR XNOR ANDNOT ORNOT\n");
1327+
log(" aig: AND NAND OR NOR ANDNOT ORNOT\n");
1328+
log("\n");
1329+
log(" Prefix a gate type with a '-' to remove it from the list. For example\n");
1330+
log(" the arguments 'AND,OR,XOR' and 'simple,-MUX' are equivalent.\n");
1331+
log("\n");
13211332
log(" -dff\n");
13221333
log(" also pass $_DFF_?_ and $_DFFE_??_ cells through ABC. modules with many\n");
13231334
log(" clock domains are automatically partitioned in clock domains and each\n");
@@ -1480,6 +1491,12 @@ struct AbcPass : public Pass {
14801491
}
14811492
if (arg == "-g" && argidx+1 < args.size()) {
14821493
for (auto g : split_tokens(args[++argidx], ",")) {
1494+
vector<string> gate_list;
1495+
bool remove_gates = false;
1496+
if (GetSize(g) > 0 && g[0] == '-') {
1497+
remove_gates = true;
1498+
g = g.substr(1);
1499+
}
14831500
if (g == "AND") goto ok_gate;
14841501
if (g == "NAND") goto ok_gate;
14851502
if (g == "OR") goto ok_gate;
@@ -1493,9 +1510,64 @@ struct AbcPass : public Pass {
14931510
if (g == "OAI3") goto ok_gate;
14941511
if (g == "AOI4") goto ok_gate;
14951512
if (g == "OAI4") goto ok_gate;
1513+
if (g == "simple") {
1514+
gate_list.push_back("AND");
1515+
gate_list.push_back("OR");
1516+
gate_list.push_back("XOR");
1517+
gate_list.push_back("MUX");
1518+
goto ok_alias;
1519+
}
1520+
if (g == "cmos2") {
1521+
gate_list.push_back("NAND");
1522+
gate_list.push_back("NOR");
1523+
goto ok_alias;
1524+
}
1525+
if (g == "cmos3") {
1526+
gate_list.push_back("NAND");
1527+
gate_list.push_back("NOR");
1528+
gate_list.push_back("AOI3");
1529+
gate_list.push_back("OAI3");
1530+
goto ok_alias;
1531+
}
1532+
if (g == "cmos4") {
1533+
gate_list.push_back("NAND");
1534+
gate_list.push_back("NOR");
1535+
gate_list.push_back("AOI3");
1536+
gate_list.push_back("OAI3");
1537+
gate_list.push_back("AOI4");
1538+
gate_list.push_back("OAI4");
1539+
goto ok_alias;
1540+
}
1541+
if (g == "gates") {
1542+
gate_list.push_back("AND");
1543+
gate_list.push_back("NAND");
1544+
gate_list.push_back("OR");
1545+
gate_list.push_back("NOR");
1546+
gate_list.push_back("XOR");
1547+
gate_list.push_back("XNOR");
1548+
gate_list.push_back("ANDNOT");
1549+
gate_list.push_back("ORNOT");
1550+
goto ok_alias;
1551+
}
1552+
if (g == "aig") {
1553+
gate_list.push_back("AND");
1554+
gate_list.push_back("NAND");
1555+
gate_list.push_back("OR");
1556+
gate_list.push_back("NOR");
1557+
gate_list.push_back("ANDNOT");
1558+
gate_list.push_back("ORNOT");
1559+
goto ok_alias;
1560+
}
14961561
cmd_error(args, argidx, stringf("Unsupported gate type: %s", g.c_str()));
14971562
ok_gate:
1498-
enabled_gates.insert(g);
1563+
gate_list.push_back(g);
1564+
ok_alias:
1565+
for (auto gate : gate_list) {
1566+
if (remove_gates)
1567+
enabled_gates.erase(gate);
1568+
else
1569+
enabled_gates.insert(gate);
1570+
}
14991571
}
15001572
continue;
15011573
}

0 commit comments

Comments
 (0)