Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
widlarizer committed Sep 2, 2024
1 parent 0fc5812 commit b71219b
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions passes/techmap/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ OBJS += passes/techmap/dffunmap.o
OBJS += passes/techmap/flowmap.o
OBJS += passes/techmap/extractinv.o
OBJS += passes/techmap/cellmatch.o
OBJS += passes/techmap/clock_gate.o
endif

ifeq ($(DISABLE_SPAWN),0)
Expand Down
62 changes: 62 additions & 0 deletions passes/techmap/clock_gate.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include "kernel/yosys.h"
#include "kernel/ff.h"

USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN

struct ClockgatePass : public Pass {
ClockgatePass() : Pass("clock_gate", "extract clock gating out of flip flops") { }
void help() override
{
// TODO
}

SigMap sigmap;
FfInitVals initvals;

void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing CLOCK_GATE pass (extract clock gating out of flip flops).\n");

std::string pos_icg_cell;
std::string neg_icg_cell;
size_t argidx;
for (argidx = 1; argidx < args.size(); argidx++)
{
if (args[argidx] == "-pos" && argidx+1 < args.size()) {
pos_icg_cell = args[++argidx];
}
if (args[argidx] == "-neg" && argidx+1 < args.size()) {
neg_icg_cell = args[++argidx];
}
break;
}


extra_args(args, argidx, design);

for (auto module : design->selected_whole_modules()) {
sigmap.set(module);
initvals.set(&sigmap, module);
for (auto cell : module->cells()) {
if (!RTLIL::builtin_ff_cell_types().count(cell->type))
continue;
FfData ff(&initvals, cell);
if (ff.has_ce) {

// TODO do stuff


bool ce_pol = ff.pol_ce;
if (!ce_pol) {
//TODO invert CE
}
}
}
}

}
} ClockgatePass;


PRIVATE_NAMESPACE_END

0 comments on commit b71219b

Please sign in to comment.