Browse Source

add memory manager for signal payload

Eyck Jentzsch 1 year ago
parent
commit
26a3f31111
3 changed files with 28 additions and 1 deletions
  1. 1
    0
      incl/tlm/tlm_signal.h
  2. 27
    0
      incl/tlm/tlm_signal_gp.h
  3. 0
    1
      incl/tlm/tlm_signal_sockets.h

+ 1
- 0
incl/tlm/tlm_signal.h View File

@@ -10,6 +10,7 @@
10 10
 
11 11
 #include "tlm_signal_gp.h"
12 12
 #include "tlm_signal_sockets.h"
13
+#include <scc/peq.h>
13 14
 
14 15
 namespace tlm {
15 16
 

+ 27
- 0
incl/tlm/tlm_signal_gp.h View File

@@ -9,6 +9,7 @@
9 9
 #define _TLM_TLM_SIGNAL_GP_H_
10 10
 
11 11
 #include <tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h>
12
+#include <deque>
12 13
 
13 14
 namespace tlm {
14 15
 
@@ -179,6 +180,32 @@ struct tlm_signal_gp: public tlm_generic_payload_base {
179 180
     void                 set_response_status(const tlm_response_status response_status){m_response_status = response_status;}
180 181
     std::string          get_response_string() const;
181 182
 
183
+    struct gp_mm : public tlm::tlm_base_mm_interface {
184
+        tlm::tlm_signal_gp<SIG>* create(){
185
+            if(pool.size()){
186
+                auto ret = pool.front();
187
+                pool.pop_front();
188
+                return ret;
189
+            } else
190
+                return new tlm::tlm_signal_gp<SIG>(this);
191
+        }
192
+        void free(tlm_generic_payload_base* gp) override {
193
+            auto t = dynamic_cast<tlm::tlm_signal_gp<SIG>*>(gp);
194
+            t->free_all_extensions();
195
+            pool.push_back(t);
196
+        }
197
+        ~gp_mm(){
198
+            for(auto n: pool) delete n;
199
+        }
200
+    private:
201
+        std::deque<tlm::tlm_signal_gp<SIG>*> pool;
202
+
203
+    };
204
+
205
+    static tlm::tlm_signal_gp<SIG>* create(){
206
+        static gp_mm mm;
207
+        return mm.create();
208
+    }
182 209
 
183 210
 protected:
184 211
     tlm_command m_command;

+ 0
- 1
incl/tlm/tlm_signal_sockets.h View File

@@ -8,7 +8,6 @@
8 8
 #ifndef _TLM_TLM_SIGNAL_SOCKETS_H_
9 9
 #define _TLM_TLM_SIGNAL_SOCKETS_H_
10 10
 
11
-#include <scc/peq.h>
12 11
 #include "scc/report.h"
13 12
 
14 13
 #include <tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h>