summaryrefslogtreecommitdiff
path: root/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp
diff options
context:
space:
mode:
authorMatthias Jung <jungma@eit.uni-kl.de>2017-03-01 18:39:56 +0100
committerMatthias Jung <jungma@eit.uni-kl.de>2017-05-18 08:36:56 +0000
commitaa651c7f8321bf96fc88f9a17285225000a753ec (patch)
treeb13240008c970b47bd74a5007e68136155d272fc /ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp
parent595e692de09e1b7cbc5f57ac01da299afc066fdd (diff)
downloadgem5-aa651c7f8321bf96fc88f9a17285225000a753ec.tar.xz
ext: Include SystemC 2.3.1 into gem5
In the past it happened several times that some changes in gem5 broke the SystemC coupling. Recently Accelera has changed the licence for SystemC from their own licence to Apache2.0, which is compatible with gem5. However, SystemC usually relies on the Boost library, but I was able to exchange the boost calls by c++11 alternatives. The recent SystemC version is placed into /ext and is integrated into gem5's build system. The goal is to integrate some SystemC tests for the CI in some following patches. Change-Id: I4b66ec806b5e3cffc1d7c85d3735ff4fa5b31fd0 Reviewed-on: https://gem5-review.googlesource.com/2240 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp')
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h149
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h85
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h73
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h31
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h105
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h268
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h263
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h98
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_put_get.h140
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h93
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h114
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h155
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h94
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h91
-rw-r--r--ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h37
15 files changed, 1796 insertions, 0 deletions
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h
new file mode 100644
index 000000000..4c1340338
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h
@@ -0,0 +1,149 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+//
+// Note to the LRM writer : This is the core of the TLM standard
+//
+
+
+#ifndef __TLM_CORE_IFS_H__
+#define __TLM_CORE_IFS_H__
+
+//#include <systemc>
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h"
+
+namespace tlm {
+
+// bidirectional blocking interfaces
+
+template < typename REQ , typename RSP >
+class tlm_transport_if : public virtual sc_core::sc_interface
+{
+public:
+ virtual RSP transport( const REQ & ) = 0;
+
+ virtual void transport( const REQ &req , RSP &rsp ) {
+ rsp = transport( req );
+ }
+
+};
+
+
+// uni-directional blocking interfaces
+
+template < typename T >
+class tlm_blocking_get_if : public virtual sc_core::sc_interface
+{
+public:
+ virtual T get( tlm_tag<T> *t = 0 ) = 0;
+ virtual void get( T &t ) { t = get(); }
+
+};
+
+template < typename T >
+class tlm_blocking_put_if : public virtual sc_core::sc_interface
+{
+public:
+ virtual void put( const T &t ) = 0;
+};
+
+// uni-directional non blocking interfaces
+
+template < typename T >
+class tlm_nonblocking_get_if : public virtual sc_core::sc_interface
+{
+public:
+ virtual bool nb_get( T &t ) = 0;
+ virtual bool nb_can_get( tlm_tag<T> *t = 0 ) const = 0;
+ virtual const sc_core::sc_event &ok_to_get( tlm_tag<T> *t = 0 ) const = 0;
+};
+
+template < typename T >
+class tlm_nonblocking_put_if : public virtual sc_core::sc_interface
+{
+public:
+ virtual bool nb_put( const T &t ) = 0;
+ virtual bool nb_can_put( tlm_tag<T> *t = 0 ) const = 0;
+ virtual const sc_core::sc_event &ok_to_put( tlm_tag<T> *t = 0 ) const = 0;
+};
+
+
+// combined uni-directional blocking and non blocking
+
+template < typename T >
+class tlm_get_if :
+ public virtual tlm_blocking_get_if< T > ,
+ public virtual tlm_nonblocking_get_if< T > {};
+
+template < typename T >
+class tlm_put_if :
+ public virtual tlm_blocking_put_if< T > ,
+ public virtual tlm_nonblocking_put_if< T > {};
+
+
+// peek interfaces
+
+template < typename T >
+class tlm_blocking_peek_if : public virtual sc_core::sc_interface
+{
+public:
+ virtual T peek( tlm_tag<T> *t = 0 ) const = 0;
+ virtual void peek( T &t ) const { t = peek(); }
+
+};
+
+template < typename T >
+class tlm_nonblocking_peek_if : public virtual sc_core::sc_interface
+{
+public:
+ virtual bool nb_peek( T &t ) const = 0;
+ virtual bool nb_can_peek( tlm_tag<T> *t = 0 ) const = 0;
+ virtual const sc_core::sc_event &ok_to_peek( tlm_tag<T> *t = 0 ) const = 0;
+};
+
+template < typename T >
+class tlm_peek_if :
+ public virtual tlm_blocking_peek_if< T > ,
+ public virtual tlm_nonblocking_peek_if< T > {};
+
+// get_peek interfaces
+
+template < typename T >
+class tlm_blocking_get_peek_if :
+ public virtual tlm_blocking_get_if<T> ,
+ public virtual tlm_blocking_peek_if<T> {};
+
+template < typename T >
+class tlm_nonblocking_get_peek_if :
+ public virtual tlm_nonblocking_get_if<T> ,
+ public virtual tlm_nonblocking_peek_if<T> {};
+
+
+template < typename T >
+class tlm_get_peek_if :
+ public virtual tlm_get_if<T> ,
+ public virtual tlm_peek_if<T> ,
+ public virtual tlm_blocking_get_peek_if<T> ,
+ public virtual tlm_nonblocking_get_peek_if<T>
+ {};
+
+} // namespace tlm
+
+#endif
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h
new file mode 100644
index 000000000..d9b2b985b
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h
@@ -0,0 +1,85 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+//
+// Note to the LRM writer : These interfaces are channel specific interfaces
+// useful in the context of tlm_fifo.
+//
+
+#ifndef __TLM_FIFO_IFS_H__
+#define __TLM_FIFO_IFS_H__
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h"
+
+namespace tlm {
+
+//
+// Fifo specific interfaces
+//
+
+// Fifo Debug Interface
+
+template< typename T >
+class tlm_fifo_debug_if : public virtual sc_core::sc_interface
+{
+public:
+ virtual int used() const = 0;
+ virtual int size() const = 0;
+ virtual void debug() const = 0;
+
+ //
+ // non blocking peek and poke - no notification
+ //
+ // n is index of data :
+ // 0 <= n < size(), where 0 is most recently written, and size() - 1
+ // is oldest ie the one about to be read.
+ //
+
+ virtual bool nb_peek( T & , int n ) const = 0;
+ virtual bool nb_poke( const T & , int n = 0 ) = 0;
+
+};
+
+// fifo interfaces = extended + debug
+
+template < typename T >
+class tlm_fifo_put_if :
+ public virtual tlm_put_if<T> ,
+ public virtual tlm_fifo_debug_if<T> {};
+
+template < typename T >
+class tlm_fifo_get_if :
+ public virtual tlm_get_peek_if<T> ,
+ public virtual tlm_fifo_debug_if<T> {};
+
+class tlm_fifo_config_size_if : public virtual sc_core::sc_interface
+{
+public:
+ virtual void nb_expand( unsigned int n = 1 ) = 0;
+ virtual void nb_unbound( unsigned int n = 16 ) = 0;
+
+ virtual bool nb_reduce( unsigned int n = 1 ) = 0;
+ virtual bool nb_bound( unsigned int n ) = 0;
+
+};
+
+} // namespace tlm
+
+#endif
+
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h
new file mode 100644
index 000000000..5bac3c877
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h
@@ -0,0 +1,73 @@
+/*****************************************************************************
+
+ 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 __TLM_MASTER_SLAVE_IFS_H__
+#define __TLM_MASTER_SLAVE_IFS_H__
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h"
+
+namespace tlm {
+
+//
+// req/rsp combined interfaces
+//
+
+// blocking
+
+template < typename REQ , typename RSP>
+class tlm_blocking_master_if :
+ public virtual tlm_blocking_put_if< REQ > ,
+ public virtual tlm_blocking_get_peek_if< RSP > {};
+
+template < typename REQ , typename RSP>
+class tlm_blocking_slave_if :
+ public virtual tlm_blocking_put_if< RSP > ,
+ public virtual tlm_blocking_get_peek_if< REQ > {};
+
+// nonblocking
+
+template < typename REQ , typename RSP >
+class tlm_nonblocking_master_if :
+ public virtual tlm_nonblocking_put_if< REQ > ,
+ public virtual tlm_nonblocking_get_peek_if< RSP > {};
+
+template < typename REQ , typename RSP >
+class tlm_nonblocking_slave_if :
+ public virtual tlm_nonblocking_put_if< RSP > ,
+ public virtual tlm_nonblocking_get_peek_if< REQ > {};
+
+// combined
+
+template < typename REQ , typename RSP >
+class tlm_master_if :
+ public virtual tlm_put_if< REQ > ,
+ public virtual tlm_get_peek_if< RSP > ,
+ public virtual tlm_blocking_master_if< REQ , RSP > ,
+ public virtual tlm_nonblocking_master_if< REQ , RSP > {};
+
+template < typename REQ , typename RSP >
+class tlm_slave_if :
+ public virtual tlm_put_if< RSP > ,
+ public virtual tlm_get_peek_if< REQ > ,
+ public virtual tlm_blocking_slave_if< REQ , RSP > ,
+ public virtual tlm_nonblocking_slave_if< REQ , RSP > {};
+
+} // namespace tlm
+
+#endif
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h
new file mode 100644
index 000000000..230b77d17
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h
@@ -0,0 +1,31 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+//
+// Note to the LRM writer : This is part of the core TLM standard
+//
+
+#ifndef __TLM_TAG_H__
+#define __TLM_TAG_H__
+
+namespace tlm {
+template<class T> class tlm_tag {};
+}
+
+#endif
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h
new file mode 100644
index 000000000..13207187a
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h
@@ -0,0 +1,105 @@
+/*****************************************************************************
+
+ 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 __TLM_ADAPTERS_H__
+#define __TLM_ADAPTERS_H__
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h"
+
+namespace tlm {
+
+template< typename REQ , typename RSP >
+class tlm_transport_to_master :
+ public sc_core::sc_module ,
+ public virtual tlm_transport_if< REQ , RSP >
+{
+public:
+ sc_core::sc_export< tlm_transport_if< REQ , RSP > > target_export;
+ sc_core::sc_port< tlm_master_if< REQ , RSP > > master_port;
+
+ tlm_transport_to_master( sc_core::sc_module_name nm ) :
+ sc_core::sc_module( nm ) {
+
+ target_export( *this );
+
+ }
+
+ tlm_transport_to_master() :
+ sc_core::sc_module( sc_core::sc_module_name( sc_core::sc_gen_unique_name( "transport_to_master" ) ) ){
+
+ target_export( *this );
+
+ }
+
+ RSP transport( const REQ &req ) {
+
+ mutex.lock();
+
+ master_port->put( req );
+ rsp = master_port->get();
+
+ mutex.unlock();
+ return rsp;
+
+ }
+
+private:
+ sc_core::sc_mutex mutex;
+ RSP rsp;
+
+};
+
+template< typename REQ , typename RSP >
+class tlm_slave_to_transport : public sc_core::sc_module
+{
+public:
+
+ SC_HAS_PROCESS( tlm_slave_to_transport );
+
+ sc_core::sc_port< tlm_slave_if< REQ , RSP > > slave_port;
+ sc_core::sc_port< tlm_transport_if< REQ , RSP > > initiator_port;
+
+ tlm_slave_to_transport( sc_core::sc_module_name nm ) : sc_core::sc_module( nm )
+ {}
+
+ tlm_slave_to_transport() :
+ sc_core::sc_module( sc_core::sc_module_name( sc_core::sc_gen_unique_name("slave_to_transport") ) )
+ {}
+
+private:
+ void run() {
+
+ REQ req;
+ RSP rsp;
+
+ while( true ) {
+
+ slave_port->get( req );
+ rsp = initiator_port->transport( req );
+ slave_port->put( rsp );
+
+ }
+
+ }
+
+};
+
+} // namespace tlm
+
+#endif
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h
new file mode 100644
index 000000000..68c3c2c1f
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h
@@ -0,0 +1,268 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+//
+// To the LRM writer : this class is purely an artifact of the implementation.
+//
+
+#ifndef __CIRCULAR_BUFFER_H__
+#define __CIRCULAR_BUFFER_H__
+
+#include <iostream>
+
+namespace tlm {
+
+template < typename T >
+class circular_buffer
+{
+public:
+
+ explicit
+ circular_buffer( int size = 0 );
+ ~circular_buffer();
+
+ void resize( int size );
+ void clear();
+
+ T read();
+ void write( const T & );
+
+ bool is_empty() const { return used() == 0; }
+ bool is_full() const { return free() == 0; }
+
+ int size() const { return m_size; }
+ int used() const { return m_used; }
+ int free() const { return m_free; }
+
+ const T& read_data() const
+ { return buf_read( m_buf, m_ri ); }
+
+ const T& peek_data( int i ) const
+ { return buf_read( m_buf, (m_ri + i) % size() ); }
+
+ T & poke_data( int i )
+ { return buf_read( m_buf , (m_wi + i) % size() ); }
+
+ void debug() const;
+
+private:
+ void increment_write_pos( int i = 1 );
+ void increment_read_pos( int i = 1 );
+
+ void init();
+
+ circular_buffer( const circular_buffer<T> &b ); // disabled
+ circular_buffer<T> &operator=( const circular_buffer<T> & ); // disabled
+
+ void* buf_alloc( int size );
+ void buf_free( void*& buf );
+ void buf_write( void* buf, int n, const T & t );
+ T& buf_read( void* buf, int n ) const;
+ void buf_clear( void* buf, int n );
+
+private:
+ int m_size; // size of the buffer
+ void* m_buf; // the buffer
+ int m_free; // number of free spaces
+ int m_used; // number of used spaces
+ int m_ri; // index of next read
+ int m_wi; // index of next write
+
+};
+
+template< typename T >
+void
+circular_buffer<T>::debug() const
+{
+
+ std::cout << "Buffer debug" << std::endl;
+ std::cout << "Size : " << size() << std::endl;
+ std::cout << "Free/Used " << free() << "/" << used() << std::endl;
+ std::cout << "Indices : r/w = " << m_ri << "/" << m_wi << std::endl;
+
+ if( is_empty() ) {
+
+ std::cout << "empty" << std::endl;
+
+ }
+
+ if( is_full() ) {
+
+ std::cout << "full" << std::endl;
+
+ }
+
+ std::cout << "Data : " << std::endl;
+ for( int i = 0; i < used(); i++ ) {
+
+ std::cout << peek_data( i ) << std::endl;
+
+ }
+
+
+}
+
+template < typename T >
+circular_buffer<T>::circular_buffer( int size )
+ : m_size(size)
+ , m_buf(0)
+{
+ init();
+
+}
+
+template < typename T >
+void
+circular_buffer<T>::clear()
+{
+ for( int i=0; i < used(); i++ ) {
+ buf_clear( m_buf, i );
+ }
+ m_free = m_size;
+ m_used = m_ri = m_wi = 0;
+}
+
+template < typename T >
+circular_buffer<T>::~circular_buffer()
+{
+ clear();
+ buf_free( m_buf );
+}
+
+template < typename T >
+void
+circular_buffer<T>::resize( int size )
+{
+
+ int i;
+ void * new_buf = buf_alloc(size);
+
+ for( i = 0; i < size && i < used(); i++ ) {
+
+ buf_write( new_buf, i, peek_data( i ) );
+ buf_clear( m_buf, (m_ri + i) % m_size );
+
+ }
+
+ buf_free( m_buf );
+
+ m_size = size;
+ m_ri = 0;
+ m_wi = i % m_size;
+ m_used = i;
+ m_free = m_size - m_used;
+
+ m_buf = new_buf;
+}
+
+
+template < typename T >
+void
+circular_buffer<T>::init() {
+
+ if( m_size > 0 ) {
+ m_buf = buf_alloc( m_size );
+ }
+
+ m_free = m_size;
+ m_used = 0;
+ m_ri = 0;
+ m_wi = 0;
+
+}
+
+template < typename T >
+T
+circular_buffer<T>::read()
+{
+ T t = read_data();
+
+ buf_clear( m_buf, m_ri );
+ increment_read_pos();
+
+ return t;
+}
+
+template < typename T >
+void
+circular_buffer<T>::write( const T &t )
+{
+ buf_write( m_buf, m_wi, t );
+ increment_write_pos();
+}
+
+
+template < typename T >
+void
+circular_buffer<T>::increment_write_pos( int i ) {
+
+ m_wi = ( m_wi + i ) % m_size;
+ m_used += i;
+ m_free -= i;
+
+}
+
+template < typename T >
+void
+circular_buffer<T>::increment_read_pos( int i ) {
+
+ m_ri = ( m_ri + i ) % m_size;
+ m_used -= i;
+ m_free += i;
+
+}
+
+template < typename T >
+inline void*
+circular_buffer<T>::buf_alloc( int size )
+ { return new unsigned char[ size * sizeof(T) ]; }
+
+template < typename T >
+inline void
+circular_buffer<T>::buf_free( void* & buf )
+ { delete [] static_cast<unsigned char*>(buf); buf = 0; }
+
+template < typename T >
+inline void
+circular_buffer<T>::buf_write( void* buf, int n, const T & t )
+{
+ T* p = static_cast<T*>(buf) + n;
+ new (p) T(t);
+}
+
+template < typename T >
+inline T&
+circular_buffer<T>::buf_read( void* buf, int n ) const
+{
+ T* p = static_cast<T*>(buf) + n;
+ return *p;
+}
+
+template < typename T >
+inline void
+circular_buffer<T>::buf_clear( void* buf, int n )
+{
+ T* p = static_cast<T*>(buf) + n;
+ p->~T();
+}
+
+} // namespace tlm
+
+#endif
+
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h
new file mode 100644
index 000000000..7b44a32ee
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h
@@ -0,0 +1,263 @@
+/*****************************************************************************
+
+ 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 __TLM_FIFO_H__
+#define __TLM_FIFO_H__
+
+//
+// This implements put, get and peek
+//
+// It also implements 0 and infinite size fifos - but the size
+// zero fifos aren't rendezvous like zero length fifos, they simply are both
+// full and empty at the same time.
+//
+// The size can be dynamically changed using the resize interface
+//
+// To get an infinite fifo use a -ve size in the constructor.
+// The absolute value of the size is taken as the starting size of the
+// actual physical buffer.
+//
+
+//#include <systemc>
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h"
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h"
+
+namespace tlm {
+
+template <typename T>
+class tlm_fifo :
+ public virtual tlm_fifo_get_if<T>,
+ public virtual tlm_fifo_put_if<T>,
+ public sc_core::sc_prim_channel
+{
+public:
+
+ // constructors
+
+ explicit tlm_fifo( int size_ = 1 )
+ : sc_core::sc_prim_channel( sc_core::sc_gen_unique_name( "fifo" ) ) {
+
+ init( size_ );
+
+ }
+
+ explicit tlm_fifo( const char* name_, int size_ = 1 )
+ : sc_core::sc_prim_channel( name_ ) {
+
+ init( size_ );
+
+ }
+
+ // destructor
+
+ virtual ~tlm_fifo() {}
+
+ // tlm get interface
+
+ T get( tlm_tag<T> * = 0 );
+
+ bool nb_get( T& );
+ bool nb_can_get( tlm_tag<T> * = 0 ) const;
+ const sc_core::sc_event &ok_to_get( tlm_tag<T> * = 0 ) const {
+ return m_data_written_event;
+ }
+
+ // tlm peek interface
+
+ T peek( tlm_tag<T> * = 0 ) const;
+
+ bool nb_peek( T& ) const;
+ bool nb_can_peek( tlm_tag<T> * = 0 ) const;
+ const sc_core::sc_event &ok_to_peek( tlm_tag<T> * = 0 ) const {
+ return m_data_written_event;
+ }
+
+ // tlm put interface
+
+ void put( const T& );
+
+ bool nb_put( const T& );
+ bool nb_can_put( tlm_tag<T> * = 0 ) const;
+
+ const sc_core::sc_event& ok_to_put( tlm_tag<T> * = 0 ) const {
+ return m_data_read_event;
+ }
+
+ // resize if
+
+ void nb_expand( unsigned int n = 1 );
+ void nb_unbound( unsigned int n = 16 );
+
+ bool nb_reduce( unsigned int n = 1 );
+ bool nb_bound( unsigned int n );
+
+ // debug interface
+
+ bool nb_peek( T & , int n ) const;
+ bool nb_poke( const T & , int n = 0 );
+
+ int used() const {
+ return m_num_readable - m_num_read;
+ }
+
+ int size() const {
+ return m_size;
+ }
+
+ void debug() const {
+
+ if( is_empty() ) std::cout << "empty" << std::endl;
+ if( is_full() ) std::cout << "full" << std::endl;
+
+ std::cout << "size " << size() << " - " << used() << " used "
+ << std::endl;
+ std::cout << "readable " << m_num_readable
+ << std::endl;
+ std::cout << "written/read " << m_num_written << "/" << m_num_read
+ << std::endl;
+
+ }
+
+ // support functions
+
+ static const char* const kind_string;
+
+ const char* kind() const
+ { return kind_string; }
+
+
+protected:
+ sc_core::sc_event &read_event( tlm_tag<T> * = 0 ) {
+ return m_data_read_event;
+ }
+
+protected:
+
+ void update();
+
+ // support methods
+
+ void init( int );
+
+protected:
+
+ circular_buffer<T> buffer;
+
+ int m_size; // logical size of fifo
+
+ int m_num_readable; // #samples readable
+ int m_num_read; // #samples read during this delta cycle
+ int m_num_written; // #samples written during this delta cycle
+ bool m_expand; // has an expand occurred during this delta cycle ?
+ int m_num_read_no_notify; // #samples read without notify during this delta cycle
+
+ sc_core::sc_event m_data_read_event;
+ sc_core::sc_event m_data_written_event;
+
+private:
+
+ // disabled
+ tlm_fifo( const tlm_fifo<T>& );
+ tlm_fifo& operator = ( const tlm_fifo<T>& );
+
+ //
+ // use nb_can_get() and nb_can_put() rather than the following two
+ // private functions
+ //
+
+ bool is_empty() const {
+ return used() == 0;
+ }
+
+ bool is_full() const {
+ //return size() == m_num_readable + m_num_written; // Old buggy code
+ if( size() < 0 )
+ return false;
+ else
+ return size() <= m_num_readable + m_num_written;
+ }
+
+};
+
+template <typename T>
+const char* const tlm_fifo<T>::kind_string = "tlm_fifo";
+
+
+/******************************************************************
+//
+// init and update
+//
+******************************************************************/
+
+template< typename T >
+inline
+void
+tlm_fifo<T>::init( int size_ ) {
+
+ if( size_ > 0 ) {
+ buffer.resize( size_ );
+ }
+
+ else if( size_ < 0 ) {
+ buffer.resize( -size_ );
+ }
+
+ else {
+ buffer.resize( 16 );
+ }
+
+ m_size = size_;
+ m_num_readable = 0;
+ m_num_read = 0;
+ m_num_written = 0;
+ m_expand = false;
+ m_num_read_no_notify = false;
+
+}
+
+template < typename T>
+inline
+void
+tlm_fifo<T>::update()
+{
+ if( m_num_read > m_num_read_no_notify || m_expand ) {
+ m_data_read_event.notify( sc_core::SC_ZERO_TIME );
+ }
+
+ if( m_num_written > 0 ) {
+ m_data_written_event.notify( sc_core::SC_ZERO_TIME );
+ }
+
+ m_expand = false;
+ m_num_read = 0;
+ m_num_written = 0;
+ m_num_readable = buffer.used();
+ m_num_read_no_notify = 0;
+
+}
+
+} // namespace tlm
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_put_get.h"
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h"
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h"
+
+#endif
+
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h
new file mode 100644
index 000000000..e856c5657
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h
@@ -0,0 +1,98 @@
+/*****************************************************************************
+
+ 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 __TLM_FIFO_PEEK_H__
+#define __TLM_FIFO_PEEK_H__
+
+namespace tlm {
+
+template < typename T>
+inline
+T
+tlm_fifo<T>::peek( tlm_tag<T> * ) const {
+
+ while( is_empty() ) {
+
+ // call free-standing sc_core::wait(),
+ // since sc_prim_channel::wait(.) is not const
+
+ sc_core::wait( m_data_written_event );
+ }
+
+ return buffer.read_data();
+
+}
+
+template < typename T>
+inline
+bool
+tlm_fifo<T>::nb_peek( T &t ) const {
+
+ if( used() < 1 ) {
+ return false;
+ }
+
+ t = buffer.peek_data( 0 );
+ return true;
+
+}
+
+template < typename T>
+inline
+bool
+tlm_fifo<T>::nb_peek( T &t , int n ) const {
+
+ if( n >= used() || n < -1 ) {
+ return false;
+ }
+
+ if( n == -1 ) {
+ n = used() - 1;
+ }
+
+ t = buffer.peek_data( n );
+ return true;
+
+}
+
+template< typename T >
+inline
+bool
+tlm_fifo<T>::nb_can_peek( tlm_tag<T> * ) const
+{
+ return !is_empty();
+}
+
+template < typename T>
+inline
+bool
+tlm_fifo<T>::nb_poke( const T &t , int n ) {
+
+ if( n >= used() || n < 0 ) {
+ return false;
+ }
+
+ buffer.poke_data( n ) = t;
+ return true;
+
+}
+
+} // namespace tlm
+
+#endif
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_put_get.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_put_get.h
new file mode 100644
index 000000000..2728e0394
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_put_get.h
@@ -0,0 +1,140 @@
+/*****************************************************************************
+
+ 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 __TLM_FIFO_PUT_GET_IF_H__
+#define __TLM_FIFO_PUT_GET_IF_H__
+
+namespace tlm {
+
+/******************************************************************
+//
+// get interface
+//
+******************************************************************/
+
+template <typename T>
+inline
+T
+tlm_fifo<T>::get( tlm_tag<T> * )
+{
+
+ while( is_empty() ) {
+ wait( m_data_written_event );
+ }
+
+ m_num_read ++;
+ request_update();
+
+ return buffer.read();
+
+}
+
+// non-blocking read
+
+template <typename T>
+inline
+bool
+tlm_fifo<T>::nb_get( T& val_ )
+{
+
+ if( is_empty() ) {
+ return false;
+ }
+
+ m_num_read ++;
+ request_update();
+
+ val_ = buffer.read();
+
+ return true;
+
+}
+
+template <typename T>
+inline
+bool
+tlm_fifo<T>::nb_can_get( tlm_tag<T> * ) const {
+
+ return !is_empty();
+
+}
+
+
+/******************************************************************
+//
+// put interface
+//
+******************************************************************/
+
+template <typename T>
+inline
+void
+tlm_fifo<T>::put( const T& val_ )
+{
+ while( is_full() ) {
+ wait( m_data_read_event );
+ }
+
+ if( buffer.is_full() ) {
+
+ buffer.resize( buffer.size() * 2 );
+
+ }
+
+ m_num_written ++;
+ buffer.write( val_ );
+
+ request_update();
+}
+
+template <typename T>
+inline
+bool
+tlm_fifo<T>::nb_put( const T& val_ )
+{
+
+ if( is_full() ) {
+ return false;
+ }
+
+ if( buffer.is_full() ) {
+
+ buffer.resize( buffer.size() * 2 );
+
+ }
+
+ m_num_written ++;
+ buffer.write( val_ );
+ request_update();
+
+ return true;
+}
+
+template < typename T >
+inline
+bool
+tlm_fifo<T>::nb_can_put( tlm_tag<T> * ) const {
+
+ return !is_full();
+
+}
+
+} // namespace tlm
+
+#endif
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h
new file mode 100644
index 000000000..39932fea1
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h
@@ -0,0 +1,93 @@
+/*****************************************************************************
+
+ 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 __TLM_FIFO_RESIZE_H__
+#define __TLM_FIFO_RESIZE_H__
+
+/******************************************************************
+//
+// resize interface
+//
+******************************************************************/
+
+namespace tlm {
+
+template < typename T>
+inline
+void
+tlm_fifo<T>::nb_expand( unsigned int n ) {
+
+ if( m_size >= 0 ) {
+ m_expand = true;
+ m_size += n;
+ request_update();
+ }
+}
+
+template < typename T>
+inline
+void
+tlm_fifo<T>::nb_unbound( unsigned int n ) {
+
+ m_expand = true;
+ m_size = -n;
+
+ if( buffer.size() < static_cast<int>( n ) ) {
+ buffer.resize( n );
+ }
+
+ request_update();
+
+}
+
+template < typename T>
+inline
+bool
+tlm_fifo<T>::nb_reduce( unsigned int n ) {
+
+ if( m_size < 0 ) {
+ return false;
+ }
+
+ return nb_bound( size() - n );
+
+}
+
+template < typename T>
+inline
+bool
+tlm_fifo<T>::nb_bound( unsigned int new_size ) {
+
+ bool ret = true;
+
+ if( static_cast<int>( new_size ) < used() ) {
+
+ new_size = used();
+ ret = false;
+
+ }
+
+ m_size = new_size;
+ return ret;
+
+}
+
+} // namespace tlm
+
+#endif
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h
new file mode 100644
index 000000000..36dbd21d6
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h
@@ -0,0 +1,114 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+//
+// To the LRM writer : these classes are purely artifacts of the implementation.
+//
+
+#ifndef __TLM_PUT_GET_IMP_H__
+#define __TLM_PUT_GET_IMP_H__
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h"
+
+namespace tlm {
+
+template < typename PUT_DATA , typename GET_DATA>
+class tlm_put_get_imp :
+ private virtual tlm_put_if< PUT_DATA > ,
+ private virtual tlm_get_peek_if< GET_DATA >
+{
+public:
+ tlm_put_get_imp( tlm_put_if<PUT_DATA> &p ,
+ tlm_get_peek_if<GET_DATA> &g ) :
+ put_fifo( p ) , get_fifo( g ) {}
+
+ // put interface
+
+ void put( const PUT_DATA &t ) { put_fifo.put( t ); }
+
+ bool nb_put( const PUT_DATA &t ) { return put_fifo.nb_put( t ); }
+ bool nb_can_put( tlm_tag<PUT_DATA> *t = 0 ) const {
+ return put_fifo.nb_can_put( t );
+ }
+ const sc_core::sc_event &ok_to_put( tlm_tag<PUT_DATA> *t = 0 ) const {
+ return put_fifo.ok_to_put( t );
+ }
+
+ // get interface
+
+ GET_DATA get( tlm_tag<GET_DATA> * = 0 ) { return get_fifo.get(); }
+
+ bool nb_get( GET_DATA &t ) { return get_fifo.nb_get( t ); }
+
+ bool nb_can_get( tlm_tag<GET_DATA> *t = 0 ) const {
+ return get_fifo.nb_can_get( t );
+ }
+
+ virtual const sc_core::sc_event &ok_to_get( tlm_tag<GET_DATA> *t = 0 ) const {
+ return get_fifo.ok_to_get( t );
+ }
+
+ // peek interface
+
+ GET_DATA peek( tlm_tag<GET_DATA> * = 0 ) const { return get_fifo.peek(); }
+
+ bool nb_peek( GET_DATA &t ) const { return get_fifo.nb_peek( t ); }
+
+ bool nb_can_peek( tlm_tag<GET_DATA> *t = 0 ) const {
+ return get_fifo.nb_can_peek( t );
+ }
+
+ virtual const sc_core::sc_event &ok_to_peek( tlm_tag<GET_DATA> *t = 0 ) const {
+ return get_fifo.ok_to_peek( t );
+ }
+
+private:
+ tlm_put_if<PUT_DATA> &put_fifo;
+ tlm_get_peek_if<GET_DATA> &get_fifo;
+};
+
+template < typename REQ , typename RSP >
+class tlm_master_imp :
+ private tlm_put_get_imp< REQ , RSP > ,
+ public virtual tlm_master_if< REQ , RSP >
+{
+public:
+
+ tlm_master_imp( tlm_put_if<REQ> &req ,
+ tlm_get_peek_if<RSP> &rsp ) :
+ tlm_put_get_imp<REQ,RSP>( req , rsp ) {}
+
+};
+
+template < typename REQ , typename RSP >
+class tlm_slave_imp :
+ private tlm_put_get_imp< RSP , REQ > ,
+ public virtual tlm_slave_if< REQ , RSP >
+{
+public:
+
+ tlm_slave_imp( tlm_get_peek_if<REQ> &req ,
+ tlm_put_if<RSP> &rsp ) :
+ tlm_put_get_imp<RSP,REQ>( rsp , req ) {}
+
+};
+
+} // namespace tlm
+
+#endif
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h
new file mode 100644
index 000000000..7bd5652f7
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h
@@ -0,0 +1,155 @@
+/*****************************************************************************
+
+ 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 __TLM_REQ_RSP_CHANNELS_H__
+#define __TLM_REQ_RSP_CHANNELS_H__
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h"
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h"
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h"
+
+namespace tlm {
+
+template < typename REQ , typename RSP ,
+ typename REQ_CHANNEL = tlm_fifo<REQ> ,
+ typename RSP_CHANNEL = tlm_fifo<RSP> >
+
+class tlm_req_rsp_channel : public sc_core::sc_module
+{
+public:
+ // uni-directional slave interface
+
+ sc_core::sc_export< tlm_fifo_get_if< REQ > > get_request_export;
+ sc_core::sc_export< tlm_fifo_put_if< RSP > > put_response_export;
+
+ // uni-directional master interface
+
+ sc_core::sc_export< tlm_fifo_put_if< REQ > > put_request_export;
+ sc_core::sc_export< tlm_fifo_get_if< RSP > > get_response_export;
+
+ // master / slave interfaces
+
+ sc_core::sc_export< tlm_master_if< REQ , RSP > > master_export;
+ sc_core::sc_export< tlm_slave_if< REQ , RSP > > slave_export;
+
+
+ tlm_req_rsp_channel( int req_size = 1 , int rsp_size = 1 ) :
+ sc_core::sc_module( sc_core::sc_module_name( sc_core::sc_gen_unique_name("tlm_req_rsp_channel") ) ) ,
+ request_fifo( req_size ) ,
+ response_fifo( rsp_size ) ,
+ master( request_fifo , response_fifo ) ,
+ slave( request_fifo , response_fifo )
+ {
+
+ bind_exports();
+
+ }
+
+ tlm_req_rsp_channel( sc_core::sc_module_name module_name ,
+ int req_size = 1 , int rsp_size = 1 ) :
+ sc_core::sc_module( module_name ) ,
+ request_fifo( req_size ) ,
+ response_fifo( rsp_size ) ,
+ master( request_fifo , response_fifo ) ,
+ slave( request_fifo , response_fifo )
+ {
+
+ bind_exports();
+
+ }
+
+private:
+ void bind_exports() {
+
+ put_request_export( request_fifo );
+ get_request_export( request_fifo );
+
+ put_response_export( response_fifo );
+ get_response_export( response_fifo );
+
+ master_export( master );
+ slave_export( slave );
+
+ }
+
+protected:
+ REQ_CHANNEL request_fifo;
+ RSP_CHANNEL response_fifo;
+
+ tlm_master_imp< REQ , RSP > master;
+ tlm_slave_imp< REQ , RSP > slave;
+};
+
+template < typename REQ , typename RSP ,
+ typename REQ_CHANNEL = tlm_fifo<REQ> ,
+ typename RSP_CHANNEL = tlm_fifo<RSP> >
+class tlm_transport_channel : public sc_core::sc_module
+{
+public:
+
+ // master transport interface
+
+ sc_core::sc_export< tlm_transport_if< REQ , RSP > > target_export;
+
+ // slave interfaces
+
+ sc_core::sc_export< tlm_fifo_get_if< REQ > > get_request_export;
+ sc_core::sc_export< tlm_fifo_put_if< RSP > > put_response_export;
+
+ sc_core::sc_export< tlm_slave_if< REQ , RSP > > slave_export;
+
+ tlm_transport_channel() :
+ sc_core::sc_module( sc_core::sc_module_name( sc_core::sc_gen_unique_name("transport_channel" ) ) ) ,
+ target_export("target_export") ,
+ req_rsp( "req_rsp" , 1 , 1 ) ,
+ t2m("ts2m")
+ {
+ do_binding();
+ }
+
+ tlm_transport_channel( sc_core::sc_module_name nm ) :
+ sc_core::sc_module( nm ) ,
+ target_export("target_export") ,
+ req_rsp( "req_rsp" , 1 , 1 ) ,
+ t2m("tsm" )
+ {
+ do_binding();
+ }
+
+private:
+ void do_binding() {
+
+ target_export( t2m.target_export );
+
+ t2m.master_port( req_rsp.master_export );
+
+ get_request_export( req_rsp.get_request_export );
+ put_response_export( req_rsp.put_response_export );
+ slave_export( req_rsp.slave_export );
+
+ }
+
+ tlm_req_rsp_channel< REQ , RSP , REQ_CHANNEL , RSP_CHANNEL > req_rsp;
+ tlm_transport_to_master< REQ , RSP > t2m;
+
+};
+
+} // namespace tlm
+
+#endif
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h
new file mode 100644
index 000000000..60874ce91
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h
@@ -0,0 +1,94 @@
+/*****************************************************************************
+
+ 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 __TLM_EVENT_FINDER_H__
+#define __TLM_EVENT_FINDER_H__
+
+//#include <systemc>
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h"
+
+namespace tlm {
+
+template <class IF , class T>
+class tlm_event_finder_t
+: public sc_core::sc_event_finder
+{
+public:
+
+ // constructor
+
+ tlm_event_finder_t( const sc_core::sc_port_base& port_,
+ const sc_core::sc_event& (IF::*event_method_) ( tlm_tag<T> * ) const )
+ : sc_core::sc_event_finder( port_ ), m_event_method( event_method_ )
+ {}
+
+ // destructor (does nothing)
+
+ virtual ~tlm_event_finder_t()
+ {}
+#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
+ virtual const sc_core::sc_event& find_event( sc_core::sc_interface* if_p = 0 ) const;
+#else
+ virtual const sc_core::sc_event& find_event() const;
+#endif
+
+private:
+
+ const sc_core::sc_event& (IF::*m_event_method) ( tlm_tag<T> * ) const;
+
+private:
+
+ // disabled
+ tlm_event_finder_t();
+ tlm_event_finder_t( const tlm_event_finder_t<IF,T>& );
+ tlm_event_finder_t<IF,T>& operator = ( const tlm_event_finder_t<IF,T>& );
+};
+
+
+#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
+template <class IF , class T>
+inline
+const sc_core::sc_event&
+tlm_event_finder_t<IF,T>::find_event( sc_core::sc_interface* if_p ) const
+{
+ const IF* iface = ( if_p ) ? dynamic_cast<const IF*>( if_p ) :
+ dynamic_cast<const IF*>( port().get_interface() );
+ if( iface == 0 ) {
+ report_error( sc_core::SC_ID_FIND_EVENT_, "port is not bound" );
+ }
+ return (const_cast<IF*>( iface )->*m_event_method) ( 0 );
+}
+#else
+template <class IF , class T>
+inline
+const sc_core::sc_event&
+tlm_event_finder_t<IF,T>::find_event() const
+{
+ const IF* iface = dynamic_cast<const IF*>( port().get_interface() );
+ if( iface == 0 ) {
+ report_error( sc_core::SC_ID_FIND_EVENT_, "port is not bound" );
+ }
+ return (const_cast<IF*>( iface )->*m_event_method) ( 0 );
+}
+#endif
+
+} // namespace tlm
+
+#endif
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h
new file mode 100644
index 000000000..0af1e3487
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h
@@ -0,0 +1,91 @@
+/*****************************************************************************
+
+ 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 __TLM_NONBLOCKING_PORT_H__
+#define __TLM_NONBLOCKING_PORT_H__
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h"
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h"
+
+namespace tlm {
+
+template < typename T >
+class tlm_nonblocking_get_port :
+public sc_core::sc_port< tlm_nonblocking_get_if< T > , 1 >
+{
+public:
+ typedef tlm_nonblocking_get_if<T> get_if_type;
+
+ tlm_nonblocking_get_port( const char *port_name ) :
+ sc_core::sc_port< tlm_nonblocking_get_if< T > , 1 >( port_name ) {}
+
+ sc_core::sc_event_finder& ok_to_get() const {
+
+ return *new tlm_event_finder_t< get_if_type , T >(
+ *this,
+ &get_if_type::ok_to_get );
+
+ }
+
+};
+
+template < typename T >
+class tlm_nonblocking_peek_port :
+public sc_core::sc_port< tlm_nonblocking_peek_if< T > , 1 >
+{
+public:
+ typedef tlm_nonblocking_peek_if<T> peek_if_type;
+
+ tlm_nonblocking_peek_port( const char *port_name ) :
+ sc_core::sc_port< tlm_nonblocking_peek_if< T > , 1 >( port_name ) {}
+
+ sc_core::sc_event_finder& ok_to_peek() const {
+
+ return *new tlm_event_finder_t< peek_if_type , T >(
+ *this,
+ &peek_if_type::ok_to_peek );
+
+ }
+
+};
+
+
+template < typename T >
+class tlm_nonblocking_put_port :
+public sc_core::sc_port< tlm_nonblocking_put_if< T > , 1 >
+{
+public:
+ typedef tlm_nonblocking_put_if<T> put_if_type;
+
+ tlm_nonblocking_put_port( const char *port_name ) :
+ sc_core::sc_port< tlm_nonblocking_put_if< T > , 1 >( port_name ) {}
+
+ sc_core::sc_event_finder& ok_to_put() const {
+
+ return *new tlm_event_finder_t< put_if_type , T >(
+ *this,
+ &put_if_type::ok_to_put );
+
+ }
+
+};
+
+} // namespace tlm
+
+#endif
diff --git a/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h
new file mode 100644
index 000000000..88f1d0e8c
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h
@@ -0,0 +1,37 @@
+/*****************************************************************************
+
+ 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 __TLM_REQ_RSP_H__
+#define __TLM_REQ_RSP_H__
+
+// The unannotated TLM interfaces
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h"
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h"
+
+// The channels : tlm_fifo, tlm_transport_channel and tlm_req_rsp_channel
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h"
+
+// Some non blocking ports to provide static sensitivity
+
+#include "tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h"
+
+
+#endif /* __TLM_REQ_RSP_H__ */