yosys/passes/cmds/scatter.cc

74 lines
2.4 KiB
C++
Raw Normal View History

2013-06-12 07:41:33 -05:00
/*
* yosys -- Yosys Open SYnthesis Suite
*
* Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
2015-07-02 04:14:30 -05:00
*
2013-06-12 07:41:33 -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
*
2013-06-12 07:41:33 -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.
*
*/
#include "kernel/register.h"
#include "kernel/celltypes.h"
#include "kernel/rtlil.h"
#include "kernel/log.h"
2014-09-27 09:17:53 -05:00
USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN
2013-06-12 07:41:33 -05:00
struct ScatterPass : public Pass {
ScatterPass() : Pass("scatter", "add additional intermediate nets") { }
void help() YS_OVERRIDE
2013-06-12 07:41:33 -05:00
{
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
log("\n");
log(" scatter [selection]\n");
log("\n");
log("This command adds additional intermediate nets on all cell ports. This is used\n");
2013-08-21 05:16:44 -05:00
log("for testing the correct use of the SigMap helper in passes. If you don't know\n");
2013-06-12 07:41:33 -05:00
log("what this means: don't worry -- you only need this pass when testing your own\n");
log("extensions to Yosys.\n");
log("\n");
log("Use the opt_clean command to get rid of the additional nets.\n");
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
2013-06-12 07:41:33 -05:00
{
CellTypes ct(design);
extra_args(args, 1, design);
for (auto &mod_it : design->modules_)
2013-06-12 07:41:33 -05:00
{
if (!design->selected(mod_it.second))
continue;
for (auto &c : mod_it.second->cells_)
for (auto &p : c.second->connections_)
2013-06-12 07:41:33 -05:00
{
RTLIL::Wire *wire = mod_it.second->addWire(NEW_ID, p.second.size());
2013-06-12 07:41:33 -05:00
if (ct.cell_output(c.second->type, p.first)) {
RTLIL::SigSig sigsig(p.second, wire);
mod_it.second->connect(sigsig);
2013-06-12 07:41:33 -05:00
} else {
RTLIL::SigSig sigsig(wire, p.second);
mod_it.second->connect(sigsig);
2013-06-12 07:41:33 -05:00
}
p.second = wire;
}
}
}
} ScatterPass;
2015-07-02 04:14:30 -05:00
2014-09-27 09:17:53 -05:00
PRIVATE_NAMESPACE_END