yosys/passes/memory/memory_share.cc

527 lines
18 KiB
C++
Raw Normal View History

2014-07-18 05:40:01 -05:00
/*
* yosys -- Yosys Open SYnthesis Suite
*
* Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
2015-07-02 04:14:30 -05:00
*
2014-07-18 05:40:01 -05:00
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
2015-07-02 04:14:30 -05:00
*
2014-07-18 05:40:01 -05:00
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
2014-07-31 16:30:18 -05:00
#include "kernel/yosys.h"
#include "kernel/satgen.h"
2014-07-18 05:40:01 -05:00
#include "kernel/sigtools.h"
2014-07-31 16:30:18 -05:00
#include "kernel/modtools.h"
2021-05-23 10:20:51 -05:00
#include "kernel/mem.h"
2014-07-31 16:30:18 -05:00
2014-09-27 09:17:53 -05:00
USING_YOSYS_NAMESPACE
2014-07-31 16:30:18 -05:00
PRIVATE_NAMESPACE_BEGIN
2014-07-18 05:40:01 -05:00
struct MemoryShareWorker
{
RTLIL::Design *design;
RTLIL::Module *module;
SigMap sigmap, sigmap_xmux;
ModWalker modwalker;
CellTypes cone_ct;
// ------------------------------------------------------
// Consolidate write ports that write to the same address
// ------------------------------------------------------
2014-07-18 05:40:01 -05:00
RTLIL::SigSpec mask_en_naive(RTLIL::SigSpec do_mask, RTLIL::SigSpec bits, RTLIL::SigSpec mask_bits)
{
// this is the naive version of the function that does not care about grouping the EN bits.
RTLIL::SigSpec inv_mask_bits = module->Not(NEW_ID, mask_bits);
RTLIL::SigSpec inv_mask_bits_filtered = module->Mux(NEW_ID, RTLIL::SigSpec(RTLIL::State::S1, bits.size()), inv_mask_bits, do_mask);
2014-07-18 05:40:01 -05:00
RTLIL::SigSpec result = module->And(NEW_ID, inv_mask_bits_filtered, bits);
return result;
}
RTLIL::SigSpec mask_en_grouped(RTLIL::SigSpec do_mask, RTLIL::SigSpec bits, RTLIL::SigSpec mask_bits)
{
// this version of the function preserves the bit grouping in the EN bits.
std::vector<RTLIL::SigBit> v_bits = bits;
std::vector<RTLIL::SigBit> v_mask_bits = mask_bits;
std::map<std::pair<RTLIL::SigBit, RTLIL::SigBit>, std::pair<int, std::vector<int>>> groups;
RTLIL::SigSpec grouped_bits, grouped_mask_bits;
for (int i = 0; i < bits.size(); i++) {
2014-07-18 05:40:01 -05:00
std::pair<RTLIL::SigBit, RTLIL::SigBit> key(v_bits[i], v_mask_bits[i]);
if (groups.count(key) == 0) {
groups[key].first = grouped_bits.size();
grouped_bits.append(v_bits[i]);
grouped_mask_bits.append(v_mask_bits[i]);
2014-07-18 05:40:01 -05:00
}
groups[key].second.push_back(i);
}
std::vector<RTLIL::SigBit> grouped_result = mask_en_naive(do_mask, grouped_bits, grouped_mask_bits);
RTLIL::SigSpec result;
for (int i = 0; i < bits.size(); i++) {
2014-07-18 05:40:01 -05:00
std::pair<RTLIL::SigBit, RTLIL::SigBit> key(v_bits[i], v_mask_bits[i]);
result.append(grouped_result.at(groups.at(key).first));
2014-07-18 05:40:01 -05:00
}
return result;
}
void merge_en_data(RTLIL::SigSpec &merged_en, RTLIL::SigSpec &merged_data, RTLIL::SigSpec next_en, RTLIL::SigSpec next_data)
{
std::vector<RTLIL::SigBit> v_old_en = merged_en;
std::vector<RTLIL::SigBit> v_next_en = next_en;
// The new merged_en signal is just the old merged_en signal and next_en OR'ed together.
// But of course we need to preserve the bit grouping..
std::map<std::pair<RTLIL::SigBit, RTLIL::SigBit>, int> groups;
std::vector<RTLIL::SigBit> grouped_old_en, grouped_next_en;
RTLIL::SigSpec new_merged_en;
for (int i = 0; i < int(v_old_en.size()); i++) {
std::pair<RTLIL::SigBit, RTLIL::SigBit> key(v_old_en[i], v_next_en[i]);
if (groups.count(key) == 0) {
groups[key] = grouped_old_en.size();
grouped_old_en.push_back(key.first);
grouped_next_en.push_back(key.second);
}
}
std::vector<RTLIL::SigBit> grouped_new_en = module->Or(NEW_ID, grouped_old_en, grouped_next_en);
for (int i = 0; i < int(v_old_en.size()); i++) {
std::pair<RTLIL::SigBit, RTLIL::SigBit> key(v_old_en[i], v_next_en[i]);
new_merged_en.append(grouped_new_en.at(groups.at(key)));
2014-07-18 05:40:01 -05:00
}
// Create the new merged_data signal.
RTLIL::SigSpec new_merged_data(RTLIL::State::Sx, merged_data.size());
2014-07-18 05:40:01 -05:00
RTLIL::SigSpec old_data_set = module->And(NEW_ID, merged_en, merged_data);
RTLIL::SigSpec old_data_unset = module->And(NEW_ID, merged_en, module->Not(NEW_ID, merged_data));
RTLIL::SigSpec new_data_set = module->And(NEW_ID, next_en, next_data);
RTLIL::SigSpec new_data_unset = module->And(NEW_ID, next_en, module->Not(NEW_ID, next_data));
new_merged_data = module->Or(NEW_ID, new_merged_data, old_data_set);
new_merged_data = module->And(NEW_ID, new_merged_data, module->Not(NEW_ID, old_data_unset));
new_merged_data = module->Or(NEW_ID, new_merged_data, new_data_set);
new_merged_data = module->And(NEW_ID, new_merged_data, module->Not(NEW_ID, new_data_unset));
// Update merged_* signals
merged_en = new_merged_en;
merged_data = new_merged_data;
}
2021-05-23 10:20:51 -05:00
void consolidate_wr_by_addr(Mem &mem)
2014-07-18 05:40:01 -05:00
{
2021-05-23 10:20:51 -05:00
if (GetSize(mem.wr_ports) <= 1)
return;
2021-05-23 10:20:51 -05:00
log("Consolidating write ports of memory %s.%s by address:\n", log_id(module), log_id(mem.memid));
2014-07-18 05:40:01 -05:00
std::map<RTLIL::SigSpec, int> last_port_by_addr;
std::vector<std::vector<bool>> active_bits_on_port;
2014-07-18 05:40:01 -05:00
bool cache_clk_enable = false;
bool cache_clk_polarity = false;
RTLIL::SigSpec cache_clk;
2021-05-24 18:55:44 -05:00
int cache_wide_log2 = 0;
2014-07-18 05:40:01 -05:00
2021-05-23 10:20:51 -05:00
bool changed = false;
for (int i = 0; i < GetSize(mem.wr_ports); i++)
2014-07-18 05:40:01 -05:00
{
2021-05-23 10:20:51 -05:00
auto &port = mem.wr_ports[i];
RTLIL::SigSpec addr = sigmap_xmux(port.addr);
2014-07-18 05:40:01 -05:00
2021-05-23 10:20:51 -05:00
if (port.clk_enable != cache_clk_enable ||
2021-05-24 18:55:44 -05:00
port.wide_log2 != cache_wide_log2 ||
2021-05-23 10:20:51 -05:00
(cache_clk_enable && (sigmap(port.clk) != cache_clk ||
port.clk_polarity != cache_clk_polarity)))
2014-07-18 05:40:01 -05:00
{
2021-05-23 10:20:51 -05:00
cache_clk_enable = port.clk_enable;
cache_clk_polarity = port.clk_polarity;
cache_clk = sigmap(port.clk);
2021-05-24 18:55:44 -05:00
cache_wide_log2 = port.wide_log2;
2014-07-18 05:40:01 -05:00
last_port_by_addr.clear();
if (cache_clk_enable)
log(" New clock domain: %s %s\n", cache_clk_polarity ? "posedge" : "negedge", log_signal(cache_clk));
else
log(" New clock domain: unclocked\n");
}
2021-05-23 10:20:51 -05:00
log(" Port %d has addr %s.\n", i, log_signal(addr));
2014-07-18 05:40:01 -05:00
log(" Active bits: ");
2021-05-23 10:20:51 -05:00
std::vector<RTLIL::SigBit> en_bits = sigmap(port.en);
active_bits_on_port.push_back(std::vector<bool>(en_bits.size()));
for (int k = int(en_bits.size())-1; k >= 0; k--) {
active_bits_on_port[i][k] = en_bits[k].wire != NULL || en_bits[k].data != RTLIL::State::S0;
log("%c", active_bits_on_port[i][k] ? '1' : '0');
}
log("\n");
2014-07-18 05:40:01 -05:00
if (last_port_by_addr.count(addr))
{
int last_i = last_port_by_addr.at(addr);
log(" Merging port %d into this one.\n", last_i);
bool found_overlapping_bits = false;
for (int k = 0; k < int(en_bits.size()); k++) {
if (active_bits_on_port[i][k] && active_bits_on_port[last_i][k])
found_overlapping_bits = true;
active_bits_on_port[i][k] = active_bits_on_port[i][k] || active_bits_on_port[last_i][k];
}
2014-07-18 05:40:01 -05:00
// Force this ports addr input to addr directly (skip don't care muxes)
2021-05-23 10:20:51 -05:00
port.addr = addr;
2014-07-18 05:40:01 -05:00
// If any of the ports between `last_i' and `i' write to the same address, this
// will have priority over whatever `last_i` wrote. So we need to revisit those
// ports and mask the EN bits accordingly.
2021-05-23 10:20:51 -05:00
RTLIL::SigSpec merged_en = sigmap(mem.wr_ports[last_i].en);
2014-07-18 05:40:01 -05:00
for (int j = last_i+1; j < i; j++)
{
2021-05-23 10:20:51 -05:00
if (mem.wr_ports[j].removed)
2014-07-18 05:40:01 -05:00
continue;
for (int k = 0; k < int(en_bits.size()); k++)
if (active_bits_on_port[i][k] && active_bits_on_port[j][k])
goto found_overlapping_bits_i_j;
if (0) {
found_overlapping_bits_i_j:
log(" Creating collosion-detect logic for port %d.\n", j);
2014-07-21 05:35:06 -05:00
RTLIL::SigSpec is_same_addr = module->addWire(NEW_ID);
2021-05-23 10:20:51 -05:00
module->addEq(NEW_ID, addr, mem.wr_ports[j].addr, is_same_addr);
merged_en = mask_en_grouped(is_same_addr, merged_en, sigmap(mem.wr_ports[j].en));
}
2014-07-18 05:40:01 -05:00
}
// Then we need to merge the (masked) EN and the DATA signals.
2021-05-23 10:20:51 -05:00
RTLIL::SigSpec merged_data = mem.wr_ports[last_i].data;
if (found_overlapping_bits) {
log(" Creating logic for merging DATA and EN ports.\n");
2021-05-23 10:20:51 -05:00
merge_en_data(merged_en, merged_data, sigmap(port.en), sigmap(port.data));
} else {
2021-05-23 10:20:51 -05:00
RTLIL::SigSpec cell_en = sigmap(port.en);
RTLIL::SigSpec cell_data = sigmap(port.data);
for (int k = 0; k < int(en_bits.size()); k++)
if (!active_bits_on_port[last_i][k]) {
merged_en.replace(k, cell_en.extract(k, 1));
merged_data.replace(k, cell_data.extract(k, 1));
}
}
2014-07-18 05:40:01 -05:00
// Connect the new EN and DATA signals and remove the old write port.
2021-05-23 10:20:51 -05:00
port.en = merged_en;
port.data = merged_data;
2014-07-18 05:40:01 -05:00
2021-05-23 10:20:51 -05:00
mem.wr_ports[last_i].removed = true;
changed = true;
log(" Active bits: ");
2021-05-23 10:20:51 -05:00
std::vector<RTLIL::SigBit> en_bits = sigmap(port.en);
active_bits_on_port.push_back(std::vector<bool>(en_bits.size()));
for (int k = int(en_bits.size())-1; k >= 0; k--)
log("%c", active_bits_on_port[i][k] ? '1' : '0');
log("\n");
2014-07-18 05:40:01 -05:00
}
last_port_by_addr[addr] = i;
}
2021-05-23 10:20:51 -05:00
if (changed)
mem.emit();
2014-07-18 05:40:01 -05:00
}
// --------------------------------------------------------
// Consolidate write ports using sat-based resource sharing
// --------------------------------------------------------
2021-05-23 10:20:51 -05:00
void consolidate_wr_using_sat(Mem &mem)
{
2021-05-23 10:20:51 -05:00
if (GetSize(mem.wr_ports) <= 1)
return;
2015-02-21 05:15:41 -06:00
ezSatPtr ez;
SatGen satgen(ez.get(), &modwalker.sigmap);
// find list of considered ports and port pairs
std::set<int> considered_ports;
std::set<int> considered_port_pairs;
2021-05-23 10:20:51 -05:00
for (int i = 0; i < GetSize(mem.wr_ports); i++) {
auto &port = mem.wr_ports[i];
std::vector<RTLIL::SigBit> bits = modwalker.sigmap(port.en);
for (auto bit : bits)
if (bit == RTLIL::State::S1)
goto port_is_always_active;
if (modwalker.has_drivers(bits))
considered_ports.insert(i);
port_is_always_active:;
}
2021-05-23 10:20:51 -05:00
log("Consolidating write ports of memory %s.%s using sat-based resource sharing:\n", log_id(module), log_id(mem.memid));
bool cache_clk_enable = false;
bool cache_clk_polarity = false;
RTLIL::SigSpec cache_clk;
2021-05-24 18:55:44 -05:00
int cache_wide_log2 = 0;
2021-05-23 10:20:51 -05:00
for (int i = 0; i < GetSize(mem.wr_ports); i++)
{
2021-05-23 10:20:51 -05:00
auto &port = mem.wr_ports[i];
2021-05-23 10:20:51 -05:00
if (port.clk_enable != cache_clk_enable ||
2021-05-24 18:55:44 -05:00
port.wide_log2 != cache_wide_log2 ||
2021-05-23 10:20:51 -05:00
(cache_clk_enable && (sigmap(port.clk) != cache_clk ||
port.clk_polarity != cache_clk_polarity)))
{
2021-05-23 10:20:51 -05:00
cache_clk_enable = port.clk_enable;
cache_clk_polarity = port.clk_polarity;
cache_clk = sigmap(port.clk);
2021-05-24 18:55:44 -05:00
cache_wide_log2 = port.wide_log2;
}
else if (i > 0 && considered_ports.count(i-1) && considered_ports.count(i))
considered_port_pairs.insert(i);
if (cache_clk_enable)
2021-05-23 10:20:51 -05:00
log(" Port %d on %s %s: %s\n", i,
cache_clk_polarity ? "posedge" : "negedge", log_signal(cache_clk),
considered_ports.count(i) ? "considered" : "not considered");
else
2021-05-23 10:20:51 -05:00
log(" Port %d unclocked: %s\n", i,
considered_ports.count(i) ? "considered" : "not considered");
}
if (considered_port_pairs.size() < 1) {
log(" No two subsequent ports in same clock domain considered -> nothing to consolidate.\n");
return;
}
// create SAT representation of common input cone of all considered EN signals
2015-02-04 11:52:54 -06:00
pool<Wire*> one_hot_wires;
std::set<RTLIL::Cell*> sat_cells;
std::set<RTLIL::SigBit> bits_queue;
std::map<int, int> port_to_sat_variable;
2021-05-23 10:20:51 -05:00
for (int i = 0; i < GetSize(mem.wr_ports); i++)
if (considered_port_pairs.count(i) || considered_port_pairs.count(i+1))
{
2021-05-23 10:20:51 -05:00
RTLIL::SigSpec sig = modwalker.sigmap(mem.wr_ports[i].en);
2015-02-21 05:15:41 -06:00
port_to_sat_variable[i] = ez->expression(ez->OpOr, satgen.importSigSpec(sig));
std::vector<RTLIL::SigBit> bits = sig;
bits_queue.insert(bits.begin(), bits.end());
}
while (!bits_queue.empty())
{
2015-02-04 11:52:54 -06:00
for (auto bit : bits_queue)
if (bit.wire && bit.wire->get_bool_attribute(ID::onehot))
2015-02-04 11:52:54 -06:00
one_hot_wires.insert(bit.wire);
2014-12-27 05:02:57 -06:00
pool<ModWalker::PortBit> portbits;
modwalker.get_drivers(portbits, bits_queue);
bits_queue.clear();
for (auto &pbit : portbits)
if (sat_cells.count(pbit.cell) == 0 && cone_ct.cell_known(pbit.cell->type)) {
2014-12-27 05:02:57 -06:00
pool<RTLIL::SigBit> &cell_inputs = modwalker.cell_inputs[pbit.cell];
bits_queue.insert(cell_inputs.begin(), cell_inputs.end());
sat_cells.insert(pbit.cell);
}
}
2015-02-04 11:52:54 -06:00
for (auto wire : one_hot_wires) {
log(" Adding one-hot constraint for wire %s.\n", log_id(wire));
vector<int> ez_wire_bits = satgen.importSigSpec(wire);
for (int i : ez_wire_bits)
for (int j : ez_wire_bits)
2015-02-21 05:15:41 -06:00
if (i != j) ez->assume(ez->NOT(i), j);
2015-02-04 11:52:54 -06:00
}
log(" Common input cone for all EN signals: %d cells.\n", int(sat_cells.size()));
for (auto cell : sat_cells)
satgen.importCell(cell);
2015-02-21 05:15:41 -06:00
log(" Size of unconstrained SAT problem: %d variables, %d clauses\n", ez->numCnfVariables(), ez->numCnfClauses());
// merge subsequent ports if possible
2021-05-23 10:20:51 -05:00
bool changed = false;
for (int i = 0; i < GetSize(mem.wr_ports); i++)
{
if (!considered_port_pairs.count(i))
continue;
2015-02-21 05:15:41 -06:00
if (ez->solve(port_to_sat_variable.at(i-1), port_to_sat_variable.at(i))) {
log(" According to SAT solver sharing of port %d with port %d is not possible.\n", i-1, i);
continue;
}
log(" Merging port %d into port %d.\n", i-1, i);
2015-02-21 05:15:41 -06:00
port_to_sat_variable.at(i) = ez->OR(port_to_sat_variable.at(i-1), port_to_sat_variable.at(i));
2021-05-23 10:20:51 -05:00
RTLIL::SigSpec last_addr = mem.wr_ports[i-1].addr;
RTLIL::SigSpec last_data = mem.wr_ports[i-1].data;
std::vector<RTLIL::SigBit> last_en = modwalker.sigmap(mem.wr_ports[i-1].en);
2021-05-23 10:20:51 -05:00
RTLIL::SigSpec this_addr = mem.wr_ports[i].addr;
RTLIL::SigSpec this_data = mem.wr_ports[i].data;
std::vector<RTLIL::SigBit> this_en = modwalker.sigmap(mem.wr_ports[i].en);
RTLIL::SigBit this_en_active = module->ReduceOr(NEW_ID, this_en);
if (GetSize(last_addr) < GetSize(this_addr))
last_addr.extend_u0(GetSize(this_addr));
else
this_addr.extend_u0(GetSize(last_addr));
2021-05-23 10:20:51 -05:00
mem.wr_ports[i].addr = module->Mux(NEW_ID, last_addr, this_addr, this_en_active);
mem.wr_ports[i].data = module->Mux(NEW_ID, last_data, this_data, this_en_active);
std::map<std::pair<RTLIL::SigBit, RTLIL::SigBit>, int> groups_en;
RTLIL::SigSpec grouped_last_en, grouped_this_en, en;
2014-07-21 05:35:06 -05:00
RTLIL::Wire *grouped_en = module->addWire(NEW_ID, 0);
for (int j = 0; j < int(this_en.size()); j++) {
std::pair<RTLIL::SigBit, RTLIL::SigBit> key(last_en[j], this_en[j]);
if (!groups_en.count(key)) {
grouped_last_en.append(last_en[j]);
grouped_this_en.append(this_en[j]);
groups_en[key] = grouped_en->width;
grouped_en->width++;
}
en.append(RTLIL::SigSpec(grouped_en, groups_en[key]));
}
module->addMux(NEW_ID, grouped_last_en, grouped_this_en, this_en_active, grouped_en);
2021-05-23 10:20:51 -05:00
mem.wr_ports[i].en = en;
2021-05-23 10:20:51 -05:00
mem.wr_ports[i-1].removed = true;
changed = true;
}
2021-05-23 10:20:51 -05:00
if (changed)
mem.emit();
}
// -------------
// Setup and run
// -------------
MemoryShareWorker(RTLIL::Design *design) : design(design), modwalker(design) {}
void operator()(RTLIL::Module* module)
{
2021-05-23 10:20:51 -05:00
std::vector<Mem> memories = Mem::get_selected_memories(module);
2020-03-30 10:22:12 -05:00
this->module = module;
sigmap.set(module);
sigmap_xmux = sigmap;
for (auto cell : module->cells())
2014-07-18 05:40:01 -05:00
{
if (cell->type == ID($mux))
2014-07-18 05:40:01 -05:00
{
2020-03-12 14:57:01 -05:00
RTLIL::SigSpec sig_a = sigmap_xmux(cell->getPort(ID::A));
RTLIL::SigSpec sig_b = sigmap_xmux(cell->getPort(ID::B));
2014-07-18 05:40:01 -05:00
if (sig_a.is_fully_undef())
2020-03-12 14:57:01 -05:00
sigmap_xmux.add(cell->getPort(ID::Y), sig_b);
2014-07-18 05:40:01 -05:00
else if (sig_b.is_fully_undef())
2020-03-12 14:57:01 -05:00
sigmap_xmux.add(cell->getPort(ID::Y), sig_a);
}
2014-07-18 05:40:01 -05:00
}
2021-05-23 10:20:51 -05:00
for (auto &mem : memories)
consolidate_wr_by_addr(mem);
cone_ct.setup_internals();
cone_ct.cell_types.erase(ID($mul));
cone_ct.cell_types.erase(ID($mod));
cone_ct.cell_types.erase(ID($div));
cone_ct.cell_types.erase(ID($modfloor));
cone_ct.cell_types.erase(ID($divfloor));
cone_ct.cell_types.erase(ID($pow));
cone_ct.cell_types.erase(ID($shl));
cone_ct.cell_types.erase(ID($shr));
cone_ct.cell_types.erase(ID($sshl));
cone_ct.cell_types.erase(ID($sshr));
cone_ct.cell_types.erase(ID($shift));
cone_ct.cell_types.erase(ID($shiftx));
modwalker.setup(module, &cone_ct);
2021-05-23 10:20:51 -05:00
for (auto &mem : memories)
consolidate_wr_using_sat(mem);
2014-07-18 05:40:01 -05:00
}
};
struct MemorySharePass : public Pass {
MemorySharePass() : Pass("memory_share", "consolidate memory ports") { }
2020-06-18 18:34:52 -05:00
void help() override
2014-07-18 05:40:01 -05:00
{
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
log("\n");
log(" memory_share [selection]\n");
log("\n");
log("This pass merges share-able memory ports into single memory ports.\n");
log("\n");
2014-07-19 08:34:14 -05:00
log("The following methods are used to consolidate the number of memory ports:\n");
log("\n");
log(" - When multiple write ports access the same address then this is converted\n");
2014-07-19 08:34:14 -05:00
log(" to a single write port with a more complex data and/or enable logic path.\n");
log("\n");
log(" - When multiple write ports are never accessed at the same time (a SAT\n");
log(" solver is used to determine this), then the ports are merged into a single\n");
log(" write port.\n");
log("\n");
log("Note that in addition to the algorithms implemented in this pass, the $memrd\n");
log("and $memwr cells are also subject to generic resource sharing passes (and other\n");
2016-03-31 01:52:49 -05:00
log("optimizations) such as \"share\" and \"opt_merge\".\n");
2014-07-19 08:34:14 -05:00
log("\n");
2014-07-18 05:40:01 -05:00
}
2020-06-18 18:34:52 -05:00
void execute(std::vector<std::string> args, RTLIL::Design *design) override {
2016-09-08 02:57:16 -05:00
log_header(design, "Executing MEMORY_SHARE pass (consolidating $memrd/$memwr cells).\n");
2014-07-18 05:40:01 -05:00
extra_args(args, 1, design);
MemoryShareWorker msw(design);
for (auto module : design->selected_modules())
msw(module);
2014-07-18 05:40:01 -05:00
}
} MemorySharePass;
2014-07-31 16:30:18 -05:00
PRIVATE_NAMESPACE_END