summaryrefslogtreecommitdiff
path: root/src/systemc/tests/tlm/static_extensions/gp2ext
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-05-24 01:37:55 -0700
committerGabe Black <gabeblack@google.com>2018-08-08 10:09:54 +0000
commit16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f (patch)
tree7b6faaacb4574a555e561534aa4a8508c0624c32 /src/systemc/tests/tlm/static_extensions/gp2ext
parent7235d3b5211d0ba8f528d930a4c1e7ad62eec51a (diff)
downloadgem5-16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f.tar.xz
systemc: Import tests from the Accellera systemc distribution.
Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6 Reviewed-on: https://gem5-review.googlesource.com/10845 Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/tests/tlm/static_extensions/gp2ext')
-rw-r--r--src/systemc/tests/tlm/static_extensions/gp2ext/SimpleLTTarget_ext.h186
-rw-r--r--src/systemc/tests/tlm/static_extensions/gp2ext/extension_adaptors.h212
-rw-r--r--src/systemc/tests/tlm/static_extensions/gp2ext/golden/gp2ext.log81
-rw-r--r--src/systemc/tests/tlm/static_extensions/gp2ext/gp2ext.cpp40
-rw-r--r--src/systemc/tests/tlm/static_extensions/gp2ext/my_extension.h56
5 files changed, 575 insertions, 0 deletions
diff --git a/src/systemc/tests/tlm/static_extensions/gp2ext/SimpleLTTarget_ext.h b/src/systemc/tests/tlm/static_extensions/gp2ext/SimpleLTTarget_ext.h
new file mode 100644
index 000000000..c542c196d
--- /dev/null
+++ b/src/systemc/tests/tlm/static_extensions/gp2ext/SimpleLTTarget_ext.h
@@ -0,0 +1,186 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+#ifndef __SIMPLE_LT_TARGET2_H__
+#define __SIMPLE_LT_TARGET2_H__
+
+#include "tlm.h"
+#include "tlm_utils/simple_target_socket.h"
+#include "my_extension.h"
+
+//#include <systemc>
+#include <cassert>
+#include <vector>
+//#include <iostream>
+
+class SimpleLTTarget_ext : public sc_core::sc_module
+{
+public:
+ typedef tlm::tlm_generic_payload transaction_type;
+ typedef tlm::tlm_phase phase_type;
+ typedef tlm::tlm_sync_enum sync_enum_type;
+ typedef tlm_utils::simple_target_socket<SimpleLTTarget_ext, 32,
+ my_extended_payload_types> target_socket_type;
+
+public:
+ target_socket_type socket;
+
+public:
+ SC_HAS_PROCESS(SimpleLTTarget_ext);
+ SimpleLTTarget_ext(sc_core::sc_module_name name,
+ sc_core::sc_time invalidate_dmi_time = sc_core::sc_time(25, sc_core::SC_NS)) :
+ sc_core::sc_module(name),
+ socket("socket")
+ {
+ // register nb_transport method
+ socket.register_nb_transport_fw(this, &SimpleLTTarget_ext::myNBTransport);
+ socket.register_get_direct_mem_ptr(this, &SimpleLTTarget_ext::myGetDMIPtr);
+
+ socket.register_transport_dbg(this, &SimpleLTTarget_ext::transport_dbg);
+
+ SC_METHOD(invalidate_dmi_method);
+ sensitive << m_invalidate_dmi_event;
+ dont_initialize();
+ m_invalidate_dmi_time = invalidate_dmi_time;
+ }
+
+ sync_enum_type myNBTransport(transaction_type& trans, phase_type& phase, sc_core::sc_time& t)
+ {
+ sc_assert(phase == tlm::BEGIN_REQ);
+
+ my_extension* tmp_ext;
+ trans.get_extension(tmp_ext);
+ if (!tmp_ext)
+ {
+ std::cout << name() << ": ERROR, extension not present" << std::endl;
+ }
+ else
+ {
+ std::cout << name() << ": OK, extension data = "
+ << tmp_ext->m_data << std::endl;
+ }
+ sc_dt::uint64 address = trans.get_address();
+ sc_assert(address < 400);
+
+ unsigned int& data = *reinterpret_cast<unsigned int*>(trans.get_data_ptr());
+ if (trans.get_command() == tlm::TLM_WRITE_COMMAND) {
+ std::cout << name() << ": Received write request: A = 0x"
+ << std::hex << (unsigned int)address
+ << ", D = 0x" << data << std::dec
+ << " @ " << sc_core::sc_time_stamp() << std::endl;
+
+ *reinterpret_cast<unsigned int*>(&mMem[address]) = data;
+ t += sc_core::sc_time(10, sc_core::SC_NS);
+
+ } else {
+ std::cout << name() << ": Received read request: A = 0x"
+ << std::hex << (unsigned int)address << std::dec
+ << " @ " << sc_core::sc_time_stamp() << std::endl;
+
+ data = *reinterpret_cast<unsigned int*>(&mMem[address]);
+ t += sc_core::sc_time(100, sc_core::SC_NS);
+ }
+
+ trans.set_response_status(tlm::TLM_OK_RESPONSE);
+
+ trans.set_dmi_allowed(true);
+
+ // LT target
+ // - always return true
+ // - not necessary to update phase (if true is returned)
+ return tlm::TLM_COMPLETED;
+ }
+
+ unsigned int transport_dbg(transaction_type& r)
+ {
+ if (r.get_address() >= 400) return 0;
+
+ unsigned int tmp = (int)r.get_address();
+ unsigned int num_bytes;
+ if (tmp + r.get_data_length() >= 400) {
+ num_bytes = 400 - tmp;
+
+ } else {
+ num_bytes = r.get_data_length();
+ }
+ if (r.is_read()) {
+ for (unsigned int i = 0; i < num_bytes; ++i) {
+ r.get_data_ptr()[i] = mMem[i + tmp];
+ }
+
+ } else {
+ for (unsigned int i = 0; i < num_bytes; ++i) {
+ mMem[i + tmp] = r.get_data_ptr()[i];
+ }
+ }
+ return num_bytes;
+ }
+
+ bool myGetDMIPtr(transaction_type& trans,
+ tlm::tlm_dmi& dmi_data)
+ {
+ // notify DMI invalidation, just to check if this reaches the
+ // initiators properly
+ m_invalidate_dmi_event.notify(m_invalidate_dmi_time);
+
+ // Check for DMI extension:
+ my_extension * tmp_ext;
+ trans.get_extension(tmp_ext);
+ if (tmp_ext)
+ {
+ std::cout << name() << ": get_direct_mem_ptr OK, extension data = "
+ <<tmp_ext->m_data << std::endl;
+ }
+ else
+ {
+ std::cout << name() << ", get_direct_mem_ptr ERROR: "
+ << "didn't get pointer to extension"
+ << std::endl;
+ }
+ if (trans.get_address() < 400) {
+ dmi_data.allow_read_write();
+ dmi_data.set_start_address(0x0);
+ dmi_data.set_end_address(399);
+ dmi_data.set_dmi_ptr(mMem);
+ dmi_data.set_read_latency(sc_core::sc_time(100, sc_core::SC_NS));
+ dmi_data.set_write_latency(sc_core::sc_time(10, sc_core::SC_NS));
+ return true;
+
+ } else {
+ // should not happen
+ dmi_data.set_start_address(trans.get_address());
+ dmi_data.set_end_address(trans.get_address());
+ return false;
+
+ }
+ }
+
+ void invalidate_dmi_method()
+ {
+ sc_dt::uint64 start_address = 0x0;
+ sc_dt::uint64 end_address = 399;
+ socket->invalidate_direct_mem_ptr(start_address, end_address);
+ }
+private:
+ unsigned char mMem[400];
+ sc_core::sc_event m_invalidate_dmi_event;
+ sc_core::sc_time m_invalidate_dmi_time;
+};
+
+#endif
diff --git a/src/systemc/tests/tlm/static_extensions/gp2ext/extension_adaptors.h b/src/systemc/tests/tlm/static_extensions/gp2ext/extension_adaptors.h
new file mode 100644
index 000000000..a6b470e2a
--- /dev/null
+++ b/src/systemc/tests/tlm/static_extensions/gp2ext/extension_adaptors.h
@@ -0,0 +1,212 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+#ifndef __EXTENSIONS_ADAPTORS_H__
+#define __EXTENSIONS_ADAPTORS_H__
+
+#include "tlm.h"
+#include "my_extension.h"
+
+#include "tlm_utils/simple_initiator_socket.h"
+#include "tlm_utils/simple_target_socket.h"
+
+template <unsigned int BUSWIDTH = 32>
+class adapt_ext2gp : public sc_core::sc_module
+{
+ public:
+ typedef tlm::tlm_generic_payload initiator_payload_type;
+ typedef tlm::tlm_generic_payload target_payload_type;
+ typedef tlm_utils::simple_initiator_socket<adapt_ext2gp, BUSWIDTH,
+ tlm::tlm_base_protocol_types> initiator_socket_type;
+ typedef tlm_utils::simple_target_socket<adapt_ext2gp, BUSWIDTH,
+ my_extended_payload_types> target_socket_type;
+
+ target_socket_type target_socket;
+ initiator_socket_type initiator_socket;
+
+ SC_HAS_PROCESS(adapt_ext2gp);
+ adapt_ext2gp(sc_core::sc_module_name name_)
+ : sc_core::sc_module(name_)
+ {
+ target_socket.register_nb_transport_fw(this, &adapt_ext2gp::forward_nb_transport);
+ target_socket.register_transport_dbg(this, &adapt_ext2gp::transport_debug);
+ target_socket.register_get_direct_mem_ptr(this, &adapt_ext2gp::get_dmi_pointer);
+
+ initiator_socket.register_nb_transport_bw(this, &adapt_ext2gp::backward_nb_transport);
+ initiator_socket.register_invalidate_direct_mem_ptr(this, &adapt_ext2gp::invalidate_dmi_pointers);
+ }
+
+ ///////////////
+ // NB transport
+ ///////////////
+
+ // Forward direction: The initiator calls this method with an extended
+ // payload. We leave the extension class in the vector, and it will be
+ // ignored by the GP target.
+ tlm::tlm_sync_enum forward_nb_transport(initiator_payload_type& trans,
+ tlm::tlm_phase& phase,
+ sc_core::sc_time& t)
+ {
+ return initiator_socket->nb_transport_fw(trans, phase, t);
+ }
+ // Backward direction: we can assume here that the payload we get
+ // as parameter is the same one that the initiator sent out. Thus, the
+ // extension vector is known to be present.
+ tlm::tlm_sync_enum backward_nb_transport(target_payload_type& trans,
+ tlm::tlm_phase& phase,
+ sc_core::sc_time& t)
+ {
+ return target_socket->nb_transport_bw(trans, phase, t);
+ }
+
+ bool get_dmi_pointer(target_payload_type& trans,
+ tlm::tlm_dmi& dmi_data)
+ {
+ bool tmp_ret = initiator_socket->get_direct_mem_ptr(trans,
+ dmi_data);
+ return tmp_ret;
+ }
+
+ //////////////////////////
+ // simple call forwarders:
+ //////////////////////////
+ unsigned int transport_debug(target_payload_type& trans)
+ {
+ return initiator_socket->transport_dbg(trans);
+ }
+ void invalidate_dmi_pointers(sc_dt::uint64 start_range,
+ sc_dt::uint64 end_range)
+ {
+ target_socket->invalidate_direct_mem_ptr(start_range,
+ end_range);
+ }
+};
+
+template <unsigned int BUSWIDTH = 32>
+class adapt_gp2ext : public sc_core::sc_module
+{
+ public:
+ typedef tlm::tlm_generic_payload initiator_payload_type;
+ typedef tlm::tlm_generic_payload target_payload_type;
+ typedef tlm_utils::simple_initiator_socket<adapt_gp2ext, BUSWIDTH,
+ my_extended_payload_types> initiator_socket_type;
+ typedef tlm_utils::simple_target_socket<adapt_gp2ext, BUSWIDTH,
+ tlm::tlm_base_protocol_types> target_socket_type;
+
+ target_socket_type target_socket;
+ initiator_socket_type initiator_socket;
+
+ SC_HAS_PROCESS(adapt_gp2ext);
+ adapt_gp2ext(sc_core::sc_module_name name_)
+ : sc_core::sc_module(name_)
+ {
+ // Optionally, we can initialize our private extension class
+ // here, if required.
+
+ target_socket.register_nb_transport_fw(this, &adapt_gp2ext::forward_nb_transport);
+ target_socket.register_transport_dbg(this, &adapt_gp2ext::transport_debug);
+ target_socket.register_get_direct_mem_ptr(this, &adapt_gp2ext::get_dmi_pointer);
+
+ initiator_socket.register_nb_transport_bw(this, &adapt_gp2ext::backward_nb_transport);
+ initiator_socket.register_invalidate_direct_mem_ptr(this, &adapt_gp2ext::invalidate_dmi_pointers);
+
+ m_ext.m_data = 13;
+ }
+
+ ///////////////
+ // NB transport
+ ///////////////
+
+ // Forward direction: We extend the payload on the fly (if needed).
+ tlm::tlm_sync_enum forward_nb_transport(initiator_payload_type& trans,
+ tlm::tlm_phase& phase,
+ sc_core::sc_time& t)
+ {
+ // If the mandatory extension is not there, we need to add it and
+ // store it so that we can re-construc the original state.
+ // Otherwise we don't touch the extension, so that we don't overwrite
+ // it in e.g. a nonGP->GP->nonGP (initiator->interconnect->target)
+ // setup.
+ // Note, however, that there might be situations where we might need to
+ // re-initialize the extension, e.g. for mutable data fields in
+ // different system setups.
+ trans.get_extension(m_initiator_ext);
+ if (!m_initiator_ext)
+ {
+ m_initiator_ext = trans.set_extension(&m_ext);
+ }
+ tlm::tlm_sync_enum tmp =
+ initiator_socket->nb_transport_fw(trans, phase, t);
+ if (tmp == tlm::TLM_COMPLETED)
+ {
+ m_initiator_ext = trans.set_extension(m_initiator_ext);
+ }
+ return tmp;
+ }
+ // Backward direction: only restore of original extension and static_cast.
+ tlm::tlm_sync_enum backward_nb_transport(target_payload_type& trans,
+ tlm::tlm_phase& phase,
+ sc_core::sc_time& t)
+ {
+ m_initiator_ext = trans.set_extension(m_initiator_ext);
+ return target_socket->nb_transport_bw(trans, phase, t);
+ }
+
+ bool get_dmi_pointer(target_payload_type& trans,
+ tlm::tlm_dmi& dmi_data)
+ {
+ // If the mandatory extension is not there, we need to add it and
+ // store it so that we can re-construc the original state.
+ // Otherwise we don't touch the extension, so that we don't overwrite
+ // it in e.g. a nonGP->GP->nonGP (initiator->interconnect->target)
+ // setup.
+ my_extension* tmp_ext;
+ trans.get_extension(tmp_ext);
+ if (!tmp_ext)
+ {
+ trans.set_extension(&m_ext);
+ }
+ bool tmp_ret = initiator_socket->get_direct_mem_ptr(trans,
+ dmi_data);
+ if(!tmp_ext)
+ {
+ trans.clear_extension(tmp_ext);
+ }
+ return tmp_ret;
+ }
+ //////////////////////////
+ // simple call forwarders:
+ //////////////////////////
+ unsigned int transport_debug(target_payload_type& trans)
+ {
+ return initiator_socket->transport_dbg(trans);
+ }
+ void invalidate_dmi_pointers(sc_dt::uint64 start_range,
+ sc_dt::uint64 end_range)
+ {
+ target_socket->invalidate_direct_mem_ptr(start_range,
+ end_range);
+ }
+
+private:
+ my_extension m_ext;
+ my_extension* m_initiator_ext;
+};
+
+#endif
diff --git a/src/systemc/tests/tlm/static_extensions/gp2ext/golden/gp2ext.log b/src/systemc/tests/tlm/static_extensions/gp2ext/golden/gp2ext.log
new file mode 100644
index 000000000..d43825d43
--- /dev/null
+++ b/src/systemc/tests/tlm/static_extensions/gp2ext/golden/gp2ext.log
@@ -0,0 +1,81 @@
+SystemC Simulation
+initiator1: Send write request: A = 0x0, D = 0x0 @ 0 s
+target1: OK, extension data = 13
+target1: Received write request: A = 0x0, D = 0x0 @ 0 s
+initiator1: Received ok response @ 10 ns
+target1: get_direct_mem_ptr OK, extension data = 13
+initiator1: Send write request: A = 0x4, D = 0x1 @ 10 ns
+initiator1: Received ok response @ 20 ns
+initiator1: Send write request: A = 0x8, D = 0x2 @ 20 ns
+initiator1: Received ok response @ 30 ns
+initiator1: Send write request: A = 0xc, D = 0x3 @ 30 ns
+initiator1: got DMI pointer invalidation @ 35 ns
+initiator1: Received ok response @ 40 ns
+initiator1: Send write request: A = 0x10, D = 0x4 @ 40 ns
+target1: OK, extension data = 13
+target1: Received write request: A = 0x10, D = 0x4 @ 40 ns
+initiator1: Received ok response @ 50 ns
+target1: get_direct_mem_ptr OK, extension data = 13
+initiator1: Send write request: A = 0x14, D = 0x5 @ 50 ns
+initiator1: Received ok response @ 60 ns
+initiator1: Send write request: A = 0x18, D = 0x6 @ 60 ns
+initiator1: Received ok response @ 70 ns
+initiator1: Send write request: A = 0x1c, D = 0x7 @ 70 ns
+initiator1: got DMI pointer invalidation @ 75 ns
+initiator1: Received ok response @ 80 ns
+initiator1: Send write request: A = 0x20, D = 0x8 @ 80 ns
+target1: OK, extension data = 13
+target1: Received write request: A = 0x20, D = 0x8 @ 80 ns
+initiator1: Received ok response @ 90 ns
+target1: get_direct_mem_ptr OK, extension data = 13
+initiator1: Send write request: A = 0x24, D = 0x9 @ 90 ns
+initiator1: Received ok response @ 100 ns
+initiator1: Send read request: A = 0x0 @ 100 ns
+initiator1: got DMI pointer invalidation @ 115 ns
+initiator1: Received ok response: D = 0x0 @ 200 ns
+initiator1: Send read request: A = 0x4 @ 200 ns
+target1: OK, extension data = 13
+target1: Received read request: A = 0x4 @ 200 ns
+initiator1: Received ok response: D = 0x1 @ 300 ns
+target1: get_direct_mem_ptr OK, extension data = 13
+initiator1: Send read request: A = 0x8 @ 300 ns
+initiator1: got DMI pointer invalidation @ 325 ns
+initiator1: Received ok response: D = 0x2 @ 400 ns
+initiator1: Send read request: A = 0xc @ 400 ns
+target1: OK, extension data = 13
+target1: Received read request: A = 0xc @ 400 ns
+initiator1: Received ok response: D = 0x3 @ 500 ns
+target1: get_direct_mem_ptr OK, extension data = 13
+initiator1: Send read request: A = 0x10 @ 500 ns
+initiator1: got DMI pointer invalidation @ 525 ns
+initiator1: Received ok response: D = 0x4 @ 600 ns
+initiator1: Send read request: A = 0x14 @ 600 ns
+target1: OK, extension data = 13
+target1: Received read request: A = 0x14 @ 600 ns
+initiator1: Received ok response: D = 0x5 @ 700 ns
+target1: get_direct_mem_ptr OK, extension data = 13
+initiator1: Send read request: A = 0x18 @ 700 ns
+initiator1: got DMI pointer invalidation @ 725 ns
+initiator1: Received ok response: D = 0x6 @ 800 ns
+initiator1: Send read request: A = 0x1c @ 800 ns
+target1: OK, extension data = 13
+target1: Received read request: A = 0x1c @ 800 ns
+initiator1: Received ok response: D = 0x7 @ 900 ns
+target1: get_direct_mem_ptr OK, extension data = 13
+initiator1: Send read request: A = 0x20 @ 900 ns
+initiator1: got DMI pointer invalidation @ 925 ns
+initiator1: Received ok response: D = 0x8 @ 1 us
+initiator1: Send read request: A = 0x24 @ 1 us
+target1: OK, extension data = 13
+target1: Received read request: A = 0x24 @ 1 us
+initiator1: Received ok response: D = 0x9 @ 1100 ns
+target1: get_direct_mem_ptr OK, extension data = 13
+initiator1: got DMI pointer invalidation @ 1125 ns
+
+Info: /OSCI/SystemC: Simulation stopped by user.
+initiator1, <<SimpleLTInitiator1>>:
+
+Mem @0
+00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00
+04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00
+
diff --git a/src/systemc/tests/tlm/static_extensions/gp2ext/gp2ext.cpp b/src/systemc/tests/tlm/static_extensions/gp2ext/gp2ext.cpp
new file mode 100644
index 000000000..0533e9d1b
--- /dev/null
+++ b/src/systemc/tests/tlm/static_extensions/gp2ext/gp2ext.cpp
@@ -0,0 +1,40 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include "tlm.h"
+
+#include "SimpleLTInitiator1_DMI.h"
+#include "SimpleLTTarget_ext.h"
+#include "extension_adaptors.h"
+
+
+int sc_main(int argc, char* argv[])
+{
+ SimpleLTInitiator1_dmi initiator("initiator1", 10, 0x0);
+ adapt_gp2ext<32> bridge("bridge");
+ SimpleLTTarget_ext target("target1");
+
+ initiator.socket(bridge.target_socket);
+ bridge.initiator_socket(target.socket);
+
+ sc_core::sc_start();
+ sc_core::sc_stop();
+
+ return 0;
+}
diff --git a/src/systemc/tests/tlm/static_extensions/gp2ext/my_extension.h b/src/systemc/tests/tlm/static_extensions/gp2ext/my_extension.h
new file mode 100644
index 000000000..650931cd1
--- /dev/null
+++ b/src/systemc/tests/tlm/static_extensions/gp2ext/my_extension.h
@@ -0,0 +1,56 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+#ifndef __MY_EXTENSION_H__
+#define __MY_EXTENSION_H__
+
+#include "tlm.h"
+#include <cassert>
+
+class my_extension :
+ public tlm::tlm_extension<my_extension>
+{
+public:
+ my_extension()
+ : m_data(0)
+ {}
+ tlm_extension_base* clone() const
+ {
+ return new my_extension(*this);
+ }
+ void free()
+ {
+ delete this;
+ }
+ void copy_from(tlm_extension_base const & e)
+ {
+ sc_assert(typeid(this) == typeid(e));
+ m_data = static_cast<my_extension const &>(e).m_data;
+ }
+
+ int m_data;
+};
+
+struct my_extended_payload_types
+{
+ typedef tlm::tlm_base_protocol_types::tlm_payload_type tlm_payload_type;
+ typedef tlm::tlm_base_protocol_types::tlm_phase_type tlm_phase_type;
+};
+
+#endif