mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-07 01:54:10 +00:00
cxxrtl: rename observer::{on_commit→on_update}. (breaking change)
The name `on_commit` was terrible since it would not be called, as one may conclude from the name, on each `commit()`, but only whenever that method actually updates a value.
This commit is contained in:
parent
fac843f480
commit
ed81cc5f81
|
@ -865,19 +865,19 @@ struct observer {
|
||||||
// Called when the `commit()` method for a wire is about to update the `chunks` chunks at `base` with `chunks` chunks
|
// Called when the `commit()` method for a wire is about to update the `chunks` chunks at `base` with `chunks` chunks
|
||||||
// at `value` that have a different bit pattern. It is guaranteed that `chunks` is equal to the wire chunk count and
|
// at `value` that have a different bit pattern. It is guaranteed that `chunks` is equal to the wire chunk count and
|
||||||
// `base` points to the first chunk.
|
// `base` points to the first chunk.
|
||||||
virtual void on_commit(size_t chunks, const chunk_t *base, const chunk_t *value) = 0;
|
virtual void on_update(size_t chunks, const chunk_t *base, const chunk_t *value) = 0;
|
||||||
|
|
||||||
// Called when the `commit()` method for a memory is about to update the `chunks` chunks at `&base[chunks * index]`
|
// Called when the `commit()` method for a memory is about to update the `chunks` chunks at `&base[chunks * index]`
|
||||||
// with `chunks` chunks at `value` that have a different bit pattern. It is guaranteed that `chunks` is equal to
|
// with `chunks` chunks at `value` that have a different bit pattern. It is guaranteed that `chunks` is equal to
|
||||||
// the memory element chunk count and `base` points to the first chunk of the first element of the memory.
|
// the memory element chunk count and `base` points to the first chunk of the first element of the memory.
|
||||||
virtual void on_commit(size_t chunks, const chunk_t *base, const chunk_t *value, size_t index) = 0;
|
virtual void on_update(size_t chunks, const chunk_t *base, const chunk_t *value, size_t index) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The `null_observer` class has the same interface as `observer`, but has no invocation overhead, since its methods
|
// The `null_observer` class has the same interface as `observer`, but has no invocation overhead, since its methods
|
||||||
// are final and have no implementation. This allows the observer feature to be zero-cost when not in use.
|
// are final and have no implementation. This allows the observer feature to be zero-cost when not in use.
|
||||||
struct null_observer final: observer {
|
struct null_observer final: observer {
|
||||||
void on_commit(size_t chunks, const chunk_t *base, const chunk_t *value) override {}
|
void on_update(size_t chunks, const chunk_t *base, const chunk_t *value) override {}
|
||||||
void on_commit(size_t chunks, const chunk_t *base, const chunk_t *value, size_t index) override {}
|
void on_update(size_t chunks, const chunk_t *base, const chunk_t *value, size_t index) override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<size_t Bits>
|
template<size_t Bits>
|
||||||
|
@ -916,12 +916,12 @@ struct wire {
|
||||||
|
|
||||||
// This method intentionally takes a mandatory argument (to make it more difficult to misuse in
|
// This method intentionally takes a mandatory argument (to make it more difficult to misuse in
|
||||||
// black box implementations, leading to missed observer events). It is generic over its argument
|
// black box implementations, leading to missed observer events). It is generic over its argument
|
||||||
// to make sure the `on_commit` call is devirtualized. This is somewhat awkward but lets us keep
|
// to make sure the `on_update` call is devirtualized. This is somewhat awkward but lets us keep
|
||||||
// a single implementation for both this method and the one in `memory`.
|
// a single implementation for both this method and the one in `memory`.
|
||||||
template<class ObserverT>
|
template<class ObserverT>
|
||||||
bool commit(ObserverT &observer) {
|
bool commit(ObserverT &observer) {
|
||||||
if (curr != next) {
|
if (curr != next) {
|
||||||
observer.on_commit(curr.chunks, curr.data, next.data);
|
observer.on_update(curr.chunks, curr.data, next.data);
|
||||||
curr = next;
|
curr = next;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1003,7 +1003,7 @@ struct memory {
|
||||||
value<Width> elem = data[entry.index];
|
value<Width> elem = data[entry.index];
|
||||||
elem = elem.update(entry.val, entry.mask);
|
elem = elem.update(entry.val, entry.mask);
|
||||||
if (data[entry.index] != elem) {
|
if (data[entry.index] != elem) {
|
||||||
observer.on_commit(value<Width>::chunks, data[0].data, elem.data, entry.index);
|
observer.on_update(value<Width>::chunks, data[0].data, elem.data, entry.index);
|
||||||
changed |= true;
|
changed |= true;
|
||||||
}
|
}
|
||||||
data[entry.index] = elem;
|
data[entry.index] = elem;
|
||||||
|
|
|
@ -561,12 +561,12 @@ public:
|
||||||
spool::writer *writer;
|
spool::writer *writer;
|
||||||
|
|
||||||
CXXRTL_ALWAYS_INLINE
|
CXXRTL_ALWAYS_INLINE
|
||||||
void on_commit(size_t chunks, const chunk_t *base, const chunk_t *value) override {
|
void on_update(size_t chunks, const chunk_t *base, const chunk_t *value) override {
|
||||||
writer->write_change(ident_lookup->at(base), chunks, value);
|
writer->write_change(ident_lookup->at(base), chunks, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
CXXRTL_ALWAYS_INLINE
|
CXXRTL_ALWAYS_INLINE
|
||||||
void on_commit(size_t chunks, const chunk_t *base, const chunk_t *value, size_t index) override {
|
void on_update(size_t chunks, const chunk_t *base, const chunk_t *value, size_t index) override {
|
||||||
writer->write_change(ident_lookup->at(base), chunks, value, index);
|
writer->write_change(ident_lookup->at(base), chunks, value, index);
|
||||||
}
|
}
|
||||||
} record_observer;
|
} record_observer;
|
||||||
|
|
Loading…
Reference in a new issue