log(" do not use MUXF[78] resources to implement LUTs larger than LUT6s\n");
log("\n");
log(" -widemux <int>\n");
- log(" enable inference of hard multiplexer resources (MuxFx) for muxes at or\n");
- log(" above this number of inputs (minimum value 5).\n");
+ log(" enable inference of hard multiplexer resources (MUXF[78]) for muxes at or\n");
+ log(" above this number of inputs (minimum value 2, recommended value >= 5).\n");
log(" default: 0 (no inference)\n");
log("\n");
log(" -run <from_label>:<to_label>\n");
continue;
}
if (args[argidx] == "-widemux" && argidx+1 < args.size()) {
- widemux = atoi(args[++argidx].c_str());
+ widemux = std::stoi(args[++argidx]);
continue;
}
if (args[argidx] == "-abc9") {
if (family != "xcup" && family != "xcu" && family != "xc7" && family != "xc6s")
log_cmd_error("Invalid Xilinx -family setting: %s\n", family.c_str());
- if (widemux != 0 && widemux < 5)
- log_cmd_error("-widemux value must be 0 or >= 5.\n");
+ if (widemux != 0 && widemux < 2)
+ log_cmd_error("-widemux value must be 0 or >= 2.\n");
if (!design->full_selection())
log_cmd_error("This command only operates on fully selected designs!\n");
if (check_label("coarse")) {
if (help_mode)
- run("synth -run coarse [-flatten]", "(with '-flatten')");
+ run("synth -keepdc -run coarse [-flatten]", "(with '-flatten')");
else
- run("synth -run coarse" + std::string(flatten ? "" : " -flatten"), "(with '-flatten')");
+ run("synth -keepdc -run coarse" + std::string(flatten ? "" : " -flatten"), "(with '-flatten')");
if (widemux > 0 || help_mode)
run("muxpack", " ('-widemux' only)");
// so attempt to convert $pmux-es to the former
// Also: wide multiplexer inference benefits from this too
if (!(nosrl && widemux == 0) || help_mode)
- run("pmux2shiftx", "(skip if '-nosrl' and '-widemux' < 5)");
+ run("pmux2shiftx", "(skip if '-nosrl' and '-widemux=0')");
}
if (check_label("bram", "(skip if '-nobram')")) {
}
if (check_label("fine")) {
- run("opt -fast -full");
+ if (widemux > 0)
+ run("opt -fast -mux_bool -undriven -fine"); // Necessary to omit -mux_undef otherwise muxcover
+ // performs less efficiently
+ else
+ run("opt -fast -full");
run("memory_map");
run("dffsr2dff");
run("dff2dffe");
}
else if (widemux > 0) {
run("simplemap t:$mux");
- std::string muxcover_args = " -nodecode";
+ constexpr int cost_mux2 = 100;
+ std::string muxcover_args = stringf(" -nodecode -mux2=%d", cost_mux2);
switch (widemux) {
- // NB: Cost of mux2 is 100; mux8 should cost between 3 and 4
- // of those so that 4:1 muxes and below are implemented
- // out of mux2s
- case 5: muxcover_args += " -mux8=350 -mux16=400"; break;
- case 6: muxcover_args += " -mux8=450 -mux16=500"; break;
- case 7: muxcover_args += " -mux8=550 -mux16=600"; break;
- case 8: muxcover_args += " -mux8=650 -mux16=700"; break;
- case 9: muxcover_args += " -mux16=750"; break;
- case 10: muxcover_args += " -mux16=850"; break;
- case 11: muxcover_args += " -mux16=950"; break;
- case 12: muxcover_args += " -mux16=1050"; break;
- case 13: muxcover_args += " -mux16=1150"; break;
- case 14: muxcover_args += " -mux16=1250"; break;
- case 15: muxcover_args += " -mux16=1350"; break;
- default: muxcover_args += " -mux16=1450"; break;
+ case 2: muxcover_args += stringf(" -mux4=%d -mux8=%d -mux16=%d", cost_mux2+1, cost_mux2+2, cost_mux2+3); break;
+ case 3:
+ case 4: muxcover_args += stringf(" -mux4=%d -mux8=%d -mux16=%d", cost_mux2*(widemux-1)-2, cost_mux2*(widemux-1)-1, cost_mux2*(widemux-1)); break;
+ case 5:
+ case 6:
+ case 7:
+ case 8: muxcover_args += stringf(" -mux8=%d -mux16=%d", cost_mux2*(widemux-1)-1, cost_mux2*(widemux-1)); break;
+ case 9:
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ default: muxcover_args += stringf(" -mux16=%d", cost_mux2*(widemux-1)-1); break;
}
run("muxcover " + muxcover_args);
}