39 std::set<RTLIL::IdString>
ports;
99 std::vector<RTLIL::SigSpec> chunks;
103 if (bit.wire ==
NULL)
106 chunks.back().append(bit);
108 chunks.push_back(bit);
116 if (last_bit+1 == this_bit)
117 chunks.back().append(bit);
119 chunks.push_back(bit);
124 log(
" Failed to generate spliced signal %s.\n",
log_signal(sig));
131 for (
size_t i = 1; i < chunks.size(); i++) {
139 new_sig = cell->
getPort(
"\\Y");
156 if (it.second->port_input) {
165 for (
auto &conn : it.second->connections())
188 for (
auto &conn : it.second->connections_)
190 if (
ports.size() > 0 && !
ports.count(conn.first))
207 std::vector<std::pair<RTLIL::Wire*, RTLIL::SigSpec>> rework_wires;
218 rework_wires.push_back(std::pair<RTLIL::Wire*, RTLIL::SigSpec>(it.second, new_sig));
220 if (!it.second->port_input) {
223 rework_wires.push_back(std::pair<RTLIL::Wire*, RTLIL::SigSpec>(it.second,
spliced_signals_cache.at(sig)));
225 rework_wires.push_back(std::pair<RTLIL::Wire*, RTLIL::SigSpec>(it.second,
sliced_signals_cache.at(sig)));
228 for (
auto &it : rework_wires)
235 it.first->port_input =
false;
236 it.first->port_output =
false;
249 log(
" splice [options] [selection]\n");
251 log(
"This command adds $slice and $concat cells to the design to make the splicing\n");
252 log(
"of multi-bit signals explicit. This for example is useful for coarse grain\n");
253 log(
"synthesis, where dedidacted hardware is needed to splice signals.\n");
255 log(
" -sel_by_cell\n");
256 log(
" only select the cell ports to rewire by the cell. if the selection\n");
257 log(
" contains a cell, than all cell inputs are rewired, if necessary.\n");
259 log(
" -sel_by_wire\n");
260 log(
" only select the cell ports to rewire by the wire. if the selection\n");
261 log(
" contains a wire, than all cell ports driven by this wire are wired,\n");
262 log(
" if necessary.\n");
264 log(
" -sel_any_bit\n");
265 log(
" it is sufficient if the driver of any bit of a cell port is selected.\n");
266 log(
" by default all bits must be selected.\n");
268 log(
" -no_outputs\n");
269 log(
" do not rewire selected module outputs.\n");
271 log(
" -port <name>\n");
272 log(
" only rewire cell ports with the specified name. can be used multiple\n");
273 log(
" times. implies -no_output.\n");
275 log(
" -no_port <name>\n");
276 log(
" do not rewire cell ports with the specified name. can be used multiple\n");
277 log(
" times. can not be combined with -port <name>.\n");
279 log(
"By default selected output wires and all cell ports of selected cells driven\n");
280 log(
"by selected wires are rewired.\n");
285 bool sel_by_cell =
false;
286 bool sel_by_wire =
false;
287 bool sel_any_bit =
false;
288 bool no_outputs =
false;
289 std::set<RTLIL::IdString> ports, no_ports;
292 for (argidx = 1; argidx < args.size(); argidx++) {
293 if (args[argidx] ==
"-sel_by_cell") {
297 if (args[argidx] ==
"-sel_by_wire") {
301 if (args[argidx] ==
"-sel_any_bit") {
305 if (args[argidx] ==
"-no_outputs") {
309 if (args[argidx] ==
"-port" && argidx+1 < args.size()) {
314 if (args[argidx] ==
"-no_port" && argidx+1 < args.size()) {
322 if (sel_by_cell && sel_by_wire)
323 log_cmd_error(
"The options -sel_by_cell and -sel_by_wire are exclusive!\n");
325 if (sel_by_cell && sel_any_bit)
326 log_cmd_error(
"The options -sel_by_cell and -sel_any_bit are exclusive!\n");
328 if (!ports.empty() && !no_ports.empty())
329 log_cmd_error(
"The options -port and -no_port are exclusive!\n");
331 log_header(
"Executing SPLICE pass (creating cells for signal splicing).\n");
333 for (
auto &mod_it : design->
modules_)
335 if (!design->
selected(mod_it.second))
338 if (mod_it.second->processes.size()) {
339 log(
"Skipping module %s as it contains processes.\n", mod_it.second->name.c_str());
348 worker.
ports = ports;
bool selected(T1 *module) const
RTLIL::Cell * addCell(RTLIL::IdString name, RTLIL::IdString type)
void log_header(const char *format,...)
std::map< RTLIL::SigSpec, RTLIL::SigSpec > sliced_signals_cache
std::map< RTLIL::IdString, RTLIL::Wire * > wires_
RTLIL::SigSpec get_spliced_signal(RTLIL::SigSpec sig)
const char * log_signal(const RTLIL::SigSpec &sig, bool autoint)
void setPort(RTLIL::IdString portname, RTLIL::SigSpec signal)
std::set< RTLIL::IdString > ports
std::map< RTLIL::IdString, RTLIL::Const > parameters
static std::string escape_id(std::string str)
std::set< RTLIL::SigSpec > driven_chunks
bool cell_known(RTLIL::IdString type)
bool check_any(RTLIL::SigSpec sig)
void connect(const RTLIL::SigSig &conn)
std::map< RTLIL::SigSpec, RTLIL::SigSpec > spliced_signals_cache
#define PRIVATE_NAMESPACE_BEGIN
bool cell_output(RTLIL::IdString type, RTLIL::IdString port)
const RTLIL::SigSpec & getPort(RTLIL::IdString portname) const
bool is_fully_const() const
RTLIL::Wire * addWire(RTLIL::IdString name, int width=1)
std::vector< RTLIL::SigBit > driven_bits
#define PRIVATE_NAMESPACE_END
RTLIL::SigBit to_single_sigbit() const
bool check_all(RTLIL::SigSpec sig)
static const char * id2cstr(const RTLIL::IdString &str)
void log_cmd_error(const char *format,...)
RTLIL::SigSpec get_sliced_signal(RTLIL::SigSpec sig)
void add(RTLIL::SigSpec sig)
#define USING_YOSYS_NAMESPACE
std::map< RTLIL::IdString, RTLIL::Module * > modules_
std::map< RTLIL::IdString, RTLIL::Cell * > cells_
std::set< RTLIL::IdString > no_ports
std::map< RTLIL::SigBit, int > driven_bits_map
void log(const char *format,...)
RTLIL::SigSpec extract(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other=NULL) const
void append(const RTLIL::SigSpec &signal)
virtual void execute(std::vector< std::string > args, RTLIL::Design *design)
bool cell_input(RTLIL::IdString type, RTLIL::IdString port)
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)
std::pair< SigSpec, SigSpec > SigSig
std::vector< RTLIL::SigBit > to_sigbit_vector() const
void rename(RTLIL::Wire *wire, RTLIL::IdString new_name)
SpliceWorker(RTLIL::Design *design, RTLIL::Module *module)