struct WireInfo
{
RTLIL::IdString cell_name;
- RTLIL::SigChunk *chunk;
+ const RTLIL::SigChunk *chunk;
- WireInfo(RTLIL::IdString c, RTLIL::SigChunk* ch) : cell_name(c), chunk(ch) { }
+ WireInfo(RTLIL::IdString c, const RTLIL::SigChunk* ch) : cell_name(c), chunk(ch) { }
};
struct WireInfoOrder
return true;
}
-void dump_const(FILE *f, RTLIL::Const &data, int width = -1, int offset = 0, bool no_decimal = false, bool set_signed = false)
+void dump_const(FILE *f, const RTLIL::Const &data, int width = -1, int offset = 0, bool no_decimal = false, bool set_signed = false)
{
if (width < 0)
width = data.bits.size() - offset;
}
}
-void dump_sigchunk(FILE *f, RTLIL::SigChunk &chunk, bool no_decimal = false)
+void dump_sigchunk(FILE *f, const RTLIL::SigChunk &chunk, bool no_decimal = false)
{
if (chunk.wire == NULL) {
dump_const(f, chunk.data, chunk.width, chunk.offset, no_decimal);
sig.optimize();
for (size_t i = 0; i < sig.chunks().size(); i++)
{
- RTLIL::SigChunk &chunk = sig.chunks()[i];
+ RTLIL::SigChunk &chunk = sig.chunks_rw()[i];
if (chunk.wire == NULL)
continue;
RTLIL::SigSpec current_val = values_map(sig);
current_val.expand();
for (size_t i = 0; i < current_val.chunks().size(); i++) {
- RTLIL::SigChunk &chunk = current_val.chunks()[i];
+ const RTLIL::SigChunk &chunk = current_val.chunks()[i];
assert(chunk.wire != NULL || chunk.data.bits[0] == value.bits[i]);
}
#endif
RTLIL::Module *mod;
void operator()(RTLIL::SigSpec &sig)
{
- for (auto &c : sig.chunks())
+ for (auto &c : sig.chunks_rw())
if (c.wire != NULL)
c.wire = mod->wires.at(c.wire->name);
}
int width_;
public:
- std::vector<RTLIL::SigChunk> &chunks() { return chunks_; }
+ std::vector<RTLIL::SigChunk> &chunks_rw() { return chunks_; }
const std::vector<RTLIL::SigChunk> &chunks() const { return chunks_; }
int size() const { return width_; }
assert(from.chunks().size() == to.chunks().size());
for (size_t i = 0; i < from.chunks().size(); i++)
{
- RTLIL::SigChunk &cf = from.chunks()[i];
- RTLIL::SigChunk &ct = to.chunks()[i];
+ const RTLIL::SigChunk &cf = from.chunks()[i];
+ const RTLIL::SigChunk &ct = to.chunks()[i];
if (cf.wire == NULL)
continue;
sig.expand();
for (size_t i = 0; i < sig.chunks().size(); i++)
{
- RTLIL::SigChunk &c = sig.chunks()[i];
+ const RTLIL::SigChunk &c = sig.chunks()[i];
if (c.wire != NULL) {
register_bit(c);
set_bit(c, c);
void apply(RTLIL::SigSpec &sig) const
{
sig.expand();
- for (auto &c : sig.chunks())
+ for (auto &c : sig.chunks_rw())
map_bit(c);
sig.optimize();
}
void operator()(RTLIL::SigSpec &sig) {
sig.optimize();
- for (auto &c : sig.chunks())
+ for (auto &c : sig.chunks_rw())
if (c.wire != NULL && delete_wires_p->count(c.wire->name)) {
c.wire = module->addWire(NEW_ID, c.width);
c.offset = 0;
void operator()(RTLIL::SigSpec &sig)
{
sig.expand();
- for (auto &c : sig.chunks())
+ for (auto &c : sig.chunks_rw())
if (c.wire == NULL && c.data.bits.at(0) > RTLIL::State::S1)
c.data.bits.at(0) = next_bit();
sig.optimize();
}
if (sig.chunks().size() == 1) {
- RTLIL::SigChunk &c = sig.chunks()[0];
+ const RTLIL::SigChunk &c = sig.chunks()[0];
if (c.wire != NULL && design->selected_member(module->name, c.wire->name)) {
if (!range_check || c.wire->width == c.width)
return stringf("n%d", id2num(c.wire->name));
int pos = sig.size()-1;
int idx = single_idx_count++;
for (int i = int(sig.chunks().size())-1; i >= 0; i--) {
- RTLIL::SigChunk &c = sig.chunks()[i];
+ const RTLIL::SigChunk &c = sig.chunks()[i];
net = gen_signode_simple(c, false);
assert(!net.empty());
if (driver) {
void operator()(RTLIL::SigSpec &sig)
{
sig.expand();
- for (auto &c : sig.chunks())
+ for (auto &c : sig.chunks_rw())
if (splitmap.count(c.wire) > 0)
c = splitmap.at(c.wire).at(c.offset);
sig.optimize();
{
if (dont_care.size() > 0) {
sig.expand();
- for (auto &chunk : sig.chunks()) {
+ for (auto &chunk : sig.chunks_rw()) {
assert(chunk.width == 1);
if (dont_care.extract(chunk).size() > 0)
chunk.wire = NULL, chunk.data = RTLIL::Const(noconst_state);
ce.values_map.apply(sig);
sig.expand();
- for (auto &chunk : sig.chunks()) {
+ for (auto &chunk : sig.chunks_rw()) {
assert(chunk.width == 1);
if (chunk.wire != NULL)
chunk.wire = NULL, chunk.data = RTLIL::Const(noconst_state);
for (RTLIL::Cell *cell : submod.cells) {
RTLIL::Cell *new_cell = new RTLIL::Cell(*cell);
for (auto &conn : new_cell->connections)
- for (auto &c : conn.second.chunks())
+ for (auto &c : conn.second.chunks_rw())
if (c.wire != NULL) {
assert(wire_flags.count(c.wire) > 0);
c.wire = wire_flags[c.wire].new_wire;
for (size_t i = 0; i < sig.chunks().size(); i++)
{
- RTLIL::SigChunk &chunk = sig.chunks()[i];
+ RTLIL::SigChunk &chunk = sig.chunks_rw()[i];
if (chunk.wire == NULL)
continue;
RTLIL::SigSpec a = cell->connections["\\A"]; \
assign_map.apply(a); \
if (a.is_fully_const()) { \
- a.optimize(); \
- if (a.chunks().empty()) a.chunks().push_back(RTLIL::SigChunk()); \
RTLIL::Const dummy_arg(RTLIL::State::S0, 1); \
- RTLIL::SigSpec y(RTLIL::const_ ## _t(a.chunks()[0].data, dummy_arg, \
+ RTLIL::SigSpec y(RTLIL::const_ ## _t(a.as_const(), dummy_arg, \
cell->parameters["\\A_SIGNED"].as_bool(), false, \
cell->parameters["\\Y_WIDTH"].as_int())); \
replace_cell(module, cell, stringf("%s", log_signal(a)), "\\Y", y); \
RTLIL::SigSpec b = cell->connections["\\B"]; \
assign_map.apply(a), assign_map.apply(b); \
if (a.is_fully_const() && b.is_fully_const()) { \
- a.optimize(), b.optimize(); \
- if (a.chunks().empty()) a.chunks().push_back(RTLIL::SigChunk()); \
- if (b.chunks().empty()) b.chunks().push_back(RTLIL::SigChunk()); \
- RTLIL::SigSpec y(RTLIL::const_ ## _t(a.chunks()[0].data, b.chunks()[0].data, \
+ RTLIL::SigSpec y(RTLIL::const_ ## _t(a.as_const(), b.as_const(), \
cell->parameters["\\A_SIGNED"].as_bool(), \
cell->parameters["\\B_SIGNED"].as_bool(), \
cell->parameters["\\Y_WIDTH"].as_int())); \
rspec.expand(), rval.expand();
for (int i = 0; i < int(rspec.chunks().size()); i++)
if (rspec.chunks()[i].wire == NULL)
- rval.chunks()[i] = rspec.chunks()[i];
+ rval.chunks_rw()[i] = rspec.chunks()[i];
rspec.optimize(), rval.optimize();
RTLIL::SigSpec last_rval;
for (int count = 0; rval != last_rval; count++) {
sig1.expand(), sig2.expand();
for (size_t i = 0; i < sig1.chunks().size(); i++)
if (sig1.chunks().at(i) == RTLIL::SigChunk(RTLIL::State::Sx))
- sig2.chunks().at(i) = RTLIL::SigChunk(RTLIL::State::Sx);
+ sig2.chunks_rw().at(i) = RTLIL::SigChunk(RTLIL::State::Sx);
sig1.optimize(), sig2.optimize();
}
log_error("Output (y) has a different width in module %s compared to rtl!\n", RTLIL::id2cstr(module->name));
for (int i = 0; i < sig.size(); i++)
if (rtl_sig.chunks().at(i).data.bits.at(0) == RTLIL::State::Sx)
- sig.chunks().at(i).data.bits.at(0) = RTLIL::State::Sx;
+ sig.chunks_rw().at(i).data.bits.at(0) = RTLIL::State::Sx;
}
log("++RPT++ %d%s %s %s\n", idx, input_pattern_list.c_str(), sig.as_const().as_string().c_str(), module_name.c_str());
newCell->parameters = cell->parameters;
for (auto &conn : cell->connections) {
RTLIL::SigSpec sig = sigmap(conn.second);
- for (auto &chunk : sig.chunks())
+ for (auto &chunk : sig.chunks_rw())
if (chunk.wire != NULL)
chunk.wire = newMod->wires.at(chunk.wire->name);
newCell->connections[conn.first] = sig;
void hilomap_worker(RTLIL::SigSpec &sig)
{
sig.expand();
- for (auto &c : sig.chunks()) {
+ for (auto &c : sig.chunks_rw()) {
if (c.wire == NULL && (c.data.bits.at(0) == RTLIL::State::S1) && !hicell_celltype.empty()) {
if (!singleton_mode || last_hi.width == 0) {
last_hi = RTLIL::SigChunk(module->addWire(NEW_ID));
std::string wire_name = sig.chunks()[i].wire->name;
apply_prefix(prefix, wire_name);
assert(module->wires.count(wire_name) > 0);
- sig.chunks()[i].wire = module->wires[wire_name];
+ sig.chunks_rw()[i].wire = module->wires[wire_name];
}
}