31 sig.
replace(conn.first, conn.second);
43 for (
auto cell : dff_cells)
46 if (cell->getPort(
"\\CLK") != clk)
48 if (cell->parameters[
"\\CLK_POLARITY"].as_bool() !=
clk_polarity)
60 clk = cell->getPort(
"\\CLK");
61 clk_polarity = cell->parameters[
"\\CLK_POLARITY"].
as_bool();
62 goto replaced_this_bit;
81 log(
"no (compatible) $dff for address input found.\n");
87 log(
"no (compatible) $dff for data input found.\n");
93 log(
"no (compatible) $dff for enable input found.\n");
99 cell->
setPort(
"\\ADDR", sig_addr);
100 cell->
setPort(
"\\DATA", sig_data);
104 log(
"merged $dff to cell.\n");
108 log(
"no (compatible) $dff found.\n");
116 std::stringstream sstr;
117 sstr <<
"$memory_dff_disconnected$" << (
autoidx++);
121 for (
auto cell : module->
cells())
122 if (cell->type ==
"$dff") {
125 cell->setPort(
"\\Q", new_q);
141 cell->
setPort(
"\\CLK", clk_data);
142 cell->
setPort(
"\\DATA", sig_data);
146 log(
"merged data $dff to cell.\n");
155 cell->
setPort(
"\\CLK", clk_addr);
156 cell->
setPort(
"\\ADDR", sig_addr);
160 log(
"merged address $dff to cell.\n");
164 log(
"no (compatible) $dff found.\n");
169 std::vector<RTLIL::Cell*> dff_cells;
171 for (
auto cell : module->
cells())
172 if (cell->type ==
"$dff")
173 dff_cells.push_back(cell);
176 if (cell->type ==
"$memwr" && !cell->parameters[
"\\CLK_ENABLE"].as_bool())
181 if (cell->type ==
"$memrd" && !cell->parameters[
"\\CLK_ENABLE"].as_bool())
191 log(
" memory_dff [options] [selection]\n");
193 log(
"This pass detects DFFs at memory ports and merges them into the memory port.\n");
194 log(
"I.e. it consumes an asynchronous memory port and the flip-flops at its\n");
195 log(
"interface and yields a synchronous memory port.\n");
198 log(
" do not merge registers on read ports\n");
203 bool flag_wr_only =
false;
205 log_header(
"Executing MEMORY_DFF pass (merging $dff cells to $memrd and $memwr).\n");
208 for (argidx = 1; argidx < args.size(); argidx++) {
209 if (args[argidx] ==
"-wr_only") {
const char * c_str() const
void handle_wr_cell(RTLIL::Module *module, std::vector< RTLIL::Cell * > &dff_cells, RTLIL::Cell *cell)
void handle_rd_cell(RTLIL::Module *module, std::vector< RTLIL::Cell * > &dff_cells, RTLIL::Cell *cell)
void log_header(const char *format,...)
const std::vector< RTLIL::SigSig > & connections() const
void setPort(RTLIL::IdString portname, RTLIL::SigSpec signal)
std::map< RTLIL::IdString, RTLIL::Const > parameters
#define PRIVATE_NAMESPACE_BEGIN
const RTLIL::SigSpec & getPort(RTLIL::IdString portname) const
void handle_module(RTLIL::Module *module, bool flag_wr_only)
MemoryDffPass MemoryDffPass
RTLIL::Wire * addWire(RTLIL::IdString name, int width=1)
virtual void execute(std::vector< std::string > args, RTLIL::Design *design)
void disconnect_dff(RTLIL::Module *module, RTLIL::SigSpec sig)
std::vector< RTLIL::Cell * > selected_cells() const
#define PRIVATE_NAMESPACE_END
#define USING_YOSYS_NAMESPACE
RTLIL::ObjRange< RTLIL::Cell * > cells()
void replace(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with)
void log(const char *format,...)
USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN void normalize_sig(RTLIL::Module *module, RTLIL::SigSpec &sig)
RTLIL::SigSpec extract(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other=NULL) const
std::vector< RTLIL::Module * > selected_modules() const
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)
bool find_sig_before_dff(RTLIL::Module *module, std::vector< RTLIL::Cell * > &dff_cells, RTLIL::SigSpec &sig, RTLIL::SigSpec &clk, bool &clk_polarity, bool after=false)
YOSYS_NAMESPACE_BEGIN int autoidx