pmgen progress

Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
Clifford Wolf 2019-04-30 10:51:51 +02:00
parent d2d402e625
commit 4306bebe58
4 changed files with 27 additions and 13 deletions

View File

@ -19,11 +19,12 @@
#include "kernel/yosys.h"
#include "kernel/sigtools.h"
#include "passes/pmgen/ice40_dsp_pm.h"
USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN
#include "passes/pmgen/ice40_dsp_pm.h"
void create_ice40_dsp(ice40_dsp_pm &pm)
{
auto &st = pm.st_ice40_dsp;

View File

@ -19,11 +19,14 @@
#include "kernel/yosys.h"
#include "kernel/sigtools.h"
#include "passes/pmgen/peepopt_pm.h"
USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN
bool did_something;
#include "passes/pmgen/peepopt_pm.h"
struct PeepoptPass : public Pass {
PeepoptPass() : Pass("peepopt", "collection of peephole optimizers") { }
void help() YS_OVERRIDE
@ -51,8 +54,12 @@ struct PeepoptPass : public Pass {
extra_args(args, argidx, design);
for (auto module : design->selected_modules()) {
peepopt_pm pm(module, module->selected_cells());
pm.run_shiftmul();
did_something = true;
while (did_something) {
did_something = false;
peepopt_pm pm(module, module->selected_cells());
pm.run_shiftmul();
}
}
}
} PeepoptPass;

View File

@ -45,6 +45,7 @@ code
if (GetSize(port(shift, \Y)) > const_factor)
reject;
did_something = true;
log("shiftmul pattern in %s: shift=%s, mul=%s\n", log_id(module), log_id(shift), log_id(mul));
int new_const_factor_log2 = ceil_log2(const_factor);

View File

@ -11,8 +11,9 @@ prefix = None
pmgfiles = list()
outfile = None
debug = False
genhdr = False
opts, args = getopt.getopt(sys.argv[1:], "p:o:d")
opts, args = getopt.getopt(sys.argv[1:], "p:o:dg")
for o, a in opts:
if o == "-p":
@ -21,6 +22,8 @@ for o, a in opts:
outfile = a
elif o == "-d":
debug = True
elif o == "-g":
genhdr = True
if outfile is None:
outfile = "/dev/stdout"
@ -249,12 +252,12 @@ with open(outfile, "w") as f:
print("// Generated by pmgen.py from {}".format(fn), file=f)
print("", file=f)
print("#include \"kernel/yosys.h\"", file=f)
print("#include \"kernel/sigtools.h\"", file=f)
print("", file=f)
print("YOSYS_NAMESPACE_BEGIN", file=f)
print("", file=f)
if genhdr:
print("#include \"kernel/yosys.h\"", file=f)
print("#include \"kernel/sigtools.h\"", file=f)
print("", file=f)
print("YOSYS_NAMESPACE_BEGIN", file=f)
print("", file=f)
print("struct {}_pm {{".format(prefix), file=f)
print(" Module *module;", file=f)
@ -564,5 +567,7 @@ with open(outfile, "w") as f:
print("", file=f)
print("};", file=f)
print("", file=f)
print("YOSYS_NAMESPACE_END", file=f)
if genhdr:
print("", file=f)
print("YOSYS_NAMESPACE_END", file=f)