Skip to content

Commit

Permalink
Support for turning on mult pass from generic synth command
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfox-rushc committed Sep 8, 2023
1 parent 6d29dc6 commit 1d92ea8
Showing 1 changed file with 34 additions and 36 deletions.
70 changes: 34 additions & 36 deletions techlibs/common/synth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
*
*/

#include "kernel/register.h"
#include "kernel/celltypes.h"
#include "kernel/rtlil.h"
#include "kernel/log.h"
#include "kernel/register.h"
#include "kernel/rtlil.h"

USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN

struct SynthPass : public ScriptPass
{
SynthPass() : ScriptPass("synth", "generic synthesis script") { }
struct SynthPass : public ScriptPass {
SynthPass() : ScriptPass("synth", "generic synthesis script") {}

void help() override
{
Expand Down Expand Up @@ -60,6 +59,9 @@ struct SynthPass : public ScriptPass
log(" -noabc\n");
log(" do not run abc (as if yosys was compiled without ABC support)\n");
log("\n");
log(" -booth\n");
log(" run the booth pass to convert $mul to Booth encoded multipliers");
log("\n");
log(" -noalumacc\n");
log(" do not run 'alumacc' pass. i.e. keep arithmetic operators in\n");
log(" their direct form ($add, $sub, etc.).\n");
Expand Down Expand Up @@ -93,7 +95,8 @@ struct SynthPass : public ScriptPass
}

string top_module, fsm_opts, memory_opts, abc;
bool autotop, flatten, noalumacc, nofsm, noabc, noshare, flowmap;
bool autotop, flatten, noalumacc, nofsm, noabc, noshare, flowmap, mult;

int lut;

void clear_flags() override
Expand All @@ -110,6 +113,7 @@ struct SynthPass : public ScriptPass
noabc = false;
noshare = false;
flowmap = false;
mult = false;
abc = "abc";
}

Expand All @@ -119,24 +123,23 @@ struct SynthPass : public ScriptPass
clear_flags();

size_t argidx;
for (argidx = 1; argidx < args.size(); argidx++)
{
if (args[argidx] == "-top" && argidx+1 < args.size()) {
for (argidx = 1; argidx < args.size(); argidx++) {
if (args[argidx] == "-top" && argidx + 1 < args.size()) {
top_module = args[++argidx];
continue;
}
if (args[argidx] == "-encfile" && argidx+1 < args.size()) {
if (args[argidx] == "-encfile" && argidx + 1 < args.size()) {
fsm_opts = " -encfile " + args[++argidx];
continue;
}
if (args[argidx] == "-run" && argidx+1 < args.size()) {
size_t pos = args[argidx+1].find(':');
if (args[argidx] == "-run" && argidx + 1 < args.size()) {
size_t pos = args[argidx + 1].find(':');
if (pos == std::string::npos) {
run_from = args[++argidx];
run_to = args[argidx];
} else {
run_from = args[++argidx].substr(0, pos);
run_to = args[argidx].substr(pos+1);
run_to = args[argidx].substr(pos + 1);
}
continue;
}
Expand Down Expand Up @@ -164,6 +167,11 @@ struct SynthPass : public ScriptPass
noalumacc = true;
continue;
}
if (args[argidx] == "-mult") {
mult = true;
continue;
}

if (args[argidx] == "-nordff") {
memory_opts += " -nordff";
continue;
Expand Down Expand Up @@ -206,8 +214,7 @@ struct SynthPass : public ScriptPass

void script() override
{
if (check_label("begin"))
{
if (check_label("begin")) {
if (help_mode) {
run("hierarchy -check [-top <top> | -auto-top]");
} else {
Expand All @@ -221,8 +228,7 @@ struct SynthPass : public ScriptPass
}
}

if (check_label("coarse"))
{
if (check_label("coarse")) {
run("proc");
if (help_mode || flatten)
run("flatten", " (if -flatten)");
Expand All @@ -240,6 +246,8 @@ struct SynthPass : public ScriptPass
run("techmap -map +/cmp2lut.v -map +/cmp2lcu.v", " (if -lut)");
else if (lut)
run(stringf("techmap -map +/cmp2lut.v -map +/cmp2lcu.v -D LUT_WIDTH=%d", lut));
if (mult)
run("booth");
if (!noalumacc)
run("alumacc", " (unless -noalumacc)");
if (!noshare)
Expand All @@ -249,50 +257,40 @@ struct SynthPass : public ScriptPass
run("opt_clean");
}

if (check_label("fine"))
{
if (check_label("fine")) {
run("opt -fast -full");
run("memory_map");
run("opt -full");
run("techmap");
if (help_mode)
{
if (help_mode) {
run("techmap -map +/gate2lut.v", "(if -noabc and -lut)");
run("clean; opt_lut", " (if -noabc and -lut)");
run("flowmap -maxlut K", " (if -flowmap and -lut)");
}
else if (noabc && lut)
{
} else if (noabc && lut) {
run(stringf("techmap -map +/gate2lut.v -D LUT_WIDTH=%d", lut));
run("clean; opt_lut");
}
else if (flowmap)
{
} else if (flowmap) {
run(stringf("flowmap -maxlut %d", lut));
}
run("opt -fast");

if (!noabc && !flowmap) {
#ifdef YOSYS_ENABLE_ABC
if (help_mode)
{
#ifdef YOSYS_ENABLE_ABC
if (help_mode) {
run(abc + " -fast", " (unless -noabc, unless -lut)");
run(abc + " -fast -lut k", "(unless -noabc, if -lut)");
}
else
{
} else {
if (lut)
run(stringf("%s -fast -lut %d", abc.c_str(), lut));
else
run(abc + " -fast");
}
run("opt -fast", " (unless -noabc)");
#endif
#endif
}
}

if (check_label("check"))
{
if (check_label("check")) {
run("hierarchy -check");
run("stat");
run("check");
Expand Down

0 comments on commit 1d92ea8

Please sign in to comment.