aboutsummaryrefslogtreecommitdiffstats
path: root/backends/cxxrtl/cxxrtl.h
diff options
context:
space:
mode:
authorCatherine <whitequark@whitequark.org>2021-12-11 15:38:43 +0000
committerCatherine <whitequark@whitequark.org>2021-12-11 16:40:06 +0000
commit55c9fb3b18cee0e2171486f9d4dfbd9b9e106354 (patch)
treef3d7b963bdb7a4adc4efb9eea4900ec8d31464f7 /backends/cxxrtl/cxxrtl.h
parent7c9e498662c378ea5e20aebd14918ac3d8df7c05 (diff)
downloadyosys-55c9fb3b18cee0e2171486f9d4dfbd9b9e106354.tar.gz
yosys-55c9fb3b18cee0e2171486f9d4dfbd9b9e106354.tar.bz2
yosys-55c9fb3b18cee0e2171486f9d4dfbd9b9e106354.zip
cxxrtl: preserve interior memory pointers across reset.
Before this commit, values, wires, and memories with an initializer were value-initialized in emitted C++ code. After this commit, all values, wires, and memories are default-initialized, and the default constructor of generated modules calls the reset() method, which assigns the members that have an initializer.
Diffstat (limited to 'backends/cxxrtl/cxxrtl.h')
-rw-r--r--backends/cxxrtl/cxxrtl.h24
1 files changed, 3 insertions, 21 deletions
diff --git a/backends/cxxrtl/cxxrtl.h b/backends/cxxrtl/cxxrtl.h
index 923146eba..3e1357498 100644
--- a/backends/cxxrtl/cxxrtl.h
+++ b/backends/cxxrtl/cxxrtl.h
@@ -738,24 +738,6 @@ struct memory {
return *this;
}
- // The only way to get the compiler to put the initializer in .rodata and do not copy it on stack is to stuff it
- // into a plain array. You'd think an std::initializer_list would work here, but it doesn't, because you can't
- // construct an initializer_list in a constexpr (or something) and so if you try to do that the whole thing is
- // first copied on the stack (probably overflowing it) and then again into `data`.
- template<size_t Size>
- struct init {
- size_t offset;
- value<Width> data[Size];
- };
-
- template<size_t... InitSize>
- explicit memory(size_t depth, const init<InitSize> &...init) : depth(depth), data(new value<Width>[depth]) {
- // This utterly reprehensible construct is the most reasonable way to apply a function to every element
- // of a parameter pack, if the elements all have different types and so cannot be cast to an initializer list.
- auto _ = {std::move(std::begin(init.data), std::end(init.data), &data[init.offset])...};
- (void)_;
- }
-
// An operator for direct memory reads. May be used at any time during the simulation.
const value<Width> &operator [](size_t index) const {
assert(index < depth);
@@ -1051,9 +1033,9 @@ struct debug_items {
}
};
-// Tag class to disambiguate module move constructor and module constructor that takes black boxes
-// out of another instance of the module.
-struct adopt {};
+// Tag class to disambiguate the default constructor used by the toplevel module that calls reset(),
+// and the constructor of interior modules that should not call it.
+struct interior {};
struct module {
module() {}