#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;
#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
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;
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);
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":
outfile = a
elif o == "-d":
debug = True
+ elif o == "-g":
+ genhdr = True
if outfile is None:
outfile = "/dev/stdout"
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)
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)