yosys/passes/memory/memory_unpack.cc

53 lines
1.8 KiB
C++
Raw Permalink Normal View History

2014-01-16 17:05:02 -06:00
/*
* yosys -- Yosys Open SYnthesis Suite
*
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
2015-07-02 04:14:30 -05:00
*
2014-01-16 17:05:02 -06: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-01-16 17:05:02 -06: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.
*
*/
2020-10-17 15:20:47 -05:00
#include "kernel/yosys.h"
#include "kernel/mem.h"
2014-01-16 17:05:02 -06:00
2014-09-27 09:17:53 -05:00
USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN
2014-01-16 17:05:02 -06:00
struct MemoryUnpackPass : public Pass {
MemoryUnpackPass() : Pass("memory_unpack", "unpack multi-port memory cells") { }
2020-06-18 18:34:52 -05:00
void help() override
2014-01-16 17:05:02 -06:00
{
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
log("\n");
log(" memory_unpack [selection]\n");
log("\n");
log("This pass converts the multi-port $mem memory cells into individual $memrd and\n");
log("$memwr cells. It is the counterpart to the memory_collect pass.\n");
log("\n");
}
2020-06-18 18:34:52 -05:00
void execute(std::vector<std::string> args, RTLIL::Design *design) override {
2016-04-21 16:28:37 -05:00
log_header(design, "Executing MEMORY_UNPACK pass (generating $memrd/$memwr cells form $mem cells).\n");
2014-01-16 17:05:02 -06:00
extra_args(args, 1, design);
2020-10-17 15:20:47 -05:00
for (auto module : design->selected_modules()) {
for (auto &mem : Mem::get_selected_memories(module)) {
if (mem.packed) {
mem.packed = false;
mem.emit();
}
}
}
2014-01-16 17:05:02 -06:00
}
} MemoryUnpackPass;
2015-07-02 04:14:30 -05:00
2014-09-27 09:17:53 -05:00
PRIVATE_NAMESPACE_END