mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Support for turning on mult pass from generic synth command
This commit is contained in:
parent
6d29dc659b
commit
1d92ea8001
|
@ -17,17 +17,16 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "kernel/register.h"
|
|
||||||
#include "kernel/celltypes.h"
|
#include "kernel/celltypes.h"
|
||||||
#include "kernel/rtlil.h"
|
|
||||||
#include "kernel/log.h"
|
#include "kernel/log.h"
|
||||||
|
#include "kernel/register.h"
|
||||||
|
#include "kernel/rtlil.h"
|
||||||
|
|
||||||
USING_YOSYS_NAMESPACE
|
USING_YOSYS_NAMESPACE
|
||||||
PRIVATE_NAMESPACE_BEGIN
|
PRIVATE_NAMESPACE_BEGIN
|
||||||
|
|
||||||
struct SynthPass : public ScriptPass
|
struct SynthPass : public ScriptPass {
|
||||||
{
|
SynthPass() : ScriptPass("synth", "generic synthesis script") {}
|
||||||
SynthPass() : ScriptPass("synth", "generic synthesis script") { }
|
|
||||||
|
|
||||||
void help() override
|
void help() override
|
||||||
{
|
{
|
||||||
|
@ -60,6 +59,9 @@ struct SynthPass : public ScriptPass
|
||||||
log(" -noabc\n");
|
log(" -noabc\n");
|
||||||
log(" do not run abc (as if yosys was compiled without ABC support)\n");
|
log(" do not run abc (as if yosys was compiled without ABC support)\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
|
log(" -booth\n");
|
||||||
|
log(" run the booth pass to convert $mul to Booth encoded multipliers");
|
||||||
|
log("\n");
|
||||||
log(" -noalumacc\n");
|
log(" -noalumacc\n");
|
||||||
log(" do not run 'alumacc' pass. i.e. keep arithmetic operators in\n");
|
log(" do not run 'alumacc' pass. i.e. keep arithmetic operators in\n");
|
||||||
log(" their direct form ($add, $sub, etc.).\n");
|
log(" their direct form ($add, $sub, etc.).\n");
|
||||||
|
@ -93,7 +95,8 @@ struct SynthPass : public ScriptPass
|
||||||
}
|
}
|
||||||
|
|
||||||
string top_module, fsm_opts, memory_opts, abc;
|
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;
|
int lut;
|
||||||
|
|
||||||
void clear_flags() override
|
void clear_flags() override
|
||||||
|
@ -110,6 +113,7 @@ struct SynthPass : public ScriptPass
|
||||||
noabc = false;
|
noabc = false;
|
||||||
noshare = false;
|
noshare = false;
|
||||||
flowmap = false;
|
flowmap = false;
|
||||||
|
mult = false;
|
||||||
abc = "abc";
|
abc = "abc";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,24 +123,23 @@ struct SynthPass : public ScriptPass
|
||||||
clear_flags();
|
clear_flags();
|
||||||
|
|
||||||
size_t argidx;
|
size_t argidx;
|
||||||
for (argidx = 1; argidx < args.size(); argidx++)
|
for (argidx = 1; argidx < args.size(); argidx++) {
|
||||||
{
|
if (args[argidx] == "-top" && argidx + 1 < args.size()) {
|
||||||
if (args[argidx] == "-top" && argidx+1 < args.size()) {
|
|
||||||
top_module = args[++argidx];
|
top_module = args[++argidx];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (args[argidx] == "-encfile" && argidx+1 < args.size()) {
|
if (args[argidx] == "-encfile" && argidx + 1 < args.size()) {
|
||||||
fsm_opts = " -encfile " + args[++argidx];
|
fsm_opts = " -encfile " + args[++argidx];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (args[argidx] == "-run" && argidx+1 < args.size()) {
|
if (args[argidx] == "-run" && argidx + 1 < args.size()) {
|
||||||
size_t pos = args[argidx+1].find(':');
|
size_t pos = args[argidx + 1].find(':');
|
||||||
if (pos == std::string::npos) {
|
if (pos == std::string::npos) {
|
||||||
run_from = args[++argidx];
|
run_from = args[++argidx];
|
||||||
run_to = args[argidx];
|
run_to = args[argidx];
|
||||||
} else {
|
} else {
|
||||||
run_from = args[++argidx].substr(0, pos);
|
run_from = args[++argidx].substr(0, pos);
|
||||||
run_to = args[argidx].substr(pos+1);
|
run_to = args[argidx].substr(pos + 1);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -164,6 +167,11 @@ struct SynthPass : public ScriptPass
|
||||||
noalumacc = true;
|
noalumacc = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (args[argidx] == "-mult") {
|
||||||
|
mult = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (args[argidx] == "-nordff") {
|
if (args[argidx] == "-nordff") {
|
||||||
memory_opts += " -nordff";
|
memory_opts += " -nordff";
|
||||||
continue;
|
continue;
|
||||||
|
@ -206,8 +214,7 @@ struct SynthPass : public ScriptPass
|
||||||
|
|
||||||
void script() override
|
void script() override
|
||||||
{
|
{
|
||||||
if (check_label("begin"))
|
if (check_label("begin")) {
|
||||||
{
|
|
||||||
if (help_mode) {
|
if (help_mode) {
|
||||||
run("hierarchy -check [-top <top> | -auto-top]");
|
run("hierarchy -check [-top <top> | -auto-top]");
|
||||||
} else {
|
} else {
|
||||||
|
@ -221,8 +228,7 @@ struct SynthPass : public ScriptPass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_label("coarse"))
|
if (check_label("coarse")) {
|
||||||
{
|
|
||||||
run("proc");
|
run("proc");
|
||||||
if (help_mode || flatten)
|
if (help_mode || flatten)
|
||||||
run("flatten", " (if -flatten)");
|
run("flatten", " (if -flatten)");
|
||||||
|
@ -240,6 +246,8 @@ struct SynthPass : public ScriptPass
|
||||||
run("techmap -map +/cmp2lut.v -map +/cmp2lcu.v", " (if -lut)");
|
run("techmap -map +/cmp2lut.v -map +/cmp2lcu.v", " (if -lut)");
|
||||||
else if (lut)
|
else if (lut)
|
||||||
run(stringf("techmap -map +/cmp2lut.v -map +/cmp2lcu.v -D LUT_WIDTH=%d", lut));
|
run(stringf("techmap -map +/cmp2lut.v -map +/cmp2lcu.v -D LUT_WIDTH=%d", lut));
|
||||||
|
if (mult)
|
||||||
|
run("booth");
|
||||||
if (!noalumacc)
|
if (!noalumacc)
|
||||||
run("alumacc", " (unless -noalumacc)");
|
run("alumacc", " (unless -noalumacc)");
|
||||||
if (!noshare)
|
if (!noshare)
|
||||||
|
@ -249,50 +257,40 @@ struct SynthPass : public ScriptPass
|
||||||
run("opt_clean");
|
run("opt_clean");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_label("fine"))
|
if (check_label("fine")) {
|
||||||
{
|
|
||||||
run("opt -fast -full");
|
run("opt -fast -full");
|
||||||
run("memory_map");
|
run("memory_map");
|
||||||
run("opt -full");
|
run("opt -full");
|
||||||
run("techmap");
|
run("techmap");
|
||||||
if (help_mode)
|
if (help_mode) {
|
||||||
{
|
|
||||||
run("techmap -map +/gate2lut.v", "(if -noabc and -lut)");
|
run("techmap -map +/gate2lut.v", "(if -noabc and -lut)");
|
||||||
run("clean; opt_lut", " (if -noabc and -lut)");
|
run("clean; opt_lut", " (if -noabc and -lut)");
|
||||||
run("flowmap -maxlut K", " (if -flowmap 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(stringf("techmap -map +/gate2lut.v -D LUT_WIDTH=%d", lut));
|
||||||
run("clean; opt_lut");
|
run("clean; opt_lut");
|
||||||
}
|
} else if (flowmap) {
|
||||||
else if (flowmap)
|
|
||||||
{
|
|
||||||
run(stringf("flowmap -maxlut %d", lut));
|
run(stringf("flowmap -maxlut %d", lut));
|
||||||
}
|
}
|
||||||
run("opt -fast");
|
run("opt -fast");
|
||||||
|
|
||||||
if (!noabc && !flowmap) {
|
if (!noabc && !flowmap) {
|
||||||
#ifdef YOSYS_ENABLE_ABC
|
#ifdef YOSYS_ENABLE_ABC
|
||||||
if (help_mode)
|
if (help_mode) {
|
||||||
{
|
|
||||||
run(abc + " -fast", " (unless -noabc, unless -lut)");
|
run(abc + " -fast", " (unless -noabc, unless -lut)");
|
||||||
run(abc + " -fast -lut k", "(unless -noabc, if -lut)");
|
run(abc + " -fast -lut k", "(unless -noabc, if -lut)");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (lut)
|
if (lut)
|
||||||
run(stringf("%s -fast -lut %d", abc.c_str(), lut));
|
run(stringf("%s -fast -lut %d", abc.c_str(), lut));
|
||||||
else
|
else
|
||||||
run(abc + " -fast");
|
run(abc + " -fast");
|
||||||
}
|
}
|
||||||
run("opt -fast", " (unless -noabc)");
|
run("opt -fast", " (unless -noabc)");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_label("check"))
|
if (check_label("check")) {
|
||||||
{
|
|
||||||
run("hierarchy -check");
|
run("hierarchy -check");
|
||||||
run("stat");
|
run("stat");
|
||||||
run("check");
|
run("check");
|
||||||
|
|
Loading…
Reference in a new issue