95 bool flag_ports =
false;
96 bool flag_driver =
false;
97 std::string format =
"[]:";
99 log_header(
"Executing SPLITNETS pass (splitting up multi-bit signals).\n");
102 for (argidx = 1; argidx <
args.size(); argidx++)
104 if (
args[argidx] ==
"-format" && argidx+1 <
args.size()) {
105 format =
args[++argidx];
108 if (
args[argidx] ==
"-ports") {
112 if (
args[argidx] ==
"-driver") {
120 for (
auto &mod_it : design->
modules_)
132 std::map<RTLIL::Wire*, std::set<int>> split_wires_at;
134 for (
auto &c : module->
cells_)
135 for (
auto &p : c.second->connections())
143 for (
auto &chunk : sig.
chunks()) {
144 if (chunk.wire ==
NULL)
146 if (chunk.wire->port_id == 0 || flag_ports) {
147 if (chunk.offset != 0)
148 split_wires_at[chunk.wire].insert(chunk.offset);
149 if (chunk.offset + chunk.width < chunk.wire->width)
150 split_wires_at[chunk.wire].insert(chunk.offset + chunk.width);
155 for (
auto &it : split_wires_at) {
157 for (
int next_cursor : it.second) {
158 worker.
append_wire(module, it.first, cursor, next_cursor - cursor, format);
159 cursor = next_cursor;
161 worker.
append_wire(module, it.first, cursor, it.first->width - cursor, format);
166 for (
auto &w : module->
wires_) {
168 if (wire->
width > 1 && (wire->
port_id == 0 || flag_ports) && design->
selected(module, w.second))
169 worker.
splitmap[wire] = std::vector<RTLIL::SigBit>();
173 for (
int i = 0; i < it.first->width; i++)
174 worker.
append_wire(module, it.first, i, 1, format);
179 std::set<RTLIL::Wire*> delete_wires;
181 delete_wires.insert(it.first);
182 module->
remove(delete_wires);
std::map< RTLIL::Wire *, std::vector< RTLIL::SigBit > > splitmap
bool selected(T1 *module) const
void log_header(const char *format,...)
std::map< RTLIL::IdString, RTLIL::Wire * > wires_
void rewrite_sigspecs(T functor)
bool cell_known(RTLIL::IdString type)
bool cell_output(RTLIL::IdString type, RTLIL::IdString port)
void append_wire(RTLIL::Module *module, RTLIL::Wire *wire, int offset, int width, std::string format)
std::map< RTLIL::IdString, RTLIL::Module * > modules_
std::map< RTLIL::IdString, RTLIL::Cell * > cells_
void remove(const std::set< RTLIL::Wire * > &wires)
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)
const std::vector< RTLIL::SigChunk > & chunks() const