diff --git a/backends/functional/cxx.cc b/backends/functional/cxx.cc index 324a8831c86..8d53c9e0391 100644 --- a/backends/functional/cxx.cc +++ b/backends/functional/cxx.cc @@ -156,6 +156,14 @@ template struct CxxPrintVisitor : public FunctionalIR::Abstra void memory_write(Node, Node mem, Node addr, Node data) override { print("{}.write({}, {})", mem, addr, data); } }; +bool equal_def(RTLIL::Const const &a, RTLIL::Const const &b) { + if(a.size() != b.size()) return false; + for(int i = 0; i < a.size(); i++) + if((a[i] == State::S1) != (b[i] == State::S1)) + return false; + return true; +} + struct CxxModule { FunctionalIR ir; CxxStruct input_struct, output_struct, state_struct; @@ -193,11 +201,16 @@ struct CxxModule { if (sort.is_signal()) f.print("\tstate.{} = {};\n", state_struct[name], cxx_const(ir.get_initial_state_signal(name))); else if (sort.is_memory()) { + f.print("\t{{\n"); + f.print("\t\tstd::array, {}> mem;\n", sort.data_width(), 1< class Memory { std::array, 1< _contents; public: + Memory() {} + Memory(std::array, 1< const &contents) : _contents(contents) {} Signal read(Signal addr) const { return _contents[addr.template as_numeric()]; @@ -410,9 +412,6 @@ class Memory { ret._contents[addr.template as_numeric()] = data; return ret; } - // mutating methods for initializing a state - void fill(Signal data) { _contents.fill(data); } - Signal &operator[](Signal addr) { return _contents[addr.template as_numeric()]; } }; #endif