mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-24 01:25:33 +00:00
references - breaking
This commit is contained in:
parent
1c2fb078eb
commit
919e2103c9
5 changed files with 92 additions and 46 deletions
|
@ -314,6 +314,9 @@ void Pass::call(RTLIL::Design *design, std::vector<std::string> args)
|
|||
|
||||
size_t orig_sel_stack_pos = design->selection_stack.size();
|
||||
auto state = pass_register[args[0]]->pre_execute();
|
||||
ZoneScopedN(pass_name.c_str());
|
||||
// ZoneText(pass_name.c_str(), pass_name.length());
|
||||
ZoneColor((uint32_t)(size_t)pass_name.c_str());
|
||||
pass_register[args[0]]->execute(args, design);
|
||||
pass_register[args[0]]->post_execute(state);
|
||||
while (design->selection_stack.size() > orig_sel_stack_pos)
|
||||
|
|
|
@ -1087,10 +1087,10 @@ namespace {
|
|||
|
||||
void check_expected(bool check_matched_sign = false)
|
||||
{
|
||||
for (auto ¶ : cell->parameters)
|
||||
for (auto &¶ : cell->parameters)
|
||||
if (expected_params.count(para.first) == 0)
|
||||
error(__LINE__);
|
||||
for (auto &conn : cell->connections_)
|
||||
for (auto &&conn : cell->connections_)
|
||||
if (expected_ports.count(conn.first) == 0)
|
||||
error(__LINE__);
|
||||
|
||||
|
@ -1973,13 +1973,14 @@ void RTLIL::Module::check()
|
|||
log_assert(it.first == it.second->name);
|
||||
log_assert(!it.first.empty());
|
||||
log_assert(!it.second->type.empty());
|
||||
for (auto &it2 : it.second->connections_) {
|
||||
for (auto &&it2 : it.second->connections_) {
|
||||
log_assert(!it2.first.empty());
|
||||
it2.second.check(this);
|
||||
}
|
||||
for (auto &it2 : it.second->attributes)
|
||||
log_assert(!it2.first.empty());
|
||||
for (auto &it2 : it.second->parameters)
|
||||
// TODO
|
||||
// for (auto &&it2 : it.second->attributes)
|
||||
// log_assert(!it2.first.empty());
|
||||
for (auto &&it2 : it.second->parameters)
|
||||
log_assert(!it2.first.empty());
|
||||
InternalOldCellChecker checker(this, it.second);
|
||||
checker.check();
|
||||
|
@ -3553,6 +3554,9 @@ const RTLIL::Const RTLIL::Cell::getParam(const RTLIL::IdString ¶mname) {
|
|||
|
||||
if (type == ID($not)) {
|
||||
if (paramname == ID::A_WIDTH) {
|
||||
// Notice using the trivial default constructor
|
||||
// This is to reduce code changes later when we replace Const
|
||||
// with int/bool where possible in internal cell type variants
|
||||
return RTLIL::Const(not_.a_width);
|
||||
} else if (paramname == ID::Y_WIDTH) {
|
||||
return RTLIL::Const(not_.y_width);
|
||||
|
@ -3739,15 +3743,15 @@ void RTLIL::OldCell::sort()
|
|||
attributes.sort(sort_by_id_str());
|
||||
}
|
||||
|
||||
void RTLIL::OldCell::check()
|
||||
void RTLIL::Cell::check()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
InternalOldCellChecker checker(NULL, this);
|
||||
checker.check();
|
||||
#endif
|
||||
}
|
||||
|
||||
void RTLIL::OldCell::fixup_parameters(bool set_a_signed, bool set_b_signed)
|
||||
int bigboy() {return sizeof(RTLIL::Cell);}
|
||||
void RTLIL::Cell::fixup_parameters(bool set_a_signed, bool set_b_signed)
|
||||
{
|
||||
if (!type.begins_with("$") || type.begins_with("$_") || type.begins_with("$paramod") || type.begins_with("$fmcombine") ||
|
||||
type.begins_with("$verific$") || type.begins_with("$array:") || type.begins_with("$extern:"))
|
||||
|
|
|
@ -657,6 +657,7 @@ namespace RTLIL
|
|||
};
|
||||
};
|
||||
|
||||
// TODO OF GALACTIC PROPORTIONS
|
||||
struct RTLIL::Const
|
||||
{
|
||||
int flags;
|
||||
|
@ -1591,8 +1592,8 @@ public:
|
|||
const RTLIL::Const &getParam(const RTLIL::IdString ¶mname) const;
|
||||
|
||||
void sort();
|
||||
void check();
|
||||
void fixup_parameters(bool set_a_signed = false, bool set_b_signed = false);
|
||||
// void check();
|
||||
// void fixup_parameters(bool set_a_signed = false, bool set_b_signed = false);
|
||||
|
||||
bool has_keep_attr() const {
|
||||
return get_bool_attribute(ID::keep) || (module && module->design && module->design->module(type) &&
|
||||
|
@ -1613,20 +1614,21 @@ public:
|
|||
|
||||
// $not
|
||||
struct RTLIL::Unary {
|
||||
RTLIL::SigSpec a;
|
||||
RTLIL::SigSpec y;
|
||||
int a_width;
|
||||
int y_width;
|
||||
bool is_signed;
|
||||
std::array<std::pair<RTLIL::IdString, RTLIL::SigSpec>, 2> connections() {
|
||||
return {std::make_pair(ID::A, a), std::make_pair(ID::Y, y)};
|
||||
SigSpec a;
|
||||
SigSpec y;
|
||||
Const a_width;
|
||||
Const y_width;
|
||||
Const is_signed;
|
||||
std::array<std::pair<IdString, SigSpec&>, 2> connections() {
|
||||
return {std::make_pair(ID::A, std::ref(a)), std::make_pair(ID::Y, std::ref(y))};
|
||||
}
|
||||
std::array<std::pair<RTLIL::IdString, RTLIL::Const>, 3> parameters() {
|
||||
return {std::make_pair(ID::A_WIDTH, Const(a_width)), std::make_pair(ID::Y_WIDTH, Const(y_width)), std::make_pair(ID::A_SIGNED, Const(y_width))};
|
||||
std::array<std::pair<IdString, Const&>, 3> parameters() {
|
||||
return {std::make_pair(ID::A_WIDTH, std::ref(a_width)), std::make_pair(ID::Y_WIDTH, std::ref(y_width)), std::make_pair(ID::A_SIGNED, std::ref(y_width))};
|
||||
}
|
||||
// TODO new interface: inputs
|
||||
};
|
||||
|
||||
// NewCell
|
||||
struct RTLIL::Cell
|
||||
{
|
||||
// TODO huh?
|
||||
|
@ -1704,11 +1706,13 @@ public:
|
|||
bool operator!=(const iterator &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
std::pair<IdString, Const> operator*() {
|
||||
std::pair<IdString, Const&> operator*() {
|
||||
if (parent->is_legacy()) {
|
||||
auto it = parent->legacy->parameters.begin();
|
||||
it += position;
|
||||
return *it;
|
||||
auto& ref = *it;
|
||||
auto ret = std::make_pair(ref.first, std::ref(ref.second));
|
||||
return ret;
|
||||
} else if (parent->type == ID($pos)) {
|
||||
return parent->pos.parameters()[position];
|
||||
} else if (parent->type == ID($neg)) {
|
||||
|
@ -1719,11 +1723,13 @@ public:
|
|||
throw std::out_of_range("FakeParams.iterator::operator*()");
|
||||
}
|
||||
}
|
||||
const std::pair<IdString, Const> operator*() const {
|
||||
const std::pair<IdString, Const&> operator*() const {
|
||||
if (parent->is_legacy()) {
|
||||
auto it = parent->legacy->parameters.begin();
|
||||
it += position;
|
||||
return *it;
|
||||
auto& ref = *it;
|
||||
auto ret = std::make_pair(ref.first, std::ref(ref.second));
|
||||
return ret;
|
||||
} else if (parent->type == ID($pos)) {
|
||||
return parent->pos.parameters()[position];
|
||||
} else if (parent->type == ID($neg)) {
|
||||
|
@ -1736,7 +1742,13 @@ public:
|
|||
}
|
||||
};
|
||||
iterator begin() {
|
||||
return iterator(parent, 0);
|
||||
return iterator(parent, 0);
|
||||
}
|
||||
// Stupid impl, but rarely used, so I don't want to think about it rn
|
||||
iterator find(IdString name) {
|
||||
auto it = iterator(parent, 0);
|
||||
for (; it != end() && (*it).first != name; ++it) {}
|
||||
return it;
|
||||
}
|
||||
iterator end() {
|
||||
if (parent->is_legacy()) {
|
||||
|
@ -1756,8 +1768,8 @@ public:
|
|||
typedef std::input_iterator_tag iterator_category;
|
||||
typedef std::pair<IdString, Const> value_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef std::pair<IdString, Const>* pointer;
|
||||
typedef std::pair<IdString, Const>& reference;
|
||||
typedef std::pair<IdString, Const*> pointer;
|
||||
typedef std::pair<IdString, Const&> reference;
|
||||
Cell* parent;
|
||||
int position;
|
||||
public:
|
||||
|
@ -1772,11 +1784,13 @@ public:
|
|||
bool operator!=(const const_iterator &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
const std::pair<IdString, Const> operator*() const {
|
||||
const std::pair<IdString, Const&> operator*() const {
|
||||
if (parent->is_legacy()) {
|
||||
auto it = parent->legacy->parameters.begin();
|
||||
it += position;
|
||||
return *it;
|
||||
auto& ref = *it;
|
||||
auto ret = std::make_pair(ref.first, std::ref(ref.second));
|
||||
return ret;
|
||||
} else if (parent->type == ID($pos)) {
|
||||
return parent->pos.parameters()[position];
|
||||
} else if (parent->type == ID($neg)) {
|
||||
|
@ -1810,6 +1824,12 @@ public:
|
|||
RTLIL::SigSpec at(RTLIL::IdString portname) {
|
||||
return parent->getPort(portname);
|
||||
}
|
||||
// Watch out! This is different semantics than what dict has!
|
||||
// but we rely on RTLIL::Cell always being constructed correctly
|
||||
// since its layout is fixed as defined by InternalOldCellChecker
|
||||
RTLIL::SigSpec operator[](RTLIL::IdString portname) {
|
||||
return parent->getPort(portname);
|
||||
}
|
||||
int count(RTLIL::IdString portname) {
|
||||
try {
|
||||
parent->getPort(portname);
|
||||
|
@ -1839,8 +1859,8 @@ public:
|
|||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef std::pair<IdString, SigSpec> value_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef std::pair<IdString, SigSpec>* pointer;
|
||||
typedef std::pair<IdString, SigSpec>& reference;
|
||||
typedef std::pair<IdString, SigSpec*> pointer;
|
||||
typedef std::pair<IdString, SigSpec&> reference;
|
||||
Cell* parent;
|
||||
int position;
|
||||
public:
|
||||
|
@ -1855,11 +1875,13 @@ public:
|
|||
bool operator!=(const iterator &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
std::pair<IdString, SigSpec> operator*() {
|
||||
std::pair<IdString, SigSpec&> operator*() {
|
||||
if (parent->is_legacy()) {
|
||||
auto it = parent->legacy->connections_.begin();
|
||||
it += position;
|
||||
return *it;
|
||||
auto& ref = *it;
|
||||
auto ret = std::make_pair(ref.first, std::ref(ref.second));
|
||||
return ret;
|
||||
} else if (parent->type == ID($pos)) {
|
||||
// auto a = ();
|
||||
return parent->pos.connections()[position];
|
||||
|
@ -1871,11 +1893,13 @@ public:
|
|||
throw std::out_of_range("FakeConns.iterator::operator*()");
|
||||
}
|
||||
}
|
||||
const std::pair<IdString, SigSpec> operator*() const {
|
||||
const std::pair<IdString, SigSpec&> operator*() const {
|
||||
if (parent->is_legacy()) {
|
||||
auto it = parent->legacy->connections_.begin();
|
||||
it += position;
|
||||
return *it;
|
||||
auto& ref = *it;
|
||||
auto ret = std::make_pair(ref.first, std::ref(ref.second));
|
||||
return ret;
|
||||
} else if (parent->type == ID($pos)) {
|
||||
// auto a = ();
|
||||
return parent->pos.connections()[position];
|
||||
|
@ -1909,8 +1933,8 @@ public:
|
|||
typedef std::input_iterator_tag iterator_category;
|
||||
typedef std::pair<IdString, SigSpec> value_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef std::pair<IdString, SigSpec>* pointer;
|
||||
typedef std::pair<IdString, SigSpec>& reference;
|
||||
typedef std::pair<IdString, SigSpec*> pointer;
|
||||
typedef std::pair<IdString, SigSpec&> reference;
|
||||
Cell* parent;
|
||||
int position;
|
||||
public:
|
||||
|
@ -1925,11 +1949,13 @@ public:
|
|||
bool operator!=(const const_iterator &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
const std::pair<IdString, SigSpec> operator*() const {
|
||||
const std::pair<IdString, SigSpec&> operator*() const {
|
||||
if (parent->is_legacy()) {
|
||||
auto it = parent->legacy->connections_.begin();
|
||||
it += position;
|
||||
return *it;
|
||||
auto& ref = *it;
|
||||
auto ret = std::make_pair(ref.first, std::ref(ref.second));
|
||||
return ret;
|
||||
} else if (parent->type == ID($pos)) {
|
||||
return parent->pos.connections()[position];
|
||||
} else if (parent->type == ID($neg)) {
|
||||
|
@ -1982,17 +2008,24 @@ public:
|
|||
}
|
||||
template<typename T>
|
||||
void rewrite_sigspecs2(T &functor) {
|
||||
for (auto &it : connections_)
|
||||
// for(auto it = connections_.begin(); it != connections_.end(); ++it) {
|
||||
// auto& thing = *it;
|
||||
// functor(it.second);
|
||||
// }
|
||||
// TODO fix!!!
|
||||
for (auto &&it : connections_)
|
||||
functor(it.second);
|
||||
}
|
||||
template<typename T>
|
||||
void rewrite_sigspecs(T &functor) {
|
||||
for (std::pair<IdString, SigSpec> &it : connections_)
|
||||
for (auto &&it : connections_)
|
||||
functor(it.second);
|
||||
}
|
||||
void sort() {
|
||||
if (is_legacy()) legacy->sort();
|
||||
}
|
||||
void check();
|
||||
void fixup_parameters(bool set_a_signed = false, bool set_b_signed = false);
|
||||
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue