From: Gabe Black Date: Tue, 11 Dec 2018 07:02:13 +0000 (-0800) Subject: systemc: Remove redundant tlm_ prefixes from file names. X-Git-Tag: v19.0.0.0~1303 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fc5df0bdadfa6a9902b9369e97cd80300c21da4d;p=gem5.git systemc: Remove redundant tlm_ prefixes from file names. We already know those files belong to tlm because of the directory they're in. Removing the prefix makes the paths of the headers less enormously long. Change-Id: I869e58fae904162f353bb31f4c0919fba08dffa6 Reviewed-on: https://gem5-review.googlesource.com/c/15059 Reviewed-by: Anthony Gutierrez Maintainer: Anthony Gutierrez --- diff --git a/src/systemc/ext/tlm b/src/systemc/ext/tlm index 5ba3e4fc3..3e671f737 100644 --- a/src/systemc/ext/tlm +++ b/src/systemc/ext/tlm @@ -22,12 +22,12 @@ #include // main SystemC header -#include "tlm_core/tlm_2/tlm_version.h" -#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis.h" -#include "tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h" -#include "tlm_core/tlm_2/tlm_2_interfaces/tlm_2_interfaces.h" -#include "tlm_core/tlm_2/tlm_generic_payload/tlm_generic_payload.h" -#include "tlm_core/tlm_2/tlm_sockets/tlm_sockets.h" -#include "tlm_core/tlm_2/tlm_quantum/tlm_quantum.h" +#include "tlm_core/2/version.h" +#include "tlm_core/1/analysis/analysis.h" +#include "tlm_core/1/req_rsp/req_rsp.h" +#include "tlm_core/2/interfaces/interfaces.h" +#include "tlm_core/2/generic_payload/generic_payload.h" +#include "tlm_core/2/sockets/sockets.h" +#include "tlm_core/2/quantum/quantum.h" #endif /* __SYSTEMC_EXT_TLM__ */ diff --git a/src/systemc/ext/tlm_core/1/README.txt b/src/systemc/ext/tlm_core/1/README.txt new file mode 100644 index 000000000..7963e4544 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/README.txt @@ -0,0 +1,97 @@ +TLM-1.0 header files +==================== + +Dir: include/tlm_core/1/ + +SubDirs: analysis/ + req_rsp/ + +Files: README.txt + + +Comments +======== + +User code should only #include the tlm or tlm.h header file in the include/ +directory and avoid including any of the include files in this directory +directly. All objects defined in this file hierarchy are in the tlm namespace. + +The header files are organizated, by subdirectory, as follows: + + +tlm_analysis/ +-------------- + +This contains the analysis interfaces, ports, and fifos. These files were not +part of the original TLM-1.0 release, but have been grouped with TLM-1.0 in this +release of TLM-2.0 + +Files: + analysis.h (includes the other header files in this directory ) + analysis_fifo.h (defines tlm_analysis_fifo ) + analysis_if.h (defines tlm_analysis_if and tlm_delayed_analysis_if ) + analysis_port.h (defines tlm_analysis_port ) + analysis_triple.h (defines tlm_analysis_triple ) + write_if.h (defines tlm_write_if and tlm_delayed_write_if ) + + +req_rsp/ +------------ + +This provides support for TLM modeling based on a request/response pair that +are passed by value. This is the original TLM 1.0 standard, with the addition +of an overloading of the blocking transport method with pass-by-reference arguments. + +Files: + req_rsp.h (includes the key header files from the other directories) + + interfaces/ + core_ifs.h (defines the TLM 1.0 core interfaces: + tlm_transport_if + tlm_blocking_get_if + tlm_blocking_put_if + tlm_nonblocking_get_if + tlm_nonblocking_put_if + tlm_get_if + tlm_put_if + tlm_blocking_peek_if + tlm_nonblocking_peek_if + tlm_peek_if + tlm_blocking_get_peek_if + tlm_nonblocking_get_peek_if + tlm_get_peek_if ) + fifo_ifs.h ( defines the TLM1.0 fifo interfaces: + tlm_fifo_debug_if + tlm_fifo_put_if + tlm_fifo_get_if + tlm_fifo_config_size_if ) + master_slave_ifs.h ( defines the TLM1.0 master slave interfaces: + tlm_blocking_master_if + tlm_blocking_slave_if + tlm_nonblocking_master_if + tlm_nonblocking_slave_if + tlm_master_if + tlm_slave_if ) + tag.h ( defines tlm_tag ) + + ports/ + nonblocking_port.h (defines tlm_nonblocking_put_port, + tlm_nonblocking_get_port and + tlm_nonblocking_peek_port ) + event_finder.h (defines tlm_event_finder_t ) + + channels/ + fifo/ + fifo.h (defines tlm_fifo, includes the other files ) + fifo_peek.h (defines peek and poke interfaces for tlm_fifo ) + fifo_put_get.h (defines put and get interfaces for tlm_fifo ) + fifo_resize.h (defines expand, reduce, bound and unbound + interfaces for tlm_fifo ) + circular_buffer.h (defines circular buffer used by tlm_fifo ) + req_rsp_channels/ + req_rsp_channels.h (defines tlm_req_rsp_channel and + tlm_transport_channel ) + put_get_imp.h (contains implementatins used by the channels) + + adapters/ + adapters.h (defines transport_to_master and tlm_slave_to_transport) diff --git a/src/systemc/ext/tlm_core/1/analysis/analysis.h b/src/systemc/ext/tlm_core/1/analysis/analysis.h new file mode 100644 index 000000000..7e8b7e4b4 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/analysis/analysis.h @@ -0,0 +1,29 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_H__ + +#include "tlm_core/1/analysis/analysis_fifo.h" +#include "tlm_core/1/analysis/analysis_if.h" +#include "tlm_core/1/analysis/analysis_port.h" +#include "tlm_core/1/analysis/analysis_triple.h" +#include "tlm_core/1/analysis/write_if.h" + +#endif /* __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_H__ */ diff --git a/src/systemc/ext/tlm_core/1/analysis/analysis_fifo.h b/src/systemc/ext/tlm_core/1/analysis/analysis_fifo.h new file mode 100644 index 000000000..ce3a27f84 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/analysis/analysis_fifo.h @@ -0,0 +1,46 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_FIFO_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_FIFO_H__ + +#include "tlm_core/1/analysis/analysis_if.h" +#include "tlm_core/1/analysis/analysis_triple.h" +#include "tlm_core/1/req_rsp/channels/fifo/fifo.h" + +namespace tlm +{ + +template +class tlm_analysis_fifo : public tlm_fifo, + public virtual tlm_analysis_if, + public virtual tlm_analysis_if> +{ + public: + // analysis fifo is an unbounded tlm_fifo + tlm_analysis_fifo(const char *nm) : tlm_fifo(nm, -16) {} + tlm_analysis_fifo() : tlm_fifo(-16) {} + + void write(const tlm_analysis_triple &t) { nb_put(t); } + void write(const T &t) { nb_put(t); } +}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_FIFO_H__ */ diff --git a/src/systemc/ext/tlm_core/1/analysis/analysis_if.h b/src/systemc/ext/tlm_core/1/analysis/analysis_if.h new file mode 100644 index 000000000..7602c6350 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/analysis/analysis_if.h @@ -0,0 +1,38 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_IF_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_IF_H__ + +#include "tlm_core/1/analysis/write_if.h" + +namespace tlm +{ + +template +class tlm_analysis_if : public virtual tlm_write_if +{}; + +template +class tlm_delayed_analysis_if : public virtual tlm_delayed_write_if +{}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_IF_H__ */ diff --git a/src/systemc/ext/tlm_core/1/analysis/analysis_port.h b/src/systemc/ext/tlm_core/1/analysis/analysis_port.h new file mode 100644 index 000000000..4d9df6d9c --- /dev/null +++ b/src/systemc/ext/tlm_core/1/analysis/analysis_port.h @@ -0,0 +1,78 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_PORT_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_PORT_H__ + +#include +#include + +#include "tlm_core/1/analysis/analysis_if.h" + +namespace tlm +{ + +template +class tlm_analysis_port : public sc_core::sc_object, + public virtual tlm_analysis_if +{ + public: + tlm_analysis_port() : sc_core::sc_object() {} + tlm_analysis_port(const char *nm) : sc_core::sc_object(nm) {} + + // bind and () work for both interfaces and analysis ports, since + // analysis ports implement the analysis interface. + + virtual void + bind(tlm_analysis_if &_if) + { + m_interfaces.push_back(&_if); + } + + void operator() (tlm_analysis_if &_if) { bind(_if); } + virtual bool + unbind(tlm_analysis_if &_if) + { + typename std::deque *>::iterator i = + std::remove(m_interfaces.begin(), m_interfaces.end(), &_if); + + if (i != m_interfaces.end()) { + m_interfaces.erase(i, m_interfaces.end()); + return 1; + } + return 0; + } + + void + write(const T &t) + { + typename std::deque *>::iterator i; + + for (i = m_interfaces.begin(); i != m_interfaces.end(); i++) { + (*i)->write(t); + } + } + + private: + std::deque *> m_interfaces; +}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_PORT_H__ */ diff --git a/src/systemc/ext/tlm_core/1/analysis/analysis_triple.h b/src/systemc/ext/tlm_core/1/analysis/analysis_triple.h new file mode 100644 index 000000000..033b738b2 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/analysis/analysis_triple.h @@ -0,0 +1,53 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_TRIPLE_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_TRIPLE_H__ + +namespace tlm +{ + +template +struct tlm_analysis_triple +{ + sc_core::sc_time start_time; + T transaction; + sc_core::sc_time end_time; + + tlm_analysis_triple() {} + + tlm_analysis_triple(const tlm_analysis_triple &triple) + { + start_time = triple.start_time; + transaction = triple.transaction; + end_time = triple.end_time; + } + + tlm_analysis_triple(const T &t) + { + transaction = t; + } + + operator T() { return transaction; } + operator const T &() const { return transaction; } +}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_ANALYSIS_TRIPLE_H__ */ diff --git a/src/systemc/ext/tlm_core/1/analysis/write_if.h b/src/systemc/ext/tlm_core/1/analysis/write_if.h new file mode 100644 index 000000000..f4ee68d5b --- /dev/null +++ b/src/systemc/ext/tlm_core/1/analysis/write_if.h @@ -0,0 +1,44 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_WRITE_IF_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_WRITE_IF_H__ + +#include + +namespace tlm +{ + +template +class tlm_write_if : public virtual sc_core::sc_interface +{ + public: + virtual void write(const T &t) = 0; +}; + +template +class tlm_delayed_write_if : public virtual sc_core::sc_interface +{ + public: + virtual void write(const T &t, const sc_core::sc_time &time) = 0; +}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_1_ANALYSIS_WRITE_IF_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/adapters/adapters.h b/src/systemc/ext/tlm_core/1/req_rsp/adapters/adapters.h new file mode 100644 index 000000000..4aee66bea --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/adapters/adapters.h @@ -0,0 +1,100 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_ADAPTERS_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_ADAPTERS_H__ + +#include "tlm_core/1/req_rsp/interfaces/master_slave_ifs.h" + +namespace tlm +{ + +template +class tlm_transport_to_master : public sc_core::sc_module, + public virtual tlm_transport_if +{ + public: + sc_core::sc_export> target_export; + sc_core::sc_port> 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 +class tlm_slave_to_transport : public sc_core::sc_module +{ + public: + SC_HAS_PROCESS(tlm_slave_to_transport); + + sc_core::sc_port> slave_port; + sc_core::sc_port> 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 /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_ADAPTERS_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/circular_buffer.h b/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/circular_buffer.h new file mode 100644 index 000000000..7625d712c --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/circular_buffer.h @@ -0,0 +1,252 @@ +/***************************************************************************** + + 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_CORE_1_REQ_RSP_CHANNELS_FIFO_CIRCULAR_BUFFER_H__ +#define __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_CIRCULAR_BUFFER_H__ + +#include + +namespace tlm +{ + +template +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(); + + // Disabled. + circular_buffer(const circular_buffer &b); + circular_buffer &operator = (const circular_buffer &); + + 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 +void +circular_buffer::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 +circular_buffer::circular_buffer(int size) : m_size(size), m_buf(0) +{ + init(); +} + +template +void +circular_buffer::clear() +{ + for (int i = 0; i < used(); i++) { + buf_clear(m_buf, (m_ri + i) % m_size); + } + m_free = m_size; + m_used = m_ri = m_wi = 0; +} + +template +circular_buffer::~circular_buffer() +{ + clear(); + buf_free(m_buf); +} + +template +void +circular_buffer::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 +void +circular_buffer::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 +T +circular_buffer::read() +{ + T t = read_data(); + + buf_clear(m_buf, m_ri); + increment_read_pos(); + + return t; +} + +template +void +circular_buffer::write(const T &t) +{ + buf_write(m_buf, m_wi, t); + increment_write_pos(); +} + +template +void +circular_buffer::increment_write_pos(int i) +{ + m_wi = (m_wi + i) % m_size; + m_used += i; + m_free -= i; +} + +template +void +circular_buffer::increment_read_pos(int i) +{ + m_ri = (m_ri + i) % m_size; + m_used -= i; + m_free += i; +} + +template +inline void * +circular_buffer::buf_alloc(int size) +{ + return new unsigned char [size * sizeof(T)]; +} + +template +inline void +circular_buffer::buf_free(void *&buf) +{ + delete [] static_cast(buf); + buf = nullptr; +} + +template +inline void +circular_buffer::buf_write(void *buf, int n, const T &t) +{ + T *p = static_cast(buf) + n; + new (p)T(t); +} + +template +inline T & +circular_buffer::buf_read(void *buf, int n) const +{ + T *p = static_cast(buf) + n; + return *p; +} + +template +inline void +circular_buffer::buf_clear(void *buf, int n) +{ + T *p = static_cast(buf) + n; + p->~T(); +} + +} // namespace tlm + +#endif /* __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_CIRCULAR_BUFFER_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/fifo.h b/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/fifo.h new file mode 100644 index 000000000..a85c89045 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/fifo.h @@ -0,0 +1,230 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_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 "tlm_core/1/req_rsp/channels/fifo/circular_buffer.h" +#include "tlm_core/1/req_rsp/interfaces/fifo_ifs.h" + +namespace tlm +{ + +template +class tlm_fifo : public virtual tlm_fifo_get_if, + public virtual tlm_fifo_put_if, 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 * =nullptr); + + bool nb_get(T &); + bool nb_can_get(tlm_tag * =nullptr) const; + const sc_core::sc_event & + ok_to_get(tlm_tag * =nullptr) const + { + return m_data_written_event; + } + + // Tlm peek interface. + T peek(tlm_tag * =nullptr) const; + + bool nb_peek(T &) const; + bool nb_can_peek(tlm_tag * =nullptr) const; + const sc_core::sc_event & + ok_to_peek(tlm_tag * =nullptr) const + { + return m_data_written_event; + } + + // Tlm put interface. + void put(const T &); + + bool nb_put(const T &); + bool nb_can_put(tlm_tag * =nullptr) const; + const sc_core::sc_event & + ok_to_put(tlm_tag * =nullptr) 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 * =nullptr) + { + return m_data_read_event; + } + + void update(); + void init(int); + + circular_buffer 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 ? + // #samples read without notify during this delta cycle + int m_num_read_no_notify; + + sc_core::sc_event m_data_read_event; + sc_core::sc_event m_data_written_event; + + private: + // disabled + tlm_fifo(const tlm_fifo &); + tlm_fifo &operator = (const tlm_fifo &); + + // + // 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 + { + if (size() < 0) + return false; + else + return size() <= m_num_readable + m_num_written; + } +}; + +template +const char *const tlm_fifo::kind_string = "tlm_fifo"; + +/****************************************************************** +// +// init and update +// +******************************************************************/ + +template +inline void +tlm_fifo::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 +inline void +tlm_fifo::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/1/req_rsp/channels/fifo/fifo_peek.h" +#include "tlm_core/1/req_rsp/channels/fifo/fifo_put_get.h" +#include "tlm_core/1/req_rsp/channels/fifo/fifo_resize.h" + +#endif /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/fifo_peek.h b/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/fifo_peek.h new file mode 100644 index 000000000..c132852f9 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/fifo_peek.h @@ -0,0 +1,87 @@ +/***************************************************************************** + + 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_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_PEEK_H__ +#define __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_PEEK_H__ + +namespace tlm +{ + +template +inline T +tlm_fifo::peek(tlm_tag *) 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 +inline bool +tlm_fifo::nb_peek(T &t) const +{ + if (used() < 1) { + return false; + } + + t = buffer.peek_data(0); + return true; +} + +template +inline bool +tlm_fifo::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 +inline bool +tlm_fifo::nb_can_peek(tlm_tag *) const +{ + return !is_empty(); +} + +template +inline bool +tlm_fifo::nb_poke(const T &t, int n) +{ + if (n >= used() || n < 0) { + return false; + } + + buffer.poke_data(n) = t; + return true; +} + +} // namespace tlm + +#endif /* __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_PEEK_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/fifo_put_get.h b/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/fifo_put_get.h new file mode 100644 index 000000000..8d34d2a56 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/fifo_put_get.h @@ -0,0 +1,113 @@ +/***************************************************************************** + + 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_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_PUT_GET_H__ +#define __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_PUT_GET_H__ + +namespace tlm +{ + +// Get interface. +template +inline T +tlm_fifo::get(tlm_tag *) +{ + while (is_empty()) { + wait(m_data_written_event); + } + + m_num_read++; + request_update(); + + return buffer.read(); +} + +// Non-blocking read. +template +inline bool +tlm_fifo::nb_get(T &val_) +{ + if (is_empty()) { + return false; + } + + m_num_read++; + request_update(); + + val_ = buffer.read(); + + return true; +} + +template +inline bool +tlm_fifo::nb_can_get(tlm_tag *) const +{ + return !is_empty(); +} + + +// Put interface. +template +inline void +tlm_fifo::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 +inline bool +tlm_fifo::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 +inline bool +tlm_fifo::nb_can_put(tlm_tag *) const +{ + return !is_full(); +} + +} // namespace tlm + +#endif /* __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_PUT_GET_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/fifo_resize.h b/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/fifo_resize.h new file mode 100644 index 000000000..3f936fb9c --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/channels/fifo/fifo_resize.h @@ -0,0 +1,80 @@ +/***************************************************************************** + + 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_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_RESIZE_H__ +#define __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_RESIZE_H__ + +// Resize interface. +namespace tlm +{ + +template +inline void +tlm_fifo::nb_expand(unsigned int n) +{ + if (m_size >= 0) { + m_expand = true; + m_size += n; + request_update(); + } +} + +template +inline void +tlm_fifo::nb_unbound(unsigned int n) +{ + m_expand = true; + m_size = -n; + + if (buffer.size() < static_cast(n)) { + buffer.resize(n); + } + + request_update(); +} + +template +inline bool +tlm_fifo::nb_reduce(unsigned int n) +{ + if (m_size < 0) { + return false; + } + + return nb_bound(size() - n); +} + +template +inline bool +tlm_fifo::nb_bound(unsigned int new_size) +{ + bool ret = true; + + if (static_cast(new_size) < used()) { + new_size = used(); + ret = false; + } + + m_size = new_size; + return ret; +} + +} // namespace tlm + +#endif /* __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_RESIZE_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/channels/req_rsp_channels/put_get_imp.h b/src/systemc/ext/tlm_core/1/req_rsp/channels/req_rsp_channels/put_get_imp.h new file mode 100644 index 000000000..e821573b9 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/channels/req_rsp_channels/put_get_imp.h @@ -0,0 +1,115 @@ +/***************************************************************************** + + 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 \ + __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_PUT_GET_IMP_H__ +#define \ + __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_PUT_GET_IMP_H__ + +#include "tlm_core/1/req_rsp/interfaces/master_slave_ifs.h" + +namespace tlm +{ + +template +class tlm_put_get_imp : private virtual tlm_put_if, + private virtual tlm_get_peek_if +{ + public: + tlm_put_get_imp(tlm_put_if &p, tlm_get_peek_if &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 *t=nullptr) const + { + return put_fifo.nb_can_put(t); + } + const sc_core::sc_event & + ok_to_put(tlm_tag *t=nullptr) const + { + return put_fifo.ok_to_put(t); + } + + // Get interface. + GET_DATA get(tlm_tag * =nullptr) { return get_fifo.get(); } + bool nb_get(GET_DATA &t) { return get_fifo.nb_get(t); } + bool + nb_can_get(tlm_tag *t=nullptr) const + { + return get_fifo.nb_can_get(t); + } + + virtual const sc_core::sc_event & + ok_to_get(tlm_tag *t=nullptr) const + { + return get_fifo.ok_to_get(t); + } + + // Peek interface. + GET_DATA + peek(tlm_tag * =nullptr) const + { + return get_fifo.peek(); + } + bool nb_peek(GET_DATA &t) const { return get_fifo.nb_peek(t); } + bool + nb_can_peek(tlm_tag *t=nullptr) const + { + return get_fifo.nb_can_peek(t); + } + + virtual const sc_core::sc_event & + ok_to_peek(tlm_tag *t=nullptr) const + { + return get_fifo.ok_to_peek(t); + } + + private: + tlm_put_if &put_fifo; + tlm_get_peek_if &get_fifo; +}; + +template +class tlm_master_imp : private tlm_put_get_imp, + public virtual tlm_master_if +{ + public: + tlm_master_imp(tlm_put_if &req, tlm_get_peek_if &rsp) : + tlm_put_get_imp(req, rsp) + {} +}; + +template +class tlm_slave_imp : private tlm_put_get_imp, + public virtual tlm_slave_if +{ + public: + tlm_slave_imp(tlm_get_peek_if &req, tlm_put_if &rsp) : + tlm_put_get_imp(rsp, req) + {} +}; + +} // namespace tlm + +#endif +/* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_PUT_GET_IMP_H__*/ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/channels/req_rsp_channels/req_rsp_channels.h b/src/systemc/ext/tlm_core/1/req_rsp/channels/req_rsp_channels/req_rsp_channels.h new file mode 100644 index 000000000..321d947ea --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/channels/req_rsp_channels/req_rsp_channels.h @@ -0,0 +1,138 @@ +/***************************************************************************** + + 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 __EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_H__ +#define __EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_H__ + +#include "tlm_core/1/req_rsp/adapters/adapters.h" +#include "tlm_core/1/req_rsp/channels/fifo/fifo.h" +#include "tlm_core/1/req_rsp/channels/req_rsp_channels/put_get_imp.h" + +namespace tlm +{ + +template , + typename RSP_CHANNEL=tlm_fifo> +class tlm_req_rsp_channel : public sc_core::sc_module +{ + public: + // Uni-directional slave interface. + sc_core::sc_export> get_request_export; + sc_core::sc_export> put_response_export; + + // Uni-directional master interface. + sc_core::sc_export> put_request_export; + sc_core::sc_export> get_response_export; + + // Master/slave interfaces. + sc_core::sc_export> master_export; + sc_core::sc_export> 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 master; + tlm_slave_imp slave; +}; + +template , + typename RSP_CHANNEL=tlm_fifo> +class tlm_transport_channel : public sc_core::sc_module +{ + public: + // Master transport interface. + sc_core::sc_export> target_export; + + // Slave interfaces. + sc_core::sc_export> get_request_export; + sc_core::sc_export> put_response_export; + + sc_core::sc_export> 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; + tlm_transport_to_master t2m; +}; + +} // namespace tlm + +#endif +/* __EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/interfaces/core_ifs.h b/src/systemc/ext/tlm_core/1/req_rsp/interfaces/core_ifs.h new file mode 100644 index 000000000..2a5778784 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/interfaces/core_ifs.h @@ -0,0 +1,135 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_INTERFACES_CORE_IFS_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_INTERFACES_CORE_IFS_H__ + +#include "tlm_core/1/req_rsp/interfaces/tag.h" + +namespace tlm +{ + +// Bidirectional blocking interfaces. +template +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 +class tlm_blocking_get_if : public virtual sc_core::sc_interface +{ + public: + virtual T get(tlm_tag *t=nullptr) = 0; + virtual void get(T &t) { t = get(); } +}; + +template +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 +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=nullptr) const = 0; + virtual const sc_core::sc_event & + ok_to_get(tlm_tag *t=nullptr) const = 0; +}; + +template +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=nullptr) const = 0; + virtual const sc_core::sc_event & + ok_to_put(tlm_tag *t=nullptr) const = 0; +}; + +// Combined uni-directional blocking and non blocking. +template +class tlm_get_if : public virtual tlm_blocking_get_if, + public virtual tlm_nonblocking_get_if +{}; + +template +class tlm_put_if : public virtual tlm_blocking_put_if, + public virtual tlm_nonblocking_put_if +{}; + +// Peek interfaces. +template +class tlm_blocking_peek_if : public virtual sc_core::sc_interface +{ + public: + virtual T peek(tlm_tag *t=nullptr) const = 0; + virtual void peek(T &t) const { t = peek(); } +}; + +template +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=nullptr) const = 0; + virtual const sc_core::sc_event & + ok_to_peek(tlm_tag *t=nullptr) const = 0; +}; + +template +class tlm_peek_if : + public virtual tlm_blocking_peek_if, + public virtual tlm_nonblocking_peek_if +{}; + +// Get_peek interfaces. +template +class tlm_blocking_get_peek_if : public virtual tlm_blocking_get_if, + public virtual tlm_blocking_peek_if +{}; + +template +class tlm_nonblocking_get_peek_if : public virtual tlm_nonblocking_get_if, + public virtual tlm_nonblocking_peek_if +{}; + +template +class tlm_get_peek_if : public virtual tlm_get_if, + public virtual tlm_peek_if, public virtual tlm_blocking_get_peek_if, + public virtual tlm_nonblocking_get_peek_if +{}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_INTERFACES_CORE_IFS_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/interfaces/fifo_ifs.h b/src/systemc/ext/tlm_core/1/req_rsp/interfaces/fifo_ifs.h new file mode 100644 index 000000000..20d3b7e08 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/interfaces/fifo_ifs.h @@ -0,0 +1,79 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_INTERFACES_FIFO_IFS_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_INTERFACES_FIFO_IFS_H__ + +#include "tlm_core/1/req_rsp/interfaces/core_ifs.h" + +namespace tlm +{ + +// +// Fifo specific interfaces +// + +// Fifo Debug Interface + +template +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 +class tlm_fifo_put_if : public virtual tlm_put_if, + public virtual tlm_fifo_debug_if +{}; + +template +class tlm_fifo_get_if : + public virtual tlm_get_peek_if, + public virtual tlm_fifo_debug_if +{}; + +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 /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_INTERFACES_FIFO_IFS_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/interfaces/master_slave_ifs.h b/src/systemc/ext/tlm_core/1/req_rsp/interfaces/master_slave_ifs.h new file mode 100644 index 000000000..a1411c9ee --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/interfaces/master_slave_ifs.h @@ -0,0 +1,75 @@ +/***************************************************************************** + + 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_CORE_1_REQ_RSP_INTERFACES_MASTER_SLAVE_IFS_H__ +#define __TLM_CORE_1_REQ_RSP_INTERFACES_MASTER_SLAVE_IFS_H__ + +#include "tlm_core/1/req_rsp/interfaces/core_ifs.h" + +namespace tlm +{ + +// +// req/rsp combined interfaces +// + +// Blocking. +template +class tlm_blocking_master_if : + public virtual tlm_blocking_put_if, + public virtual tlm_blocking_get_peek_if +{}; + +template +class tlm_blocking_slave_if : + public virtual tlm_blocking_put_if, + public virtual tlm_blocking_get_peek_if +{}; + +// Nonblocking. +template +class tlm_nonblocking_master_if : + public virtual tlm_nonblocking_put_if, + public virtual tlm_nonblocking_get_peek_if +{}; + +template +class tlm_nonblocking_slave_if : + public virtual tlm_nonblocking_put_if, + public virtual tlm_nonblocking_get_peek_if +{}; + +// Combined. +template +class tlm_master_if : public virtual tlm_put_if, + public virtual tlm_get_peek_if , + public virtual tlm_blocking_master_if, + public virtual tlm_nonblocking_master_if +{}; + +template +class tlm_slave_if : public virtual tlm_put_if, + public virtual tlm_get_peek_if, + public virtual tlm_blocking_slave_if, + public virtual tlm_nonblocking_slave_if +{}; + +} // namespace tlm + +#endif /* __TLM_CORE_1_REQ_RSP_INTERFACES_MASTER_SLAVE_IFS_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/interfaces/tag.h b/src/systemc/ext/tlm_core/1/req_rsp/interfaces/tag.h new file mode 100644 index 000000000..7aa7581c8 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/interfaces/tag.h @@ -0,0 +1,32 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_INTERFACES_TAG_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_INTERFACES_TAG_H__ + +namespace tlm +{ + +template +class tlm_tag +{}; + +} + +#endif /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_INTERFACES_TAG_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/ports/event_finder.h b/src/systemc/ext/tlm_core/1/req_rsp/ports/event_finder.h new file mode 100644 index 000000000..61ac88664 --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/ports/event_finder.h @@ -0,0 +1,68 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_EVENT_FINDER_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_EVENT_FINDER_H__ + +#include "tlm_core/1/req_rsp/interfaces/tag.h" + +namespace tlm +{ + +template +class tlm_event_finder_t : public sc_core::sc_event_finder +{ + public: + tlm_event_finder_t(const sc_core::sc_port_base &port_, + const sc_core::sc_event &(IF::*event_method_)( + tlm_tag *) const) : + sc_core::sc_event_finder(port_), m_event_method(event_method_) + {} + + virtual ~tlm_event_finder_t() {} + + virtual const sc_core::sc_event & + find_event(sc_core::sc_interface *if_p=nullptr) const; + + private: + const sc_core::sc_event &(IF::*m_event_method)(tlm_tag *) const; + + private: + // disabled + tlm_event_finder_t(); + tlm_event_finder_t(const tlm_event_finder_t &); + tlm_event_finder_t &operator = (const tlm_event_finder_t &); +}; + +template +inline const sc_core::sc_event & +tlm_event_finder_t::find_event(sc_core::sc_interface *if_p) const +{ + const IF *iface = if_p ? dynamic_cast(if_p) : + dynamic_cast(port()->_gem5Interface(0)); + if (iface == nullptr) { + report_error(sc_core::SC_ID_FIND_EVENT_, "port is not bound"); + return sc_core::sc_event::none; + } + return (const_cast(iface)->*m_event_method)(nullptr); +} + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_EVENT_FINDER_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/ports/nonblocking_port.h b/src/systemc/ext/tlm_core/1/req_rsp/ports/nonblocking_port.h new file mode 100644 index 000000000..099d2fe7c --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/ports/nonblocking_port.h @@ -0,0 +1,88 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_NONBLOCKING_PORT_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_NONBLOCKING_PORT_H__ + +#include "tlm_core/1/req_rsp/interfaces/core_ifs.h" +#include "tlm_core/1/req_rsp/ports/event_finder.h" + +namespace tlm +{ + +template +class tlm_nonblocking_get_port : + public sc_core::sc_port, 1> +{ + public: + typedef tlm_nonblocking_get_if get_if_type; + + tlm_nonblocking_get_port(const char *port_name) : + sc_core::sc_port, 1>(port_name) + {} + + sc_core::sc_event_finder & + ok_to_get() const + { + return *new tlm_event_finder_t( + *this, &get_if_type::ok_to_get); + } +}; + +template +class tlm_nonblocking_peek_port : + public sc_core::sc_port, 1> +{ + public: + typedef tlm_nonblocking_peek_if peek_if_type; + + tlm_nonblocking_peek_port(const char *port_name) : + sc_core::sc_port, 1>(port_name) + {} + + sc_core::sc_event_finder & + ok_to_peek() const + { + return *new tlm_event_finder_t( + *this, &peek_if_type::ok_to_peek); + } +}; + +template +class tlm_nonblocking_put_port : + public sc_core::sc_port, 1> +{ + public: + typedef tlm_nonblocking_put_if put_if_type; + + tlm_nonblocking_put_port(const char *port_name) : + sc_core::sc_port, 1>(port_name) + {} + + sc_core::sc_event_finder & + ok_to_put() const + { + return *new tlm_event_finder_t( + *this, &put_if_type::ok_to_put); + } +}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_NONBLOCKING_PORT_H__ */ diff --git a/src/systemc/ext/tlm_core/1/req_rsp/req_rsp.h b/src/systemc/ext/tlm_core/1/req_rsp/req_rsp.h new file mode 100644 index 000000000..746a8598a --- /dev/null +++ b/src/systemc/ext/tlm_core/1/req_rsp/req_rsp.h @@ -0,0 +1,36 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_REQ_RSP_H__ +#define __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_REQ_RSP_H__ + +// The unannotated TLM interfaces. + +#include "tlm_core/1/req_rsp/interfaces/core_ifs.h" +#include "tlm_core/1/req_rsp/interfaces/master_slave_ifs.h" + +// The channels : tlm_fifo, tlm_transport_channel and tlm_req_rsp_channel. + +#include "tlm_core/1/req_rsp/channels/req_rsp_channels/req_rsp_channels.h" + +// Some non blocking ports to provide static sensitivity. + +#include "tlm_core/1/req_rsp/ports/nonblocking_port.h" + +#endif /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_REQ_RSP_H__ */ diff --git a/src/systemc/ext/tlm_core/2/README.txt b/src/systemc/ext/tlm_core/2/README.txt new file mode 100644 index 000000000..e3074dea7 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/README.txt @@ -0,0 +1,111 @@ +TLM-2.0 interoperability layer header files +=========================================== + +Dir: include/tlm_core/2/ + +SubDirs: interfaces/ + generic_payload/ + quantum/ + sockets + +Files: README.txt + version.h + + +Comments +======== + +User code should only #include the tlm or tlm.h header file in the include/ +directory and avoid including any of the include files in this directory +directly. All objects defined in this file hierarchy are in the tlm namespace. + +tlm_version.h contains the definitions for the version string and integer values + +The header files are organizated, by subdirectory, as follows: + + +interfaces/ +----------------- + +Contains the TLM-2.0 core interfaces + +Files: + interfaces.h (includes the other header files in this directory ) + fw_bw_ifs.h (defines the TLM 2.0 interface API's: + tlm_fw_nonblocking_transport_if + tlm_bw_nonblocking_transport_if + tlm_blocking_transport_if + tlm_fw_direct_mem_if + tlm_bw_direct_mem_if + tlm_transport_dbg_if + the enumeration type + tlm_sync_enum + and the TLM 2.0 standard interfaces using the API's + tlm_fw_transport_if + tlm_bw_transport_if ) + dmi.h (defines tlm_dmi) + + +generic_payload/ +-------------------- + +Contains the TLM-2.0 generic payload and associated classes and helper functions + +Files: + generic_payload.h ( includes the other header files in this directory) + gp.h (defines the TLM 2.0 generic payload classes: + tlm_generic_payload + tlm_extension + tlm_extension_base + tlm_mm_interface + and the enumeration types + tlm_command + tlm_response_status ) + array.h (defines array class used by the extention + mechanism ) + endian_conv.h (defines the implementation for the endianness + helper functions: + tlm_to_hostendian_generic() + tlm_from_hostendian_generic() + tlm_to_hostendian_word() + tlm_from_hostendian_word() + tlm_to_hostendian_aligned() + tlm_from_hostendian_aligned() + tlm_to_hostendian_single() + tlm_from_hostendian_single() ) + + helpers.h (defines the helper functions to determine the + hostendianness: + get_host_endianness() + host_has_little_endianness() + has_host_endianness() + and defines the enumeration type: + tlm_endianness + phase.h (defines tlm_phase as an extendable enum type) + + +sockets/ +------------ + +Contains the standard TLM-2.0 initiator and target sockets (which are used as +the base classes for the convenience sockets in tlm_utils) + +Files: + sockets.h (includes the other header files in this directory) + initiator_socket.h (defines the initiator sockets: + tlm_initiator_socket_base + tlm_initiator_socket_b + tlm_initiator_socket + target_socket.h (defines the target sockets: + tlm_target_socket_base + tlm_target_socket_b + tlm_target_socket + + +quantum/ +------------ +This contains the global quantum. (The quantum keeper is in tlm_utils) + +Files: + quantum.h ( includes the other header file in this directory ) + global_quantum.h ( defines tlm_global_quantum ) diff --git a/src/systemc/ext/tlm_core/2/generic_payload/array.h b/src/systemc/ext/tlm_core/2/generic_payload/array.h new file mode 100644 index 000000000..1c6c724a4 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/generic_payload/array.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 __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOADS_ARRAY_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOADS_ARRAY_H__ + +#include + +namespace tlm +{ + +// This implements a lean and fast array class that supports array expansion on +// request. The class is primarily used in the tlm_generic_payload class for +// storing the pointers to the extensions. +// +// Individual array elements can be accessed through the [] operators, and the +// array length is returned by the size() method. +// +// The size can be dynamically expanded using the expand(uint) method. There +// is no shrinking mechanism implemented, because the extension mechanism +// does not require this feature. Bear in mind that calling the expand method +// may invalidate all direct pointers into the array. + + +// The tlm_array shall always be used with T=tlm_extension_base*. +template +class tlm_array : private std::vector +{ + private: + typedef std::vector base_type; + typedef typename base_type::size_type size_type; + + public: + tlm_array(size_type size=0) : base_type(size), m_entries() {} + + // Operators for dereferencing: + using base_type::operator []; + + // Array size: + using base_type::size; + + // Expand the array if needed: + void + expand(size_type new_size) + { + if (new_size > size()) + base_type::resize(new_size); + } + + static const char *const kind_string; + const char *kind() const { return kind_string; } + + // This function shall get a pointer to an array slot + // it stores this slot in a cache of active slots + void insert_in_cache(T *p) { m_entries.push_back(p - &(*this)[0]); } + + // This functions clears all active slots of the array. + void + free_entire_cache() + { + while (m_entries.size()) { + // We make sure no one cleared the slot manually. + if ((*this)[m_entries.back()]) { + // ...and then we call free on the content of the slot + (*this)[m_entries.back()]->free(); + } + // Afterwards we set the slot to NULL + (*this)[m_entries.back()] = nullptr; + m_entries.pop_back(); + } + } + + protected: + std::vector m_entries; +}; + +template +const char *const tlm_array::kind_string = "tlm_array"; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOADS_ARRAY_H__ */ diff --git a/src/systemc/ext/tlm_core/2/generic_payload/endian_conv.h b/src/systemc/ext/tlm_core/2/generic_payload/endian_conv.h new file mode 100644 index 000000000..50d5e6873 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/generic_payload/endian_conv.h @@ -0,0 +1,941 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_ENDIAN_CONV_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_ENDIAN_CONV_H__ + +#include // std::memset + +#include "tlm_core/2/generic_payload/gp.h" + +namespace tlm +{ + +/* +Tranaction-Level Modelling +Endianness Helper Functions + +DESCRIPTION +A set of functions for helping users to get the endianness +right in their TLM models of system initiators. These functions are +for use within an initiator. They can not be used as-is outside +an initiator because the extension used to store context will not work +if cascaded, and they do not respect the generic payload mutability +rules. However this code may be easily copied and adapted for use +in bridges, etc.. + +These functions are not compulsory. There are other legitimate ways to +achieve the same functionality. If extra information is available at +compile time about the nature of an initiator's transactions, this can +be exploited to accelerate simulations by creating further functions +similar to those in this file. In general a functional transaction can be +described in more than one way by a TLM-2 GP object. + +The functions convert the endianness of a GP object, either on request or +response. They should only be used when the initiator's endianness +does not match the host's endianness. They assume 'arithmetic mode' +meaning that within a data word the byte order is always host-endian. +For non-arithmetic mode initiators they can be used with a data word +size of 1 byte. + +All the functions are templates, for example: + +template inline void + to_hostendian_generic(tlm_generic_payload *txn, int sizeof_databus) + +The template parameter provides the data word width. Having this as a class +makes it easy to use it for copy and swap operations within the functions. +If the assignment operator for this class is overloaded, the endianness +conversion function may not have the desired effect. + +All the functions have the same signature except for different names. + +The principle is that a function to_hostendian_convtype() is called when the +initiator-endian transaction is created, and the matching function +from_hostendian_convtype() is called when the transaction is completed, for +example before read data can be used. In some cases the from_ function is +redundant but an empty function is provided anyway. It is strongly +recommended that the from_ function is called, in case it ceases to be +redundant in future versions of this code. + +No context needs to be managed outside the two functions, except that they +must be called with the same template parameter and the same bus width. + +For initiator models that can not easily manage this context information, +a single entry point for the from_ function is provided, which will be +a little slower than calling the correct from_ function directly, as +it can not be inlined. + +All functions assume power-of-2 bus and data word widths. + +Functions offered: + +0) A pair of functions that work for almost all TLM2 GP transactions. The +only limitations are that data and bus widths should be powers of 2, and that +the data length should be an integer number of streaming widths and that the +streaming width should be an integer number of data words. +These functions always allocate new data and byte enable buffers and copy +data one byte at a time. + tlm_to_hostendian_generic(tlm_generic_payload *txn, int sizeof_databus) + tlm_from_hostendian_generic(tlm_generic_payload *txn, int sizeof_databus) + +1) A pair of functions that work for all transactions regardless of data and +bus data sizes and address alignment except for the the following +limitations: +- byte-enables are supported only when byte-enable granularity is no finer +than the data word (every data word is wholly enabled or wholly disabled) +- byte-enable-length is not supported (if byte enables are present, the byte +enable length must be equal to the data length). +- streaming width is not supported +- data word wider than bus word is not supported +A new data buffer and a new byte enable buffer are always allocated. Byte +enables are assumed to be needed even if not required for the original +(unconverted) transaction. Data is copied to the new buffer on request +(for writes) or on response (for reads). Copies are done word-by-word +where possible. + tlm_to_hostendian_word(tlm_generic_payload *txn, int sizeof_databus) + tlm_from_hostendian_word(tlm_generic_payload *txn, int sizeof_databus) + +2) If the original transaction is both word and bus-aligned then this pair of +functions can be used. It will complete faster than the generic function +because the data reordering function is much simpler and no address +conversion is required. +The following limitations apply: +- byte-enables are supported only when byte-enable granularity is no finer +than the data word (every data word is wholly enabled or wholly disabled) +- byte-enable-length is not supported (if byte enables are present, the byte +enable length must be equal to the data length). +- streaming width is not supported +- data word wider than bus word is not supported +- the transaction must be an integer number of bus words +- the address must be aligned to the bus width + tlm_to_hostendian_aligned(tlm_generic_payload *txn, int sizeof_databus) + tlm_from_hostendian_aligned(tlm_generic_payload *txn, int sizeof_databus) + +3) For single word transactions that don't cross a bus word boundary it +is always safe to work in-place and the conversion is very simple. Again, +streaming width and byte-enable length are not supported, and byte-enables +may not changes within a data word. + tlm_to_hostendian_single(tlm_generic_payload *txn, int sizeof_databus) + tlm_from_hostendian_single(tlm_generic_payload *txn, int sizeof_databus) + +4) A single entry point for accessing the correct from_ function without +needing to store context. + tlm_from_hostendian(tlm_generic_payload *txn) +*/ + +/////////////////////////////////////////////////////////////////////////////// +// Generic Utilities + +class tlm_endian_context; + +class tlm_endian_context_pool +{ + public: + tlm_endian_context *first; + inline tlm_endian_context_pool(); + inline ~tlm_endian_context_pool(); + inline tlm_endian_context *pop(); + inline void push(tlm_endian_context *c); +}; + +static tlm_endian_context_pool global_tlm_endian_context_pool; + +// an extension to keep the information needed for reconversion of response +class tlm_endian_context : public tlm_extension +{ + public: + tlm_endian_context() : dbuf_size(0), bebuf_size(0) {} + + ~tlm_endian_context() { + if (dbuf_size > 0) + delete [] new_dbuf; + if (bebuf_size > 0) + delete [] new_bebuf; + } + + sc_dt::uint64 address; // Used by generic, word. + sc_dt::uint64 new_address; // Used by generic. + unsigned char *data_ptr; // Used by generic, word, aligned. + unsigned char *byte_enable; // Used by word. + int length; // Used by generic, word. + int stream_width; // Used by generic. + + // Used by common entry point on response. + void (*from_f)(tlm_generic_payload *txn, unsigned int sizeof_databus); + int sizeof_databus; + + // Reordering buffers for data and byte-enables. + unsigned char *new_dbuf, *new_bebuf; + int dbuf_size, bebuf_size; + + void + establish_dbuf(int len) + { + if (len <= dbuf_size) + return; + if (dbuf_size > 0) + delete [] new_dbuf; + new_dbuf = new unsigned char[len]; + dbuf_size = len; + } + + void + establish_bebuf(int len) + { + if (len <= bebuf_size) + return; + if (bebuf_size > 0) + delete [] new_bebuf; + new_bebuf = new unsigned char[len]; + bebuf_size = len; + } + + // Required for extension management. + void free() { global_tlm_endian_context_pool.push(this); } + tlm_extension_base *clone() const { return 0; } + void copy_from(tlm_extension_base const &) { return; } + + // For pooling. + tlm_endian_context *next; +}; + +// Assumptions about transaction contexts: +// 1) only the address attribute of a transaction +// is mutable. all other attributes are unchanged from the request to +// response side conversion. +// 2) the conversion functions in this file do not respect the mutability +// rules and do not put the transaction back into its original state after +// completion. so if the initiator has any cleaning up to do (eg of byte +// enable buffers), it needs to store its own context. the transaction +// returned to the initiator may contain pointers to data and byte enable +// that can/must not be deleted. +// 3) the conversion functions in this file use an extension to store +// context information. they do not remove this extension. the initiator +// should not remove it unless it deletes the generic payload +// object. + +inline tlm_endian_context * +establish_context(tlm_generic_payload *txn) +{ + tlm_endian_context *tc = txn->get_extension(); + if (tc == 0) { + tc = global_tlm_endian_context_pool.pop(); + txn->set_extension(tc); + } + return tc; +} + +inline tlm_endian_context_pool::tlm_endian_context_pool() : first(0) {} + +inline tlm_endian_context_pool::~tlm_endian_context_pool() +{ + while (first != 0) { + tlm_endian_context *next = first->next; + delete first; + first = next; + } +} + +tlm_endian_context * +tlm_endian_context_pool::pop() +{ + if (first == 0) + return new tlm_endian_context; + tlm_endian_context *r = first; + first = first->next; + return r; +} + +void tlm_endian_context_pool::push(tlm_endian_context *c) +{ + c->next = first; + first = c; +} + + +// A set of constants for efficient filling of byte enables. +template +class tlm_bool +{ + public: + static D TLM_TRUE; + static D TLM_FALSE; + static D + make_uchar_array(unsigned char c) + { + D d; + unsigned char *tmp = (unsigned char *)(&d); + for (ptrdiff_t i = 0; i != sizeof(D); i++) + tmp[i] = c; // 64BITFIX negligable risk but easy fix. + return d; + } + + // Also provides an syntax-efficient tester, using a + // copy constuctor and an implicit cast to boolean. + tlm_bool(D &d) : b(*((unsigned char *)&d) != TLM_BYTE_DISABLED) {} + operator bool() const { return b; } + private: + bool b; +}; + +template +D tlm_bool::TLM_TRUE = tlm_bool::make_uchar_array(TLM_BYTE_ENABLED); +template +D tlm_bool::TLM_FALSE = tlm_bool::make_uchar_array(TLM_BYTE_DISABLED); + + + +inline void +copy_db0(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + *dest1 = *src1; + *dest2 = *src2; +} + +inline void +copy_dbtrue0(unsigned char *src1, unsigned char * /* src2 */, + unsigned char *dest1, unsigned char *dest2) +{ + *dest1 = *src1; + *dest2 = TLM_BYTE_ENABLED; +} + +inline void +copy_btrue0(unsigned char * /* src1 */, unsigned char * /* src2 */, + unsigned char * /* dest1 */, unsigned char *dest2) +{ + *dest2 = TLM_BYTE_ENABLED; +} + +inline void +copy_b0(unsigned char * /* src1 */, unsigned char *src2, + unsigned char * /* dest1 */, unsigned char *dest2) +{ + *dest2 = *src2; +} + +inline void +copy_dbyb0(unsigned char *src1, unsigned char * /* src2 */, + unsigned char *dest1, unsigned char *dest2) +{ + if (*dest2 == TLM_BYTE_ENABLED) + *src1 = *dest1; +} + + +template +inline void +loop_generic0(int new_len, int new_stream_width, int orig_stream_width, + int sizeof_databus, sc_dt::uint64 orig_start_address, + sc_dt::uint64 new_start_address, int be_length, + unsigned char *ie_data, unsigned char *ie_be, + unsigned char *he_data, unsigned char *he_be) +{ + for (int orig_sword = 0, new_sword = 0; new_sword < new_len; + new_sword += new_stream_width, orig_sword += orig_stream_width) { + sc_dt::uint64 ie_addr = orig_start_address; + for (int orig_dword = orig_sword; + orig_dword < orig_sword + orig_stream_width; + orig_dword += sizeof(D)) { + for (int curr_byte = orig_dword + sizeof(D) - 1; + curr_byte >= orig_dword; curr_byte--) { + ptrdiff_t he_index = ((ie_addr++) ^ (sizeof_databus - 1)) - + new_start_address + new_sword; // 64BITFIX + COPY(ie_data + curr_byte, + // 64BITRISK no risk of overflow, always positive. + ie_be + (curr_byte % be_length), + he_data + he_index, he_be + he_index); + } + } + } +} + + +/////////////////////////////////////////////////////////////////////////////// +// function set (0): Response +/////////////////////////////////////////////////////////////////////////////// + +template +inline void +tlm_from_hostendian_generic(tlm_generic_payload *txn, + unsigned int sizeof_databus) +{ + if (txn->is_read()) { + tlm_endian_context *tc = + txn->template get_extension(); + loop_generic0(txn->get_data_length(), + txn->get_streaming_width(), tc->stream_width, sizeof_databus, + tc->address, tc->new_address, txn->get_data_length(), + tc->data_ptr, 0, txn->get_data_ptr(), + txn->get_byte_enable_ptr()); + } +} + + +/////////////////////////////////////////////////////////////////////////////// +// function set (0): Request +template +inline void +tlm_to_hostendian_generic(tlm_generic_payload *txn, + unsigned int sizeof_databus) +{ + tlm_endian_context *tc = establish_context(txn); + tc->from_f = &(tlm_from_hostendian_generic); + tc->sizeof_databus = sizeof_databus; + + // Calculate new size: nr stream words multiplied by big enough stream + // width. + int s_width = txn->get_streaming_width(); + int length = txn->get_data_length(); + if (s_width >= length) + s_width = length; + int nr_stream_words = length / s_width; + + // Find out in which bus word the stream word starts and ends. + sc_dt::uint64 new_address = (txn->get_address() & ~(sizeof_databus - 1)); + sc_dt::uint64 end_address = ((txn->get_address() + s_width - 1) & + ~(sizeof_databus - 1)); + + int new_stream_width = end_address - new_address + sizeof_databus; + int new_length = new_stream_width * nr_stream_words; + + // Store context. + tc->data_ptr = txn->get_data_ptr(); + tc->address = txn->get_address(); + tc->new_address = new_address; + tc->stream_width = s_width; + unsigned char *orig_be = txn->get_byte_enable_ptr(); + int orig_be_length = txn->get_byte_enable_length(); + + // Create data and byte-enable buffers. + txn->set_address(new_address); + tc->establish_dbuf(new_length); + txn->set_data_ptr(tc->new_dbuf); + tc->establish_bebuf(new_length); + txn->set_byte_enable_ptr(tc->new_bebuf); + std::memset(txn->get_byte_enable_ptr(), TLM_BYTE_DISABLED, new_length); + txn->set_streaming_width(new_stream_width); + txn->set_data_length(new_length); + txn->set_byte_enable_length(new_length); + + // Copy data and/or byte enables. + if (txn->is_write()) { + if (orig_be == 0) { + loop_generic0( + new_length, new_stream_width, s_width, sizeof_databus, + tc->address, new_address, new_length, tc->data_ptr, 0, + txn->get_data_ptr(), txn->get_byte_enable_ptr()); + } else { + loop_generic0(new_length, new_stream_width, + s_width, sizeof_databus, tc->address, new_address, + orig_be_length, tc->data_ptr, orig_be, + txn->get_data_ptr(), txn->get_byte_enable_ptr()); + } + } else { + // Read transaction. + if (orig_be == 0) { + loop_generic0(new_length, + new_stream_width, s_width, sizeof_databus, tc->address, + new_address, new_length, tc->data_ptr, 0, + txn->get_data_ptr(), txn->get_byte_enable_ptr()); + } else { + loop_generic0(new_length, new_stream_width, + s_width, sizeof_databus, tc->address, new_address, + orig_be_length, tc->data_ptr, orig_be, + txn->get_data_ptr(), txn->get_byte_enable_ptr()); + } + } +} + + +/////////////////////////////////////////////////////////////////////////////// +// function set (1): Utilities +/////////////////////////////////////////////////////////////////////////////// + +template +inline void +copy_d1(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + *((D *)dest1) = *((D *)src1); + *((D *)dest2) = tlm_bool::TLM_TRUE; +} + +template +inline void +copy_db1(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + *((D *)dest1) = *((D *)src1); + *((D *)dest2) = *((D *)src2); +} + +template +inline void +true_b1(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + *((D *)dest2) = tlm_bool::TLM_TRUE; +} + +template +inline void +copy_b1(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + *((D *)dest2) = *((D *)src2); +} + +template +inline void +copy_dbyb1(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + if (*src2 != TLM_BYTE_DISABLED) + *((D *)src1) = *((D *)dest1); +} + +template +inline void +copy_dbytrue1(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + *((D *)src1) = *((D *)dest1); +} + +template +inline void +false_b1(unsigned char *dest1) +{ + *((D *)dest1) = tlm_bool::TLM_FALSE; +} + +template +inline void +no_b1(unsigned char *dest1) +{} + +template +inline int +loop_word1(int bytes_left, int len0, int lenN, int sizeof_databus, + unsigned char *start, unsigned char *end, + unsigned char *src, unsigned char *bsrc, + unsigned char *dest, unsigned char *bdest) +{ + ptrdiff_t d2b_src = bsrc - src; // 64BITFIX was int + ptrdiff_t d2b_dest = bdest - dest; // 64BITFIX was int + unsigned char *original_dest = dest; + + while (true) { + // len0 bytes at start of a bus word. + if ((src >= start) && (src < end)) { + for (int i = 0; i < len0; i++) { + COPYuchar(src, src + d2b_src, dest, dest + d2b_dest); + src++; + dest++; + } + bytes_left -= len0; + if (bytes_left <= 0) + return int(dest - original_dest); + } else { + for (int i = 0; i < len0; i++) { + FILLFALSEuchar(dest + d2b_dest); + src++; + dest++; + } + } + src -= 2 * sizeof(D); + + // Sequence of full data word fragments. + for (unsigned int i = 1; i < sizeof_databus / sizeof(D); i++) { + if ((src >= start) && (src < end)) { + COPY(src, src + d2b_src, dest, dest + d2b_dest); + bytes_left -= sizeof(D); + } else { + FILLFALSE(dest + d2b_dest); + } + dest += sizeof(D); + if (bytes_left <= 0) + return int(dest - original_dest); + src -= sizeof(D); + } + + // lenN bytes at end of bus word. + if ((src >= start) && (src < end)) { + for (int i = 0; i < lenN; i++) { + COPYuchar(src, src + d2b_src, dest, dest + d2b_dest); + src++; + dest++; + } + bytes_left -= lenN; + if (bytes_left <= 0) + return int(dest - original_dest); + } else { + for (int i = 0; i < lenN; i++) { + FILLFALSEuchar(dest + d2b_dest); + src++; + dest++; + } + } + src += 2 * sizeof_databus; + } +} + + +/////////////////////////////////////////////////////////////////////////////// +// function set (1): Response +/////////////////////////////////////////////////////////////////////////////// + +template +inline void +tlm_from_hostendian_word(tlm_generic_payload *txn, unsigned int sizeof_databus) +{ + if (txn->is_read()) { + tlm_endian_context *tc = + txn->template get_extension(); + sc_dt::uint64 b_mask = sizeof_databus - 1; + int d_mask = sizeof(DATAWORD) - 1; + int a_offset = static_cast(tc->address & b_mask); + int len0 = (sizeof_databus - a_offset) & d_mask; + int lenN = sizeof(DATAWORD) - len0; + unsigned char *d_start = tc->data_ptr; + unsigned char *d_end = + ptrdiff_t(tc->length) + d_start; // 64BITFIX probably redundant + unsigned char *d = + ptrdiff_t(((sizeof_databus - a_offset) & ~d_mask) + lenN) + + d_start; // 64BITFIX probably redundant + + // Iterate over transaction copying data qualified by byte-enables. + if (tc->byte_enable == 0) { + loop_word1, + ©_dbytrue1, &no_b1, + &no_b1>( + tc->length, len0, lenN, sizeof_databus, + d_start, d_end, d, 0, txn->get_data_ptr(), 0); + } else { + loop_word1, + ©_dbyb1, &no_b1, + &no_b1>( + tc->length, len0, lenN, sizeof_databus, + d_start, d_end, d, + tc->byte_enable - d_start + d, + txn->get_data_ptr(), 0); + } + } +} + + +/////////////////////////////////////////////////////////////////////////////// +// function set (1): Request +/////////////////////////////////////////////////////////////////////////////// + +template +inline void +tlm_to_hostendian_word(tlm_generic_payload *txn, unsigned int sizeof_databus) +{ + tlm_endian_context *tc = establish_context(txn); + tc->from_f = &(tlm_from_hostendian_word); + tc->sizeof_databus = sizeof_databus; + + sc_dt::uint64 b_mask = sizeof_databus - 1; + int d_mask = sizeof(DATAWORD) - 1; + sc_dt::uint64 a_aligned = txn->get_address() & ~b_mask; + int a_offset = static_cast(txn->get_address() & b_mask); + int len0 = (sizeof_databus - a_offset) & d_mask; + int lenN = sizeof(DATAWORD) - len0; + unsigned char *d_start = txn->get_data_ptr(); + unsigned char *d_end = + ptrdiff_t(txn->get_data_length()) + d_start; + // 64BITFIX probably redundant. + unsigned char *d = + ptrdiff_t(((sizeof_databus - a_offset) & ~d_mask) + lenN) + d_start; + // 64BITFIX probably redundant. + + // Create new data and byte enable buffers. + int long_enough = txn->get_data_length() + 2 * sizeof_databus; + tc->establish_dbuf(long_enough); + unsigned char *new_data = tc->new_dbuf; + tc->establish_bebuf(long_enough); + unsigned char *new_be = tc->new_bebuf; + + if (txn->is_read()) { + tc->data_ptr = d_start; + tc->address = txn->get_address(); + tc->byte_enable = txn->get_byte_enable_ptr(); + tc->length = txn->get_data_length(); + if (txn->get_byte_enable_ptr() == 0) { + // Iterate over transaction creating new byte enables from all-true + txn->set_data_length( + loop_word1, + &true_b1, &false_b1, + &false_b1>( + txn->get_data_length(), len0, lenN, + sizeof_databus, d_start, d_end, d, 0, + new_data, new_be)); + } else { + // iterate over transaction copying byte enables + txn->set_data_length( + loop_word1, + ©_b1, &false_b1, + &false_b1>( + txn->get_data_length(), len0, lenN, + sizeof_databus, d_start, d_end, d, + txn->get_byte_enable_ptr() - d_start + d, + new_data, new_be)); + } + } else { + // WRITE + if (txn->get_byte_enable_ptr() == 0) { + // Iterate over transaction copying data and creating new + // byte-enables. + txn->set_data_length( + loop_word1, + ©_d1, &false_b1, + &false_b1>( + txn->get_data_length(), len0, lenN, + sizeof_databus, d_start, d_end, d, 0, + new_data, new_be)); + } else { + // Iterate over transaction copying data and byte-enables. + txn->set_data_length( + loop_word1, + ©_db1, &false_b1, + &false_b1>( + txn->get_data_length(), len0, lenN, + sizeof_databus, d_start, d_end, d, + txn->get_byte_enable_ptr() - d_start + d, + new_data, new_be)); + } + } + txn->set_byte_enable_length(txn->get_data_length()); + txn->set_streaming_width(txn->get_data_length()); + txn->set_data_ptr(new_data); + txn->set_byte_enable_ptr(new_be); + txn->set_address(a_aligned); +} + + + +/////////////////////////////////////////////////////////////////////////////// +// function set (2): Utilities +/////////////////////////////////////////////////////////////////////////////// + +template +inline void copy_d2(D *src1, D *src2, D *dest1, D *dest2) { *dest1 = *src1; } + +template +inline void +copy_db2(D *src1, D *src2, D *dest1, D *dest2) +{ + *dest1 = *src1; + *dest2 = *src2; +} + +template +inline void +copy_dbyb2(D *src1, D *src2, D *dest1, D *dest2) +{ + if (tlm_bool(*src2)) + *dest1 = *src1; +} + +template +inline void +loop_aligned2(D *src1, D *src2, D *dest1, D *dest2, int words, + int words_per_bus) +{ + // 64BITFIX was int and operands were cast to int. + ptrdiff_t src1to2 = (char *)src2 - (char *)src1; + // 64BITFIX was int and operands were cast to int. + ptrdiff_t dest1to2 = (char *)dest2 - (char *)dest1; + + D *done = src1 + ptrdiff_t(words); // 64BITFIX. + D *bus_start = src1; + src1 += ptrdiff_t(words_per_bus - 1); // 64BITFIX. + + while (true) { + COPY(src1, (D *)(src1to2 + (char *)src1), dest1, + (D *)(dest1to2 + (char *)dest1)); // 64BITFIX. + dest1++; + if ((--src1) < bus_start) { + bus_start += ptrdiff_t(words_per_bus); // 64BITFIX. + if (bus_start == done) + break; + src1 = bus_start + ptrdiff_t(words_per_bus - 1); // 64BITFIX. + } + } +} + + +/////////////////////////////////////////////////////////////////////////////// +// function set (2): Response +/////////////////////////////////////////////////////////////////////////////// + +template +inline void +tlm_from_hostendian_aligned( + tlm_generic_payload *txn, unsigned int sizeof_databus) +{ + int words_per_bus = sizeof_databus / sizeof(DATAWORD); + if (words_per_bus == 1) + return; + int words = (txn->get_data_length()) / sizeof(DATAWORD); + tlm_endian_context *tc = txn->template get_extension(); + + if (txn->get_byte_enable_ptr() == 0) { + // no byte enables + if (txn->is_read()) { + // RD without byte enables. Copy data to original buffer. + loop_aligned2>( + (DATAWORD *)(txn->get_data_ptr()), 0, + (DATAWORD *)(tc->data_ptr), 0, words, words_per_bus); + } + } else { + // byte enables present + if (txn->is_read()) { + // RD with byte enables. Copy data qualified by byte-enables. + loop_aligned2>( + (DATAWORD *)(txn->get_data_ptr()), + (DATAWORD *)(txn->get_byte_enable_ptr()), + (DATAWORD *)(tc->data_ptr), 0, words, words_per_bus); + } + } +} + + +/////////////////////////////////////////////////////////////////////////////// +// function set (2): Request +/////////////////////////////////////////////////////////////////////////////// + +template +inline void +tlm_to_hostendian_aligned( + tlm_generic_payload *txn, unsigned int sizeof_databus) +{ + tlm_endian_context *tc = establish_context(txn); + tc->from_f = &(tlm_from_hostendian_aligned); + tc->sizeof_databus = sizeof_databus; + + int words_per_bus = sizeof_databus / sizeof(DATAWORD); + if (words_per_bus == 1) + return; + int words = (txn->get_data_length()) / sizeof(DATAWORD); + + DATAWORD *original_be = (DATAWORD *)(txn->get_byte_enable_ptr()); + DATAWORD *original_data = (DATAWORD *)(txn->get_data_ptr()); + + // Always allocate a new data buffer. + tc->establish_dbuf(txn->get_data_length()); + txn->set_data_ptr(tc->new_dbuf); + + if (original_be == 0) { + // No byte enables. + if (txn->is_write()) { + // WR no byte enables. Copy data. + loop_aligned2>( + original_data, 0, (DATAWORD *)(txn->get_data_ptr()), 0, + words, words_per_bus); + } else { + // RD no byte enables. Save original data pointer. + tc->data_ptr = (unsigned char *)original_data; + } + } else { + // Byte enables present. + // Allocate a new buffer for them. + tc->establish_bebuf(txn->get_data_length()); + txn->set_byte_enable_ptr(tc->new_bebuf); + txn->set_byte_enable_length(txn->get_data_length()); + + if (txn->is_write()) { + // WR with byte enables. Copy data and BEs. + loop_aligned2>( + original_data, original_be, + (DATAWORD *)(txn->get_data_ptr()), + (DATAWORD *)(txn->get_byte_enable_ptr()), + words, words_per_bus); + } else { + // RD with byte enables. Save original data pointer. + tc->data_ptr = (unsigned char *)original_data; + // Copy byte enables to new buffer. + loop_aligned2>( + original_be, 0, (DATAWORD *)(txn->get_byte_enable_ptr()), + 0, words, words_per_bus); + } + } +} + + + +/////////////////////////////////////////////////////////////////////////////// +// function set (3): Response +/////////////////////////////////////////////////////////////////////////////// + +template +inline void +tlm_from_hostendian_single( + tlm_generic_payload *txn, unsigned int sizeof_databus) +{} + + +/////////////////////////////////////////////////////////////////////////////// +// function set (3): Request +/////////////////////////////////////////////////////////////////////////////// + +template +inline void +tlm_to_hostendian_single(tlm_generic_payload *txn, unsigned int sizeof_databus) +{ + tlm_endian_context *tc = establish_context(txn); + tc->from_f = &(tlm_from_hostendian_single); + tc->sizeof_databus = sizeof_databus; + + // Only need to change the address, always safe to work in-place. + sc_dt::uint64 mask = sizeof_databus - 1; + sc_dt::uint64 a = txn->get_address(); + txn->set_address((a & ~mask) | + (sizeof_databus - (a & mask) - sizeof(DATAWORD))); +} + + + +/////////////////////////////////////////////////////////////////////////////// +// helper function which works for all responses +/////////////////////////////////////////////////////////////////////////////// + +inline void +tlm_from_hostendian(tlm_generic_payload *txn) +{ + tlm_endian_context *tc = txn->get_extension(); + (*(tc->from_f))(txn, tc->sizeof_databus); +} + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_ENDIAN_CONV_H__ */ diff --git a/src/systemc/ext/tlm_core/2/generic_payload/generic_payload.h b/src/systemc/ext/tlm_core/2/generic_payload/generic_payload.h new file mode 100644 index 000000000..fb10b8809 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/generic_payload/generic_payload.h @@ -0,0 +1,28 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_GENERIC_GENERIC_PAYLOAD_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_GENERIC_GENERIC_PAYLOAD_H__ + +#include "tlm_core/2/generic_payload/endian_conv.h" +#include "tlm_core/2/generic_payload/gp.h" +#include "tlm_core/2/generic_payload/helpers.h" +#include "tlm_core/2/generic_payload/phase.h" + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_GENERIC_GENERIC_PAYLOAD_H__ */ diff --git a/src/systemc/ext/tlm_core/2/generic_payload/gp.h b/src/systemc/ext/tlm_core/2/generic_payload/gp.h new file mode 100644 index 000000000..84bc25a01 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/generic_payload/gp.h @@ -0,0 +1,428 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_GP_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_GP_H__ + +#include +#include // std::type_info + +#include "tlm_core/2/generic_payload/array.h" + +namespace tlm +{ + +class tlm_generic_payload; + +class tlm_mm_interface +{ + public: + virtual void free(tlm_generic_payload *) = 0; + virtual ~tlm_mm_interface() {} +}; + +//--------------------------------------------------------------------------- +// Classes and helpers for the extension mechanism +//--------------------------------------------------------------------------- +// Helper function: +unsigned int max_num_extensions(); + +// This class can be used for storing pointers to the extension classes, used +// in tlm_generic_payload: +class tlm_extension_base +{ + public: + virtual tlm_extension_base *clone() const = 0; + virtual void free() { delete this; } + virtual void copy_from(tlm_extension_base const &) = 0; + protected: + virtual ~tlm_extension_base() {} + static unsigned int register_extension(const std::type_info &); +}; + +// Base class for all extension classes, derive your extension class in +// the following way: +// class my_extension : public tlm_extension { ... +// This triggers proper extension registration during C++ static +// contruction time. my_extension::ID will hold the unique index in the +// tlm_generic_payload::m_extensions array. +template +class tlm_extension : public tlm_extension_base +{ + public: + virtual tlm_extension_base *clone() const = 0; + virtual void copy_from(tlm_extension_base const &ext) = 0; + virtual ~tlm_extension() {} + const static unsigned int ID; +}; + +template +const unsigned int tlm_extension::ID = + tlm_extension_base::register_extension(typeid(T)); + +//--------------------------------------------------------------------------- +// enumeration types +//--------------------------------------------------------------------------- +enum tlm_command +{ + TLM_READ_COMMAND, + TLM_WRITE_COMMAND, + TLM_IGNORE_COMMAND +}; + +enum tlm_response_status +{ + TLM_OK_RESPONSE = 1, + TLM_INCOMPLETE_RESPONSE = 0, + TLM_GENERIC_ERROR_RESPONSE = -1, + TLM_ADDRESS_ERROR_RESPONSE = -2, + TLM_COMMAND_ERROR_RESPONSE = -3, + TLM_BURST_ERROR_RESPONSE = -4, + TLM_BYTE_ENABLE_ERROR_RESPONSE = -5 +}; + +enum tlm_gp_option +{ + TLM_MIN_PAYLOAD, + TLM_FULL_PAYLOAD, + TLM_FULL_PAYLOAD_ACCEPTED +}; + +#define TLM_BYTE_DISABLED 0x0 +#define TLM_BYTE_ENABLED 0xff + +//--------------------------------------------------------------------------- +// The generic payload class: +//--------------------------------------------------------------------------- + +extern template class tlm_array; + +class tlm_generic_payload +{ + public: + tlm_generic_payload(); + explicit tlm_generic_payload(tlm_mm_interface *mm); + + void + acquire() + { + sc_assert(m_mm != 0); + m_ref_count++; + } + + void + release() + { + sc_assert(m_mm != 0 && m_ref_count > 0); + if (--m_ref_count == 0) + m_mm->free(this); + } + + int get_ref_count() const { return m_ref_count; } + + void set_mm(tlm_mm_interface *mm) { m_mm = mm; } + bool has_mm() const { return m_mm != 0; } + + void reset(); + + private: + // Disabled copy ctor and assignment operator. + tlm_generic_payload(const tlm_generic_payload &x); + tlm_generic_payload &operator = (const tlm_generic_payload &x); + + public: + // Non-virtual deep-copying of the object. + void deep_copy_from(const tlm_generic_payload &other); + + // To update the state of the original generic payload from a deep copy. + // Assumes that "other" was created from the original by calling + // deep_copy_from Argument use_byte_enable_on_read determines whether to + // use or ignores byte enables when copying back the data array on a read + // command. + + void update_original_from(const tlm_generic_payload &other, + bool use_byte_enable_on_read=true); + + void update_extensions_from(const tlm_generic_payload &other); + + // Free all extensions. Useful when reusing a cloned transaction that + // doesn't have memory manager. Normal and sticky extensions are freed and + // extension array cleared. + void free_all_extensions(); + + virtual ~tlm_generic_payload(); + + //---------------- + // API (including setters & getters). + //--------------- + + // Command related method. + bool is_read() const { return (m_command == TLM_READ_COMMAND); } + void set_read() { m_command = TLM_READ_COMMAND; } + bool is_write() const { return (m_command == TLM_WRITE_COMMAND); } + void set_write() { m_command = TLM_WRITE_COMMAND; } + tlm_command get_command() const { return m_command; } + void set_command(const tlm_command command) { m_command = command; } + + // Address related methods. + sc_dt::uint64 get_address() const { return m_address; } + void set_address(const sc_dt::uint64 address) { m_address = address; } + + // Data related methods. + unsigned char *get_data_ptr() const { return m_data; } + void set_data_ptr(unsigned char *data) { m_data = data; } + + // Transaction length (in bytes) related methods. + unsigned int get_data_length() const { return m_length; } + void set_data_length(const unsigned int length) { m_length = length; } + + // Response status related methods. + bool is_response_ok() const { return (m_response_status > 0); } + bool is_response_error() const { return (m_response_status <= 0); } + tlm_response_status + get_response_status() const + { + return m_response_status; + } + void + set_response_status(const tlm_response_status response_status) + { + m_response_status = response_status; + } + std::string get_response_string() const; + + // Streaming related methods. + unsigned int get_streaming_width() const { return m_streaming_width; } + void + set_streaming_width(const unsigned int streaming_width) + { + m_streaming_width = streaming_width; + } + + // Byte enable related methods. + unsigned char *get_byte_enable_ptr() const { return m_byte_enable; } + void + set_byte_enable_ptr(unsigned char *byte_enable) + { + m_byte_enable = byte_enable; + } + unsigned int + get_byte_enable_length() const + { + return m_byte_enable_length; + } + void + set_byte_enable_length(const unsigned int byte_enable_length) + { + m_byte_enable_length = byte_enable_length; + } + + // This is the "DMI-hint" a slave can set this to true if it + // wants to indicate that a DMI request would be supported: + void + set_dmi_allowed(bool dmi_allowed) + { + m_dmi = dmi_allowed; + } + bool + is_dmi_allowed() const + { + return m_dmi; + } + + // Use full set of attributes in DMI/debug? + tlm_gp_option get_gp_option() const { return m_gp_option; } + void set_gp_option(const tlm_gp_option gp_opt) { m_gp_option = gp_opt; } + + private: + /* --------------------------------------------------------------------- */ + /* Generic Payload attributes: */ + /* --------------------------------------------------------------------- */ + /* - m_command : Type of transaction. Three values supported: */ + /* - TLM_WRITE_COMMAND */ + /* - TLM_READ_COMMAND */ + /* - TLM_IGNORE_COMMAND */ + /* - m_address : Transaction base address (byte-addressing). */ + /* - m_data : When m_command = TLM_WRITE_COMMAND contains a */ + /* pointer to the data to be written in the target.*/ + /* When m_command = TLM_READ_COMMAND contains a */ + /* pointer where to copy the data read from the */ + /* target. */ + /* - m_length : Total number of bytes of the transaction. */ + /* - m_response_status : This attribute indicates whether an error has */ + /* occurred during the transaction. */ + /* Values supported are: */ + /* - TLM_OK_RESP */ + /* - TLM_INCOMPLETE_RESP */ + /* - TLM_GENERIC_ERROR_RESP */ + /* - TLM_ADDRESS_ERROR_RESP */ + /* - TLM_COMMAND_ERROR_RESP */ + /* - TLM_BURST_ERROR_RESP */ + /* - TLM_BYTE_ENABLE_ERROR_RESP */ + /* */ + /* - m_byte_enable : It can be used to create burst transfers where */ + /* the address increment between each beat is greater */ + /* than the word length of each beat, or to place */ + /* words in selected byte lanes of a bus. */ + /* - m_byte_enable_length : For a read or a write command, the target */ + /* interpret the byte enable length attribute as the */ + /* number of elements in the bytes enable array. */ + /* - m_streaming_width : */ + /* --------------------------------------------------------------------- */ + + sc_dt::uint64 m_address; + tlm_command m_command; + unsigned char *m_data; + unsigned int m_length; + tlm_response_status m_response_status; + bool m_dmi; + unsigned char *m_byte_enable; + unsigned int m_byte_enable_length; + unsigned int m_streaming_width; + tlm_gp_option m_gp_option; + + public: + /* --------------------------------------------------------------------- */ + /* Dynamic extension mechanism: */ + /* --------------------------------------------------------------------- */ + /* The extension mechanism is intended to enable initiator modules to */ + /* optionally and transparently add data fields to the */ + /* tlm_generic_payload. Target modules are free to check for extensions */ + /* and may or may not react to the data in the extension fields. The */ + /* definition of the extensions' semantics is solely in the */ + /* responsibility of the user. */ + /* */ + /* The following rules apply: */ + /* */ + /* - Every extension class must be derived from tlm_extension, e.g.: */ + /* class my_extension : public tlm_extension { ... } */ + /* */ + /* - A tlm_generic_payload object should be constructed after C++ */ + /* static initialization time. This way it is guaranteed that the */ + /* extension array is of sufficient size to hold all possible */ + /* extensions. Alternatively, the initiator module can enforce a valid */ + /* extension array size by calling the resize_extensions() method */ + /* once before the first transaction with the payload object is */ + /* initiated. */ + /* */ + /* - Initiators should use the the set_extension(e) or clear_extension(e)*/ + /* methods for manipulating the extension array. The type of the */ + /* argument must be a pointer to the specific registered extension */ + /* type (my_extension in the above example) and is used to */ + /* automatically locate the appropriate index in the array. */ + /* */ + /* - Targets can check for a specific extension by calling */ + /* get_extension(e). e will point to zero if the extension is not */ + /* present. */ + /* */ + /* --------------------------------------------------------------------- */ + + // Stick the pointer to an extension into the vector, return the + // previous value: + template + T * + set_extension(T *ext) + { + return static_cast(set_extension(T::ID, ext)); + } + + // Non-templatized version with manual index: + tlm_extension_base *set_extension( + unsigned int index, tlm_extension_base *ext); + + // Stick the pointer to an extension into the vector, return the + // previous value and schedule its release. + template + T * + set_auto_extension(T *ext) + { + return static_cast(set_auto_extension(T::ID, ext)); + } + + // Non-templatized version with manual index: + tlm_extension_base *set_auto_extension( + unsigned int index, tlm_extension_base *ext); + + // Check for an extension, ext will point to 0 if not present. + template + void get_extension(T *& ext) const { ext = get_extension(); } + template + T * + get_extension() const + { + return static_cast(get_extension(T::ID)); + } + // Non-templatized version with manual index: + tlm_extension_base *get_extension(unsigned int index) const; + + // This call just removes the extension from the txn but does not + // call free() or tells the MM to do so it return false if there was + // active MM so you are now in an unsafe situation recommended use: + // when 100% sure there is no MM. + template + void clear_extension(const T *ext) { clear_extension(); } + + // This call just removes the extension from the txn but does not + // call free() or tells the MM to do so it return false if there was + // active MM so you are now in an unsafe situation recommended use: when + // 100% sure there is no MM. + template + void clear_extension() { clear_extension(T::ID); } + + // This call removes the extension from the txn and does call free() or + // tells the MM to do so when the txn is finally done recommended use: + // when not sure there is no MM. + template + void release_extension(T *ext) + { + release_extension(); + } + + // This call removes the extension from the txn and does call free() or + // tells the MM to do so when the txn is finally done recommended use: + // when not sure there is no MM + template + void release_extension() + { + release_extension(T::ID); + } + + private: + // Non-templatized version with manual index + void clear_extension(unsigned int index); + // Non-templatized version with manual index + void release_extension(unsigned int index); + + public: + // Make sure the extension array is large enough. Can be called once by + // an initiator module (before issuing the first transaction) to make + // sure that the extension array is of correct size. This is only needed + // if the initiator cannot guarantee that the generic payload object is + // allocated after C++ static construction time. + void resize_extensions(); + + private: + tlm_array m_extensions; + tlm_mm_interface *m_mm; + unsigned int m_ref_count; +}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_GP_H__ */ diff --git a/src/systemc/ext/tlm_core/2/generic_payload/helpers.h b/src/systemc/ext/tlm_core/2/generic_payload/helpers.h new file mode 100644 index 000000000..4ec4faeeb --- /dev/null +++ b/src/systemc/ext/tlm_core/2/generic_payload/helpers.h @@ -0,0 +1,70 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_HELPERS_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_HELPERS_H__ + +namespace tlm +{ + +enum tlm_endianness { TLM_UNKNOWN_ENDIAN, TLM_LITTLE_ENDIAN, TLM_BIG_ENDIAN }; + +inline tlm_endianness +get_host_endianness() +{ + static tlm_endianness host_endianness = TLM_UNKNOWN_ENDIAN; + + if (host_endianness == TLM_UNKNOWN_ENDIAN) { + unsigned int number = 1; + unsigned char *p_msb_or_lsb = (unsigned char *)&number; + host_endianness = (p_msb_or_lsb[0] == 0) ? + TLM_BIG_ENDIAN : TLM_LITTLE_ENDIAN; + } + return host_endianness; +} + +inline bool +host_has_little_endianness() +{ + static tlm_endianness host_endianness = TLM_UNKNOWN_ENDIAN; + static bool host_little_endian = false; + + if (host_endianness == TLM_UNKNOWN_ENDIAN) { + unsigned int number = 1; + unsigned char *p_msb_or_lsb = (unsigned char *)&number; + + host_little_endian = (p_msb_or_lsb[0] == 0) ? false : true; + } + + return host_little_endian; +} + +inline bool +has_host_endianness(tlm_endianness endianness) +{ + if (host_has_little_endianness()) { + return endianness == TLM_LITTLE_ENDIAN; + } else { + return endianness == TLM_BIG_ENDIAN; + } +} + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_HELPERS_H__ */ diff --git a/src/systemc/ext/tlm_core/2/generic_payload/phase.h b/src/systemc/ext/tlm_core/2/generic_payload/phase.h new file mode 100644 index 000000000..ca58b2f9d --- /dev/null +++ b/src/systemc/ext/tlm_core/2/generic_payload/phase.h @@ -0,0 +1,117 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_PHASE_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_PHASE_H__ + +#include +#include +#include + +#define SC_CONCAT_HELPER_(a, b) SC_CONCAT_HELPER_DEFERRED_(a, b) +#define SC_CONCAT_HELPER_DEFERRED_(a, b) SC_CONCAT_HELPER_MORE_DEFERRED_(a, b) +#define SC_CONCAT_HELPER_MORE_DEFERRED_(a, b) a ## b + +#define SC_STRINGIFY_HELPER_(a) SC_STRINGIFY_HELPER_DEFERRED_(a) +#define SC_STRINGIFY_HELPER_DEFERRED_(a) SC_STRINGIFY_HELPER_MORE_DEFERRED_(a) +#define SC_STRINGIFY_HELPER_MORE_DEFERRED_(a) #a + +namespace tlm +{ + +enum tlm_phase_enum +{ + UNINITIALIZED_PHASE = 0, + BEGIN_REQ = 1, + END_REQ, + BEGIN_RESP, + END_RESP +}; + +class tlm_phase +{ + public: + tlm_phase(); + tlm_phase(unsigned int id); + + tlm_phase(tlm_phase_enum standard); + tlm_phase &operator = (tlm_phase_enum standard); + + operator unsigned int() const { return m_id; } + const char *get_name() const; + + protected: + // Register extended phase. + tlm_phase(const std::type_info &type, const char *name); + + private: + unsigned int m_id; +}; + +inline tlm_phase::tlm_phase() : m_id(UNINITIALIZED_PHASE) {} + +inline tlm_phase::tlm_phase(tlm_phase_enum standard) : m_id(standard) {} + +inline tlm_phase & +tlm_phase::operator = (tlm_phase_enum standard) +{ + m_id = standard; + return *this; +} + +inline std::ostream & +operator << (std::ostream &s, const tlm_phase &p) +{ + s << p.get_name(); + return s; +} + +#define TLM_DECLARE_EXTENDED_PHASE(name_arg) \ +static class SC_CONCAT_HELPER_(tlm_phase_, name_arg) : \ + public ::tlm::tlm_phase \ +{ \ + typedef SC_CONCAT_HELPER_(tlm_phase_, name_arg) this_type; \ + public: \ + SC_CONCAT_HELPER_(tlm_phase_, name_arg)() : \ + /* register extended phase */ \ + ::tlm::tlm_phase(typeid(*this), SC_STRINGIFY_HELPER_(name_arg)) \ + {} \ + \ + static const this_type &get_phase() \ + /* needed only for IEEE 1666-2011 */ \ + { \ + static this_type this_; \ + return this_; \ + } \ +} const name_arg + +// for backwards-compatibility +#define DECLARE_EXTENDED_PHASE(NameArg) TLM_DECLARE_EXTENDED_PHASE(NameArg) + +} // namespace tlm + +#undef SC_CONCAT_HELPER_ +#undef SC_CONCAT_HELPER_DEFERRED_ +#undef SC_CONCAT_HELPER_MORE_DEFERRED_ + +#undef SC_STRINGIFY_HELPER_ +#undef SC_STRINGIFY_HELPER_DEFERRED_ +#undef SC_STRINGIFY_HELPER_MORE_DEFERRED_ + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_PHASE_H__ */ diff --git a/src/systemc/ext/tlm_core/2/interfaces/dmi.h b/src/systemc/ext/tlm_core/2/interfaces/dmi.h new file mode 100644 index 000000000..1e019e0b6 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/interfaces/dmi.h @@ -0,0 +1,124 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_DMI_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_DMI_H__ + +#include + +namespace tlm +{ + +class tlm_dmi +{ + public: + // Enum for indicating the access granted to the initiator. + // The initiator uses gp.m_command to indicate it intention (read/write) + // The target is allowed to promote DMI_ACCESS_READ or DMI_ACCESS_WRITE + // requests to dmi_access_read_write. + + enum dmi_access_e { + DMI_ACCESS_NONE = 0x00, // no access + DMI_ACCESS_READ = 0x01, // read access + DMI_ACCESS_WRITE = 0x02, // write access + DMI_ACCESS_READ_WRITE = DMI_ACCESS_READ | DMI_ACCESS_WRITE + // read/write access + }; + + tlm_dmi() { init(); } + + void + init() + { + m_dmi_ptr = nullptr; + m_dmi_start_address = 0x0; + m_dmi_end_address = (sc_dt::uint64)(-1); + m_dmi_access = DMI_ACCESS_NONE; + m_dmi_read_latency = sc_core::SC_ZERO_TIME; + m_dmi_write_latency = sc_core::SC_ZERO_TIME; + } + + unsigned char *get_dmi_ptr() const { return m_dmi_ptr; } + sc_dt::uint64 get_start_address() const { return m_dmi_start_address; } + sc_dt::uint64 get_end_address() const { return m_dmi_end_address; } + sc_core::sc_time get_read_latency() const { return m_dmi_read_latency; } + sc_core::sc_time get_write_latency() const { return m_dmi_write_latency; } + dmi_access_e get_granted_access() const { return m_dmi_access; } + bool is_none_allowed() const { return m_dmi_access == DMI_ACCESS_NONE; } + bool + is_read_allowed() const + { + return (m_dmi_access & DMI_ACCESS_READ) == DMI_ACCESS_READ; + } + bool + is_write_allowed() const + { + return (m_dmi_access & DMI_ACCESS_WRITE) == DMI_ACCESS_WRITE; + } + bool + is_read_write_allowed() const + { + return (m_dmi_access & DMI_ACCESS_READ_WRITE) == DMI_ACCESS_READ_WRITE; + } + + void set_dmi_ptr(unsigned char *p) { m_dmi_ptr = p; } + void set_start_address(sc_dt::uint64 addr) { m_dmi_start_address = addr; } + void set_end_address(sc_dt::uint64 addr) { m_dmi_end_address = addr; } + void set_read_latency(sc_core::sc_time t) { m_dmi_read_latency = t; } + void set_write_latency(sc_core::sc_time t) { m_dmi_write_latency = t; } + void set_granted_access(dmi_access_e a) { m_dmi_access = a; } + void allow_none() { m_dmi_access = DMI_ACCESS_NONE; } + void allow_read() { m_dmi_access = DMI_ACCESS_READ; } + void allow_write() { m_dmi_access = DMI_ACCESS_WRITE; } + void allow_read_write() { m_dmi_access = DMI_ACCESS_READ_WRITE; } + + private: + // If the forward call is successful, the target returns the dmi_ptr, + // which must point to the data element corresponding to the + // dmi_start_address. The data is organized as a byte array with the + // endianness of the target (endianness member of the tlm_dmi struct). + + unsigned char *m_dmi_ptr; + + // The absolute start and end addresses of the DMI region. If the decoder + // logic in the interconnect changes the address field e.g. by masking, the + // interconnect is responsible to transform the relative address back to an + // absolute address again. + + sc_dt::uint64 m_dmi_start_address; + sc_dt::uint64 m_dmi_end_address; + + // Granted access + + dmi_access_e m_dmi_access; + + // These members define the latency of read/write transactions. The + // initiator must initialize these members to zero before requesting a + // dmi pointer, because both the interconnect as well as the target can + // add to the total transaction latency. + // Depending on the 'type' attribute only one, or both of these attributes + // will be valid. + + sc_core::sc_time m_dmi_read_latency; + sc_core::sc_time m_dmi_write_latency; +}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_DMI_H__ */ diff --git a/src/systemc/ext/tlm_core/2/interfaces/fw_bw_ifs.h b/src/systemc/ext/tlm_core/2/interfaces/fw_bw_ifs.h new file mode 100644 index 000000000..032ca3982 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/interfaces/fw_bw_ifs.h @@ -0,0 +1,222 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_FW_BW_IFS_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_FW_BW_IFS_H__ + +#include + +#include "tlm_core/2/generic_payload/generic_payload.h" +#include "tlm_core/2/interfaces/dmi.h" + +namespace tlm +{ + +enum tlm_sync_enum { TLM_ACCEPTED, TLM_UPDATED, TLM_COMPLETED }; + +//////////////////////////////////////////////////////////////////////////// +// Basic interfaces +//////////////////////////////////////////////////////////////////////////// +template +class tlm_fw_nonblocking_transport_if : public virtual sc_core::sc_interface +{ + public: + virtual tlm_sync_enum nb_transport_fw(TRANS &trans, PHASE &phase, + sc_core::sc_time& t) = 0; +}; + +template +class tlm_bw_nonblocking_transport_if : public virtual sc_core::sc_interface +{ + public: + virtual tlm_sync_enum nb_transport_bw(TRANS &trans, PHASE &phase, + sc_core::sc_time &t) = 0; +}; + +template +class tlm_blocking_transport_if : public virtual sc_core::sc_interface +{ + public: + virtual void b_transport(TRANS &trans, sc_core::sc_time &t) = 0; +}; + +////////////////////////////////////////////////////////////////////////// +// DMI interfaces for getting and invalidating DMI pointers: +////////////////////////////////////////////////////////////////////////// + +// The semantics of the forward interface are as follows: +// +// - An initiator that wants to get direct access to a target's memory region +// can call the get_direct_mem_ptr method with the 'trans' parameter set to +// the address that it wants to gain access to. It sets the trans.m_command +// to specify if the initiator intended use (read or write) +// to the target's DMI region. The initiator is responsible for calling the +// method with a freshly initialized tlm_dmi object either by using a newly +// constructed object, or by calling an existing object's init() method. +// - Although a reference to a complete 'TRANS' type is passed to the get_ +// direct_mem_ptr call, only the address command, and extension fields are of +// interest in most cases. +// - Read and write ranges are not necessarily identical. If they are, a target +// can specify that the range is valid for all accesses with the tlm_data +// m_type attribute in the. +// - The interconnect, if any, needs to decode the address and forward the +// call to the corresponding target. It needs to handle the address exactly +// as the target would expect on a transaction call, e.g. mask the address +// according to the target's address width. +// - If the target supports DMI access for the given address, it sets the +// data fields in the DMI struct and returns true. +// - If a target does not support DMI access it needs to return false. +// The target can either set the correct address range in the DMI struct +// to indicate the memory region where DMI is disallowed, or it can specify +// the complete address range if it doesn't know it's memory range. In this +// case the interconnect is responsible for clipping the address range to +// the correct range that the target serves. +// - The interconnect must always translate the addresses to the initiator's +// address space. This must be the inverse operation of what the +// interconnect needed to do when forwarding the call. In case the +// component wants to change any member of the tlm_dmi object, e.g. for +// its own latency to the target's latency, it must only do so *after* the +// target has been called. The target is always allowed to overwrite all +// values in the tlm_dmi object. +// - In case the slave returned with an invalid region the bus/interconnect +// must fill in the complete address region for the particular slave in the +// DMI data structure. +// +// DMI hint optimization: +// +// Initiators may use the DMI hint in the tlm_generic_payload to avoid +// unnecessary DMI attempts. The recommended sequence of interface +// method calls would be: +// +// - The initiator first tries to check if it has a valid DMI region for the +// address that it wants to access next. +// - If not, it performs a normal transaction. +// - If the DMI hint in this transaction is true, the initiator can try and +// get the DMI region. +// +// Note that the DMI hint optimization is completely optional and every +// initiator model is free to ignore the DMI hint. However, a target is +// required to set the DMI hint to true if a DMI request on the given address +// with the given transaction type (read or write) would have succeeded. + +template +class tlm_fw_direct_mem_if : public virtual sc_core::sc_interface +{ + public: + virtual bool get_direct_mem_ptr(TRANS &trans, tlm_dmi &dmi_data) = 0; +}; + +// The semantics of the backwards call is as follows: +// +// - An interconnect component or a target is required to invalidate all +// affected DMI regions whenever any change in the regions take place. +// The exact rule is that a component must invalidate all those DMI regions +// that it already reported, if it would answer the same DMI request +// with any member of the tlm_dmi data structure set differently. +// - An interconnect component must forward the invalidate_direct_mem_ptr call +// to all initiators that could potentially have a DMI pointer to the region +// specified in the method arguments. A safe implementation is to call +// every attached initiator. +// - An interconnect component must transform the address region of an +// incoming invalidate_direct_mem_ptr to the corresponding address space +// for the initiators. Basically, this is the same address transformation +// that the interconnect does on the DMI ranges on the forward direction. +// - Each initiator must check if it has a pointer to the given region and +// throw this away. It is recommended that the initiator throws away all DMI +// regions that have any overlap with the given regions, but this is not a +// hard requirement. +// +// - A full DMI pointer invalidation, e.g. for a bus remap can be signaled +// by setting the range: 0x0 - 0xffffffffffffffffull = (sc_dt::uint64)-1 +// - An initiator must throw away all DMI pointers in this case. +// +// - Under no circumstances a model is allowed to call the get_direct_mem_ptr +// from within the invalidate_direct_mem_ptr method, directly or indirectly. +// +class tlm_bw_direct_mem_if : public virtual sc_core::sc_interface +{ + public: + virtual void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, + sc_dt::uint64 end_range) = 0; +}; + +///////////////////////////////////////////////////////////////////// +// debug interface for memory access +///////////////////////////////////////////////////////////////////// +// +// This interface can be used to gain access to a targets memory or registers +// in a non-intrusive manner. No side effects, waits or event notifications +// must happen in the course of the method. +// +// Semantics: +// - The initiator calls the transport_dbg method with transaction 'trans' as +// argument. The commonly used parts of trans for debug are: +// . address: The start address that it wants to peek or poke. +// . length: The number of bytes that it requests to read or write. +// . command: Indicates a read or write access. +// . data: A pointer to the initiator-allocated data buffer, which must +// be at least num_bytes large. The data is always organized in +// the endianness of the machine. +// . extensions: Any extension that could affect the transaction. +// - The interconnect, if any, will decode the address and forward the call to +// the appropriate target. +// - The target must return the number of successfully transmitted bytes, where +// this number must be <= num_bytes. Thus, a target can safely return 0 if it +// does not support debug transactions. +// +template +class tlm_transport_dbg_if : public virtual sc_core::sc_interface +{ + public: + // The return value of defines the number of bytes successfully + // transferred. + virtual unsigned int transport_dbg(TRANS &trans) = 0; +}; + +//////////////////////////////////////////////////////////////////////////// +// Combined interfaces +//////////////////////////////////////////////////////////////////////////// + +struct tlm_base_protocol_types +{ + typedef tlm_generic_payload tlm_payload_type; + typedef tlm_phase tlm_phase_type; +}; + +// The forward interface: +template +class tlm_fw_transport_if : + public virtual tlm_fw_nonblocking_transport_if< + typename TYPES::tlm_payload_type, typename TYPES::tlm_phase_type>, + public virtual tlm_blocking_transport_if, + public virtual tlm_fw_direct_mem_if, + public virtual tlm_transport_dbg_if +{}; + +// The backward interface: +template +class tlm_bw_transport_if : + public virtual tlm_bw_nonblocking_transport_if< + typename TYPES::tlm_payload_type, typename TYPES::tlm_phase_type>, + public virtual tlm_bw_direct_mem_if +{}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_FW_BW_IFS_H__ */ diff --git a/src/systemc/ext/tlm_core/2/interfaces/interfaces.h b/src/systemc/ext/tlm_core/2/interfaces/interfaces.h new file mode 100644 index 000000000..bab1536ad --- /dev/null +++ b/src/systemc/ext/tlm_core/2/interfaces/interfaces.h @@ -0,0 +1,26 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_INTERFACES_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_INTERFACES_H__ + +#include "tlm_core/2/interfaces/dmi.h" +#include "tlm_core/2/interfaces/fw_bw_ifs.h" + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_INTERFACES_H__ */ diff --git a/src/systemc/ext/tlm_core/2/quantum/global_quantum.h b/src/systemc/ext/tlm_core/2/quantum/global_quantum.h new file mode 100644 index 000000000..54fcd5c2c --- /dev/null +++ b/src/systemc/ext/tlm_core/2/quantum/global_quantum.h @@ -0,0 +1,76 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_QUANTUM_GLOBAL_QUANTUM_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_QUANTUM_GLOBAL_QUANTUM_H__ + +#include + +namespace tlm +{ + +// +// tlm_global_quantum class +// +// The global quantum is the maximum time an initiator can run ahead of +// SystemC time. All initiators should synchronize on timingpoints that +// are multiples of the global quantum value. +// +// sc_set_time_resolution can only be called before the first +// sc_time object is created. This means that after setting the +// global quantum it will not be possible to call sc_set_time_resolution. +// If sc_set_time_resolution must be called this must be done before +// the global quantum is set. +// + +class tlm_global_quantum +{ + public: + // + // Returns a reference to the tlm_global_quantum singleton + // + static tlm_global_quantum &instance(); + + public: + + // + // Setter/getter for the global quantum + // + void set(const sc_core::sc_time &t) { m_global_quantum = t; } + const sc_core::sc_time &get() const { return m_global_quantum; } + + // + // This function will calculate the maximum value for the next local + // quantum for an initiator. All initiators should synchronize on + // integer multiples of the global quantum value. The value for the + // local quantum of an initiator can be smaller, but should never be + // greater than the value returned by this method. + // + sc_core::sc_time compute_local_quantum(); + + protected: + tlm_global_quantum(); + + protected: + sc_core::sc_time m_global_quantum; +}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_QUANTUM_GLOBAL_QUANTUM_H__ */ diff --git a/src/systemc/ext/tlm_core/2/quantum/quantum.h b/src/systemc/ext/tlm_core/2/quantum/quantum.h new file mode 100644 index 000000000..6639d42fb --- /dev/null +++ b/src/systemc/ext/tlm_core/2/quantum/quantum.h @@ -0,0 +1,25 @@ +/***************************************************************************** + + 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 ____SYSTEMC_EXT_TLM_CORE_2_QUANTUM_QUANTUM_H__ +#define ____SYSTEMC_EXT_TLM_CORE_2_QUANTUM_QUANTUM_H__ + +#include "tlm_core/2/quantum/global_quantum.h" + +#endif /* ____SYSTEMC_EXT_TLM_CORE_2_QUANTUM_QUANTUM_H__ */ diff --git a/src/systemc/ext/tlm_core/2/sockets/base_socket_if.h b/src/systemc/ext/tlm_core/2/sockets/base_socket_if.h new file mode 100644 index 000000000..29f3397b9 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/sockets/base_socket_if.h @@ -0,0 +1,57 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_BASE_SOCKET_IF_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_BASE_SOCKET_IF_H__ + +#include + +namespace tlm +{ + +enum tlm_socket_category +{ + TLM_UNKNOWN_SOCKET = 0, + TLM_INITIATOR_SOCKET = 0x1, + TLM_TARGET_SOCKET = 0x2, + + TLM_MULTI_SOCKET = 0x10, + + TLM_MULTI_INITIATOR_SOCKET = TLM_INITIATOR_SOCKET | TLM_MULTI_SOCKET, + TLM_MULTI_TARGET_SOCKET = TLM_TARGET_SOCKET | TLM_MULTI_SOCKET +}; + +class tlm_base_socket_if +{ + public: + virtual sc_core::sc_port_base &get_port_base() = 0; + virtual sc_core::sc_port_base const &get_port_base() const = 0; + virtual sc_core::sc_export_base &get_export_base() = 0; + virtual sc_core::sc_export_base const &get_export_base() const = 0; + virtual unsigned int get_bus_width() const = 0; + virtual sc_core::sc_type_index get_protocol_types() const = 0; + virtual tlm_socket_category get_socket_category() const = 0; + + protected: + virtual ~tlm_base_socket_if() {} +}; + +} // namespace tlm + +#endif // __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_BASE_SOCKET_IF_H__ diff --git a/src/systemc/ext/tlm_core/2/sockets/initiator_socket.h b/src/systemc/ext/tlm_core/2/sockets/initiator_socket.h new file mode 100644 index 000000000..686f930c4 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/sockets/initiator_socket.h @@ -0,0 +1,204 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_INITIATOR_SOCKET_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_INITIATOR_SOCKET_H__ + +#include "tlm_core/2/interfaces/fw_bw_ifs.h" +#include "tlm_core/2/sockets/base_socket_if.h" + +namespace tlm +{ + +template , + typename BW_IF=tlm_bw_transport_if<>> +class tlm_base_initiator_socket_b +{ + public: + virtual ~tlm_base_initiator_socket_b() {} + + virtual sc_core::sc_port_b &get_base_port() = 0; + virtual sc_core::sc_port_b const &get_base_port() const = 0; + virtual BW_IF &get_base_interface() = 0; + virtual BW_IF const &get_base_interface() const = 0; + virtual sc_core::sc_export &get_base_export() = 0; + virtual sc_core::sc_export const &get_base_export() const = 0; +}; + +template +class tlm_base_target_socket_b; + +template +class tlm_base_target_socket; + +template , + typename BW_IF=tlm_bw_transport_if<>, int N=1, + sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> +class tlm_base_initiator_socket : + public tlm_base_socket_if, + public tlm_base_initiator_socket_b, + public sc_core::sc_port +{ + public: + typedef FW_IF fw_interface_type; + typedef BW_IF bw_interface_type; + typedef sc_core::sc_port port_type; + + typedef sc_core::sc_export export_type; + + typedef tlm_base_target_socket_b< + BUSWIDTH, fw_interface_type, bw_interface_type> + base_target_socket_type; + typedef tlm_base_initiator_socket_b< + BUSWIDTH, fw_interface_type, bw_interface_type> base_type; + + template + friend class tlm_base_target_socket; + + public: + tlm_base_initiator_socket() : + port_type(sc_core::sc_gen_unique_name("tlm_base_initiator_socket")), + m_export(sc_core::sc_gen_unique_name( + "tlm_base_initiator_socket_export")) + {} + + explicit tlm_base_initiator_socket(const char *name) : port_type(name), + m_export(sc_core::sc_gen_unique_name( + (std::string(name) + "_export").c_str())) + {} + + virtual const char* kind() const { return "tlm_base_initiator_socket"; } + + // + // Bind initiator socket to target socket + // - Binds the port of the initiator socket to the export of the target + // socket + // - Binds the port of the target socket to the export of the initiator + // socket + // + virtual void + bind(base_target_socket_type &s) + { + // initiator.port -> target.export + (get_base_port())(s.get_base_interface()); + // target.port -> initiator.export + (s.get_base_port())(get_base_interface()); + } + + void operator () (base_target_socket_type &s) { bind(s); } + + // + // Bind initiator socket to initiator socket (hierarchical bind) + // - Binds both the export and the port + // + virtual void + bind(base_type &s) + { + // port + (get_base_port())(s.get_base_port()); + // export + (s.get_base_export())(get_base_export()); + } + + void operator() (base_type &s) { bind(s); } + + // + // Bind interface to socket + // - Binds the interface to the export of this socket + // + virtual void bind(bw_interface_type &ifs) { (get_base_export())(ifs); } + void operator() (bw_interface_type &s) { bind(s); } + + // Implementation of tlm_base_socket_if functions + virtual sc_core::sc_port_base &get_port_base() { return *this; } + virtual sc_core::sc_port_base const & + get_port_base() const + { + return *this; + } + virtual sc_core::sc_export_base &get_export_base() { return m_export; } + virtual sc_core::sc_export_base const & + get_export_base() const + { + return m_export; + } + virtual unsigned int get_bus_width() const { return BUSWIDTH; } + virtual tlm_socket_category + get_socket_category() const + { + return TLM_INITIATOR_SOCKET; + } + + // Implementation of tlm_base_target_socket_b functions + virtual sc_core::sc_port_b &get_base_port() { return *this; } + virtual sc_core::sc_port_b const & + get_base_port() const + { + return *this; + } + + virtual BW_IF &get_base_interface() { return m_export; } + virtual BW_IF const &get_base_interface() const { return m_export; } + + virtual sc_core::sc_export &get_base_export() { return m_export; } + virtual sc_core::sc_export const & + get_base_export() const + { + return m_export; + } + + protected: + export_type m_export; +}; + +// +// Convenience socket classes +// + +template +class tlm_initiator_socket : public tlm_base_initiator_socket< + BUSWIDTH, tlm_fw_transport_if, + tlm_bw_transport_if, N, POL> +{ + public: + tlm_initiator_socket() : tlm_base_initiator_socket< + BUSWIDTH, tlm_fw_transport_if, + tlm_bw_transport_if, N, POL>() + {} + + explicit tlm_initiator_socket(const char *name) : + tlm_base_initiator_socket, + tlm_bw_transport_if, N, POL>(name) + {} + + virtual const char *kind() const { return "tlm_initiator_socket"; } + + virtual sc_core::sc_type_index + get_protocol_types() const + { + return typeid(TYPES); + } +}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_INITIATOR_SOCKET_H__ */ diff --git a/src/systemc/ext/tlm_core/2/sockets/sockets.h b/src/systemc/ext/tlm_core/2/sockets/sockets.h new file mode 100644 index 000000000..53d1819a7 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/sockets/sockets.h @@ -0,0 +1,26 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_SOCKETS_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_SOCKETS_H__ + +#include "tlm_core/2/sockets/initiator_socket.h" +#include "tlm_core/2/sockets/target_socket.h" + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_SOCKETS_H__ */ diff --git a/src/systemc/ext/tlm_core/2/sockets/target_socket.h b/src/systemc/ext/tlm_core/2/sockets/target_socket.h new file mode 100644 index 000000000..7493c97dc --- /dev/null +++ b/src/systemc/ext/tlm_core/2/sockets/target_socket.h @@ -0,0 +1,223 @@ +/***************************************************************************** + + 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 __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_H__ + +#include "tlm_core/2/interfaces/fw_bw_ifs.h" +#include "tlm_core/2/sockets/base_socket_if.h" + +namespace tlm +{ + +template , + typename BW_IF=tlm_bw_transport_if<>> +class tlm_base_target_socket_b +{ + public: + virtual ~tlm_base_target_socket_b() {} + + virtual sc_core::sc_port_b &get_base_port() = 0; + virtual sc_core::sc_export &get_base_export() = 0; + virtual FW_IF &get_base_interface() = 0; +}; + +template +class tlm_base_initiator_socket_b; + +template +class tlm_base_initiator_socket; + +template , + typename BW_IF=tlm_bw_transport_if<>, int N=1, + sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> +class tlm_base_target_socket : + public tlm_base_socket_if, + public tlm_base_target_socket_b, + public sc_core::sc_export +{ + public: + typedef FW_IF fw_interface_type; + typedef BW_IF bw_interface_type; + typedef sc_core::sc_port port_type; + + typedef sc_core::sc_export export_type; + typedef tlm_base_initiator_socket_b< + BUSWIDTH, fw_interface_type, bw_interface_type> + base_initiator_socket_type; + + typedef tlm_base_target_socket_b< + BUSWIDTH, fw_interface_type, bw_interface_type> base_type; + + template + friend class tlm_base_initiator_socket; + + public: + tlm_base_target_socket() : + export_type(sc_core::sc_gen_unique_name("tlm_base_target_socket")), + m_port(sc_core::sc_gen_unique_name("tlm_base_target_socket_port")) + {} + + explicit tlm_base_target_socket(const char *name) : + export_type(name), m_port(sc_core::sc_gen_unique_name( + (std::string(name) + "_port").c_str())) + {} + + virtual const char *kind() const { return "tlm_base_target_socket"; } + + // + // Bind target socket to initiator socket + // - Binds the port of the initiator socket to the export of the target + // socket + // - Binds the port of the target socket to the export of the initiator + // socket + // + virtual void + bind(base_initiator_socket_type &s) + { + // initiator.port -> target.export + (s.get_base_port())(get_base_interface()); + // target.port -> initiator.export + get_base_port()(s.get_base_interface()); + } + + void operator () (base_initiator_socket_type &s) { bind(s); } + + // + // Bind target socket to target socket (hierarchical bind) + // - Binds both the export and the port + // + virtual void + bind(base_type &s) + { + // export + (get_base_export())(s.get_base_export()); + // port + (s.get_base_port())(get_base_port()); + } + + void operator () (base_type &s) { bind(s); } + + // + // Bind interface to socket + // - Binds the interface to the export + // + virtual void + bind(fw_interface_type &ifs) + { + export_type *exp = &get_base_export(); + if (this == exp) { + export_type::bind(ifs); + } else { + exp->bind( ifs ); + } + } + + void operator () (fw_interface_type &s) { bind(s); } + + // + // Forward to 'size()' of port class. + // + int size() const { return m_port.size(); } + + // + // Forward to 'operator->()' of port class. + // + bw_interface_type *operator->() { return m_port.operator->(); } + + // + // Forward to 'operator[]()' of port class. + // + bw_interface_type *operator[](int i) { return m_port.operator[](i); } + + // Implementation of tlm_base_socket_if functions. + virtual sc_core::sc_port_base &get_port_base() { return m_port; } + virtual sc_core::sc_port_base const & + get_port_base() const + { + return m_port; + } + virtual sc_core::sc_export_base &get_export_base() { return *this; } + virtual sc_core::sc_export_base const & + get_export_base() const + { + return *this; + } + virtual unsigned int get_bus_width() const { return BUSWIDTH; } + virtual tlm_socket_category + get_socket_category() const + { + return TLM_TARGET_SOCKET; + } + + // Implementation of tlm_base_target_socket_b functions + virtual sc_core::sc_port_b &get_base_port() { return m_port; } + virtual sc_core::sc_port_b const & + get_base_port() const + { + return m_port; + } + + virtual FW_IF &get_base_interface() { return *this; } + virtual FW_IF const &get_base_interface() const { return *this; } + + virtual sc_core::sc_export &get_base_export() { return *this; } + virtual sc_core::sc_export const & + get_base_export() const + { + return *this; + } + + protected: + port_type m_port; +}; + +template +class tlm_target_socket : + public tlm_base_target_socket< + BUSWIDTH, tlm_fw_transport_if, + tlm_bw_transport_if, N, POL> +{ + public: + tlm_target_socket() : + tlm_base_target_socket< + BUSWIDTH, tlm_fw_transport_if, + tlm_bw_transport_if, N, POL>() + {} + + explicit tlm_target_socket(const char *name) : + tlm_base_target_socket< + BUSWIDTH, tlm_fw_transport_if, + tlm_bw_transport_if, N, POL>(name) + {} + + virtual const char* kind() const { return "tlm_target_socket"; } + + virtual sc_core::sc_type_index + get_protocol_types() const + { + return typeid(TYPES); + } +}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_H__ */ diff --git a/src/systemc/ext/tlm_core/2/version.h b/src/systemc/ext/tlm_core/2/version.h new file mode 100644 index 000000000..b7bca36ac --- /dev/null +++ b/src/systemc/ext/tlm_core/2/version.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. + + *****************************************************************************/ + +/* --------------------------------------------------------------------------- + Original Author: + Charles Wilson, XtremeEDA Corporation + + @description + This header contains preprocessor and compiler symbols to allow for the + determination of the TLM version information. This conforms to + IEEE 1666-2005 section 8.5.5 - 8.5.7 + The following are provided: + + preprocessor: TLM_VERSION_MAJOR numeric + TLM_VERSION_MINOR numeric + TLM_VERSION_PATCH numeric + TLM_VERSION_ORIGINATOR string ([A-Z][a-z][0-9]_) + TLM_VERSION_RELEASE_DATE ISO8601 date (YYYYMMDD) + TLM_VERSION_PRERELEASE string ([A-Z][a-z][0-9]_) + TLM_IS_PRERELEASE bool (1,0) + TLM_VERSION string {2.0.0_DR3-TLMWG} + TLM_COPYRIGHT string + + compiler: tlm_version_major const unsigned int + tlm_version_minor const unsigned int + tlm_version_patch const unsigned int + tlm_version_originator const std::string + tlm_version_release_date const std::string + tlm_version_prerelease const std::string + tlm_is_prerelease const bool + tlm_version const string + tlm_copyright const string + + accessors: inline const char* tlm_release (void) + inline const char* tlm_version (void) + inline const char* tlm_copyright (void) +--------------------------------------------------------------------------- */ + +#ifndef __SYSTEMC_EXT_TLM_CORE_2_VERSION_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_VERSION_H__ + +namespace tlm +{ + +#define TLM_VERSION_MAJOR 2 ///< version major level ( numeric ) +#define TLM_VERSION_MINOR 0 ///< version minor level ( numeric ) +#define TLM_VERSION_PATCH 4 ///< version patch level ( numeric ) +#define TLM_VERSION_ORIGINATOR "Accellera" ///< TLM creator string +#define TLM_VERSION_SEPARATOR "." ///< version string separator + +#define TLM_IS_PRERELEASE 0 ///< pre-release flag (1/0) + +#if TLM_IS_PRERELEASE +# define TLM_VERSION_PRERELEASE "pub_rev" ///< pre-release version string +#else +# define TLM_VERSION_PRERELEASE "" ///< pre-release version string +#endif + +#define TLM_VERSION_RELEASE_YEAR "2017" ///< release year ( YYYY ) +#define TLM_VERSION_RELEASE_MONTH "10" ///< release month ( MM ) +#define TLM_VERSION_RELEASE_DAY "12" ///< release day ( DD ) + +#define TLM_COPYRIGHT \ + "Copyright (c) 1996-" TLM_VERSION_RELEASE_YEAR " by all Contributors\n" \ + "ALL RIGHTS RESERVED" + +/******************** do not modify below this line *************************/ + +/************************* preprocessor symbols *****************************/ + +#define TLM_VERSION_RELEASE_DATE TLM_VERSION_RELEASE_YEAR \ + TLM_VERSION_RELEASE_MONTH \ + TLM_VERSION_RELEASE_DAY + +#define TLM_VERSION_STR(x) TLM_VERSION_STR_HELPER(x) +#define TLM_VERSION_STR_HELPER(x) #x + +#define TLM_VERSION_STRING_MAJOR TLM_VERSION_STR(TLM_VERSION_MAJOR) +#define TLM_VERSION_STRING_MINOR TLM_VERSION_STR(TLM_VERSION_MINOR) +#define TLM_VERSION_STRING_PATCH TLM_VERSION_STR(TLM_VERSION_PATCH) + +#define TLM_VERSION_STRING_MMP TLM_VERSION_STRING_MAJOR TLM_VERSION_SEPARATOR \ + TLM_VERSION_STRING_MINOR TLM_VERSION_SEPARATOR \ + TLM_VERSION_STRING_PATCH + +#define TLM_VERSION_STRING_PRE_START "_" +#define TLM_VERSION_STRING_PRE_END "-" + +#if (TLM_IS_PRERELEASE == 1) + +# define TLM_VERSION_STRING_PRERELEASE TLM_VERSION_PRERELEASE +# define TLM_VERSION_STRING_RELEASE_DATE "" + +#else /* TLM_IS_PRERELEASE == 1 */ + +# define TLM_VERSION_STRING_PRERELEASE "" +# define TLM_VERSION_STRING_RELEASE_DATE TLM_VERSION_RELEASE_DATE + +#endif /* TLM_IS_PRERELEASE == 1 */ + +#define TLM_VERSION_STRING TLM_VERSION_STRING_MMP \ + TLM_VERSION_STRING_PRE_START \ + TLM_VERSION_STRING_PRERELEASE \ + TLM_VERSION_STRING_PRE_END \ + TLM_VERSION_ORIGINATOR + +#define TLM_VERSION_STRING_2 "TLM " \ + TLM_VERSION_STRING_MMP \ + " --- " \ + TLM_VERSION_RELEASE_YEAR \ + "-" \ + TLM_VERSION_RELEASE_MONTH \ + "-" \ + TLM_VERSION_RELEASE_DAY + +#define TLM_VERSION TLM_VERSION_STRING + +/*************************** compiler symbols ********************************/ + +const unsigned int tlm_version_major(TLM_VERSION_MAJOR); +const unsigned int tlm_version_minor(TLM_VERSION_MINOR); +const unsigned int tlm_version_patch(TLM_VERSION_PATCH); + +const bool tlm_is_prerelease(TLM_IS_PRERELEASE); + +const std::string tlm_version_string(TLM_VERSION_STRING); +const std::string tlm_version_originator(TLM_VERSION_ORIGINATOR); +const std::string tlm_version_prerelease(TLM_VERSION_PRERELEASE); +const std::string tlm_version_release_date(TLM_VERSION_STRING_RELEASE_DATE); +const std::string tlm_copyright_string(TLM_COPYRIGHT); +const std::string tlm_version_string_2(TLM_VERSION_STRING_2); + +inline const char *tlm_release() { return tlm_version_string.c_str(); } +inline const char *tlm_version() { return tlm_version_string_2.c_str(); } +inline const char *tlm_copyright() { return tlm_copyright_string.c_str(); } + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_VERSION_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/README.txt b/src/systemc/ext/tlm_core/tlm_1/README.txt deleted file mode 100644 index c7e1c5e1f..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/README.txt +++ /dev/null @@ -1,97 +0,0 @@ -TLM-1.0 header files -==================== - -Dir: include/tlm_core/tlm_1/ - -SubDirs: tlm_analysis/ - tlm_req_rsp/ - -Files: README.txt - - -Comments -======== - -User code should only #include the tlm or tlm.h header file in the include/ -directory and avoid including any of the include files in this directory -directly. All objects defined in this file hierarchy are in the tlm namespace. - -The header files are organizated, by subdirectory, as follows: - - -tlm_analysis/ --------------- - -This contains the analysis interfaces, ports, and fifos. These files were not -part of the original TLM-1.0 release, but have been grouped with TLM-1.0 in this -release of TLM-2.0 - -Files: - tlm_analysis.h (includes the other header files in this directory ) - tlm_analysis_fifo.h (defines tlm_analysis_fifo ) - tlm_analysis_if.h (defines tlm_analysis_if and tlm_delayed_analysis_if ) - tlm_analysis_port.h (defines tlm_analysis_port ) - tlm_analysis_triple.h (defines tlm_analysis_triple ) - tlm_write_if.h (defines tlm_write_if and tlm_delayed_write_if ) - - -tlm_req_rsp/ ------------- - -This provides support for TLM modeling based on a request/response pair that -are passed by value. This is the original TLM 1.0 standard, with the addition -of an overloading of the blocking transport method with pass-by-reference arguments. - -Files: - tlm_req_rsp.h (includes the key header files from the other directories) - - tlm_1_interfaces/ - tlm_core_ifs.h (defines the TLM 1.0 core interfaces: - tlm_transport_if - tlm_blocking_get_if - tlm_blocking_put_if - tlm_nonblocking_get_if - tlm_nonblocking_put_if - tlm_get_if - tlm_put_if - tlm_blocking_peek_if - tlm_nonblocking_peek_if - tlm_peek_if - tlm_blocking_get_peek_if - tlm_nonblocking_get_peek_if - tlm_get_peek_if ) - tlm_fifo_ifs.h ( defines the TLM1.0 fifo interfaces: - tlm_fifo_debug_if - tlm_fifo_put_if - tlm_fifo_get_if - tlm_fifo_config_size_if ) - tlm_master_slave_ifs.h ( defines the TLM1.0 master slave interfaces: - tlm_blocking_master_if - tlm_blocking_slave_if - tlm_nonblocking_master_if - tlm_nonblocking_slave_if - tlm_master_if - tlm_slave_if ) - tlm_tag.h ( defines tlm_tag ) - - tlm_ports/ - tlm_nonblocking_port.h (defines tlm_nonblocking_put_port, - tlm_nonblocking_get_port and - tlm_nonblocking_peek_port ) - tlm_event_finder.h (defines tlm_event_finder_t ) - - tlm_channels/ - tlm_fifo/ - tlm_fifo.h (defines tlm_fifo, includes the other files ) - tlm_fifo_peek.h (defines peek and poke interfaces for tlm_fifo ) - tlm_fifo_put_get.h (defines put and get interfaces for tlm_fifo ) - tlm_fifo_resize.h (defines expand, reduce, bound and unbound - interfaces for tlm_fifo ) - circular_buffer.h (defines circular buffer used by tlm_fifo ) - tlm_req_rsp_channels/ - tlm_req_rsp_channels.h (defines tlm_req_rsp_channel and - tlm_transport_channel ) - tlm_put_get_imp.h (contains implementatins used by the channels) - - tlm_adapters/ - tlm_adapters.h (defines transport_to_master and tlm_slave_to_transport) diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis.h b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis.h deleted file mode 100644 index 661399c60..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis.h +++ /dev/null @@ -1,29 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_H__ - -#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_fifo.h" -#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h" -#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_port.h" -#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_triple.h" -#include "tlm_core/tlm_1/tlm_analysis/tlm_write_if.h" - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_fifo.h b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_fifo.h deleted file mode 100644 index 84807031f..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_fifo.h +++ /dev/null @@ -1,46 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_FIFO_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_FIFO_H__ - -#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h" -#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_triple.h" -#include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h" - -namespace tlm -{ - -template -class tlm_analysis_fifo : public tlm_fifo, - public virtual tlm_analysis_if, - public virtual tlm_analysis_if> -{ - public: - // analysis fifo is an unbounded tlm_fifo - tlm_analysis_fifo(const char *nm) : tlm_fifo(nm, -16) {} - tlm_analysis_fifo() : tlm_fifo(-16) {} - - void write(const tlm_analysis_triple &t) { nb_put(t); } - void write(const T &t) { nb_put(t); } -}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_FIFO_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h deleted file mode 100644 index d1b91effc..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h +++ /dev/null @@ -1,38 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_IF_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_IF_H__ - -#include "tlm_core/tlm_1/tlm_analysis/tlm_write_if.h" - -namespace tlm -{ - -template -class tlm_analysis_if : public virtual tlm_write_if -{}; - -template -class tlm_delayed_analysis_if : public virtual tlm_delayed_write_if -{}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_IF_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_port.h b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_port.h deleted file mode 100644 index 5195417a8..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_port.h +++ /dev/null @@ -1,78 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_PORT_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_PORT_H__ - -#include -#include - -#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h" - -namespace tlm -{ - -template -class tlm_analysis_port : public sc_core::sc_object, - public virtual tlm_analysis_if -{ - public: - tlm_analysis_port() : sc_core::sc_object() {} - tlm_analysis_port(const char *nm) : sc_core::sc_object(nm) {} - - // bind and () work for both interfaces and analysis ports, since - // analysis ports implement the analysis interface. - - virtual void - bind(tlm_analysis_if &_if) - { - m_interfaces.push_back(&_if); - } - - void operator() (tlm_analysis_if &_if) { bind(_if); } - virtual bool - unbind(tlm_analysis_if &_if) - { - typename std::deque *>::iterator i = - std::remove(m_interfaces.begin(), m_interfaces.end(), &_if); - - if (i != m_interfaces.end()) { - m_interfaces.erase(i, m_interfaces.end()); - return 1; - } - return 0; - } - - void - write(const T &t) - { - typename std::deque *>::iterator i; - - for (i = m_interfaces.begin(); i != m_interfaces.end(); i++) { - (*i)->write(t); - } - } - - private: - std::deque *> m_interfaces; -}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_PORT_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_triple.h b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_triple.h deleted file mode 100644 index 9727f23e5..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_triple.h +++ /dev/null @@ -1,53 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_TRIPLE_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_TRIPLE_H__ - -namespace tlm -{ - -template -struct tlm_analysis_triple -{ - sc_core::sc_time start_time; - T transaction; - sc_core::sc_time end_time; - - tlm_analysis_triple() {} - - tlm_analysis_triple(const tlm_analysis_triple &triple) - { - start_time = triple.start_time; - transaction = triple.transaction; - end_time = triple.end_time; - } - - tlm_analysis_triple(const T &t) - { - transaction = t; - } - - operator T() { return transaction; } - operator const T &() const { return transaction; } -}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_TRIPLE_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_write_if.h b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_write_if.h deleted file mode 100644 index 3d77f880d..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_write_if.h +++ /dev/null @@ -1,44 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_WRITE_IF_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_WRITE_IF_H__ - -#include - -namespace tlm -{ - -template -class tlm_write_if : public virtual sc_core::sc_interface -{ - public: - virtual void write(const T &t) = 0; -}; - -template -class tlm_delayed_write_if : public virtual sc_core::sc_interface -{ - public: - virtual void write(const T &t, const sc_core::sc_time &time) = 0; -}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_WRITE_IF_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h deleted file mode 100644 index 2cd919bd2..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h +++ /dev/null @@ -1,138 +0,0 @@ -/***************************************************************************** - - 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 \ - __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM1_INTERFACES_TLM_CORE_IFS_H__ -#define \ - __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM1_INTERFACES_TLM_CORE_IFS_H__ - -#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h" - -namespace tlm -{ - -// Bidirectional blocking interfaces. -template -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 -class tlm_blocking_get_if : public virtual sc_core::sc_interface -{ - public: - virtual T get(tlm_tag *t=nullptr) = 0; - virtual void get(T &t) { t = get(); } -}; - -template -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 -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=nullptr) const = 0; - virtual const sc_core::sc_event & - ok_to_get(tlm_tag *t=nullptr) const = 0; -}; - -template -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=nullptr) const = 0; - virtual const sc_core::sc_event & - ok_to_put(tlm_tag *t=nullptr) const = 0; -}; - -// Combined uni-directional blocking and non blocking. -template -class tlm_get_if : public virtual tlm_blocking_get_if, - public virtual tlm_nonblocking_get_if -{}; - -template -class tlm_put_if : public virtual tlm_blocking_put_if, - public virtual tlm_nonblocking_put_if -{}; - -// Peek interfaces. -template -class tlm_blocking_peek_if : public virtual sc_core::sc_interface -{ - public: - virtual T peek(tlm_tag *t=nullptr) const = 0; - virtual void peek(T &t) const { t = peek(); } -}; - -template -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=nullptr) const = 0; - virtual const sc_core::sc_event & - ok_to_peek(tlm_tag *t=nullptr) const = 0; -}; - -template -class tlm_peek_if : - public virtual tlm_blocking_peek_if, - public virtual tlm_nonblocking_peek_if -{}; - -// Get_peek interfaces. -template -class tlm_blocking_get_peek_if : public virtual tlm_blocking_get_if, - public virtual tlm_blocking_peek_if -{}; - -template -class tlm_nonblocking_get_peek_if : public virtual tlm_nonblocking_get_if, - public virtual tlm_nonblocking_peek_if -{}; - -template -class tlm_get_peek_if : public virtual tlm_get_if, - public virtual tlm_peek_if, public virtual tlm_blocking_get_peek_if, - public virtual tlm_nonblocking_get_peek_if -{}; - -} // namespace tlm - -#endif -/* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM1_INTERFACES_TLM_CORE_IFS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h deleted file mode 100644 index 57418ae92..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h +++ /dev/null @@ -1,82 +0,0 @@ -/***************************************************************************** - - 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 \ - __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_FIFO_IFS_H__ -#define \ - __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_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 -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 -class tlm_fifo_put_if : public virtual tlm_put_if, - public virtual tlm_fifo_debug_if -{}; - -template -class tlm_fifo_get_if : - public virtual tlm_get_peek_if, - public virtual tlm_fifo_debug_if -{}; - -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 -/* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_FIFO_IFS_H__*/ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h deleted file mode 100644 index 29a89de47..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h +++ /dev/null @@ -1,78 +0,0 @@ -/***************************************************************************** - - 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_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_MASTER_SLAVE_IFS_H__ -#define \ - __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_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 -class tlm_blocking_master_if : - public virtual tlm_blocking_put_if, - public virtual tlm_blocking_get_peek_if -{}; - -template -class tlm_blocking_slave_if : - public virtual tlm_blocking_put_if, - public virtual tlm_blocking_get_peek_if -{}; - -// Nonblocking. -template -class tlm_nonblocking_master_if : - public virtual tlm_nonblocking_put_if, - public virtual tlm_nonblocking_get_peek_if -{}; - -template -class tlm_nonblocking_slave_if : - public virtual tlm_nonblocking_put_if, - public virtual tlm_nonblocking_get_peek_if -{}; - -// Combined. -template -class tlm_master_if : public virtual tlm_put_if, - public virtual tlm_get_peek_if , - public virtual tlm_blocking_master_if, - public virtual tlm_nonblocking_master_if -{}; - -template -class tlm_slave_if : public virtual tlm_put_if, - public virtual tlm_get_peek_if, - public virtual tlm_blocking_slave_if, - public virtual tlm_nonblocking_slave_if -{}; - -} // namespace tlm - -#endif -/* __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_MASTER_SLAVE_IFS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h deleted file mode 100644 index b19c904fb..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_TAG_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_TAG_H__ - -namespace tlm -{ - -template -class tlm_tag -{}; - -} - -#endif -/* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_TAG_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h deleted file mode 100644 index c81df4b15..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h +++ /dev/null @@ -1,100 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_ADAPTERS_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_ADAPTERS_H__ - -#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h" - -namespace tlm -{ - -template -class tlm_transport_to_master : public sc_core::sc_module, - public virtual tlm_transport_if -{ - public: - sc_core::sc_export> target_export; - sc_core::sc_port> 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 -class tlm_slave_to_transport : public sc_core::sc_module -{ - public: - SC_HAS_PROCESS(tlm_slave_to_transport); - - sc_core::sc_port> slave_port; - sc_core::sc_port> 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 /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_ADAPTERS_H__*/ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h deleted file mode 100644 index c00fe4881..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h +++ /dev/null @@ -1,255 +0,0 @@ -/***************************************************************************** - - 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_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_CIRCULAR_BUFFER_H__ -#define \ - __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_CIRCULAR_BUFFER_H__ - -#include - -namespace tlm -{ - -template -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(); - - // Disabled. - circular_buffer(const circular_buffer &b); - circular_buffer &operator = (const circular_buffer &); - - 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 -void -circular_buffer::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 -circular_buffer::circular_buffer(int size) : m_size(size), m_buf(0) -{ - init(); -} - -template -void -circular_buffer::clear() -{ - for (int i = 0; i < used(); i++) { - buf_clear(m_buf, (m_ri + i) % m_size); - } - m_free = m_size; - m_used = m_ri = m_wi = 0; -} - -template -circular_buffer::~circular_buffer() -{ - clear(); - buf_free(m_buf); -} - -template -void -circular_buffer::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 -void -circular_buffer::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 -T -circular_buffer::read() -{ - T t = read_data(); - - buf_clear(m_buf, m_ri); - increment_read_pos(); - - return t; -} - -template -void -circular_buffer::write(const T &t) -{ - buf_write(m_buf, m_wi, t); - increment_write_pos(); -} - -template -void -circular_buffer::increment_write_pos(int i) -{ - m_wi = (m_wi + i) % m_size; - m_used += i; - m_free -= i; -} - -template -void -circular_buffer::increment_read_pos(int i) -{ - m_ri = (m_ri + i) % m_size; - m_used -= i; - m_free += i; -} - -template -inline void * -circular_buffer::buf_alloc(int size) -{ - return new unsigned char [size * sizeof(T)]; -} - -template -inline void -circular_buffer::buf_free(void *&buf) -{ - delete [] static_cast(buf); - buf = nullptr; -} - -template -inline void -circular_buffer::buf_write(void *buf, int n, const T &t) -{ - T *p = static_cast(buf) + n; - new (p)T(t); -} - -template -inline T & -circular_buffer::buf_read(void *buf, int n) const -{ - T *p = static_cast(buf) + n; - return *p; -} - -template -inline void -circular_buffer::buf_clear(void *buf, int n) -{ - T *p = static_cast(buf) + n; - p->~T(); -} - -} // namespace tlm - -#endif -/* __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_CIRCULAR_BUFFER_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h deleted file mode 100644 index 25a183459..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h +++ /dev/null @@ -1,233 +0,0 @@ -/***************************************************************************** - - 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 \ - __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_H__ -#define \ - __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_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 "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 -class tlm_fifo : public virtual tlm_fifo_get_if, - public virtual tlm_fifo_put_if, 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 * =nullptr); - - bool nb_get(T &); - bool nb_can_get(tlm_tag * =nullptr) const; - const sc_core::sc_event & - ok_to_get(tlm_tag * =nullptr) const - { - return m_data_written_event; - } - - // Tlm peek interface. - T peek(tlm_tag * =nullptr) const; - - bool nb_peek(T &) const; - bool nb_can_peek(tlm_tag * =nullptr) const; - const sc_core::sc_event & - ok_to_peek(tlm_tag * =nullptr) const - { - return m_data_written_event; - } - - // Tlm put interface. - void put(const T &); - - bool nb_put(const T &); - bool nb_can_put(tlm_tag * =nullptr) const; - const sc_core::sc_event & - ok_to_put(tlm_tag * =nullptr) 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 * =nullptr) - { - return m_data_read_event; - } - - void update(); - void init(int); - - circular_buffer 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 ? - // #samples read without notify during this delta cycle - int m_num_read_no_notify; - - sc_core::sc_event m_data_read_event; - sc_core::sc_event m_data_written_event; - - private: - // disabled - tlm_fifo(const tlm_fifo &); - tlm_fifo &operator = (const tlm_fifo &); - - // - // 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 - { - if (size() < 0) - return false; - else - return size() <= m_num_readable + m_num_written; - } -}; - -template -const char *const tlm_fifo::kind_string = "tlm_fifo"; - -/****************************************************************** -// -// init and update -// -******************************************************************/ - -template -inline void -tlm_fifo::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 -inline void -tlm_fifo::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 -/*__SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_H__*/ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h deleted file mode 100644 index 540f72de6..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h +++ /dev/null @@ -1,90 +0,0 @@ -/***************************************************************************** - - 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_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_PEEK_H__ -#define \ - __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_PEEK_H__ - -namespace tlm -{ - -template -inline T -tlm_fifo::peek(tlm_tag *) 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 -inline bool -tlm_fifo::nb_peek(T &t) const -{ - if (used() < 1) { - return false; - } - - t = buffer.peek_data(0); - return true; -} - -template -inline bool -tlm_fifo::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 -inline bool -tlm_fifo::nb_can_peek(tlm_tag *) const -{ - return !is_empty(); -} - -template -inline bool -tlm_fifo::nb_poke(const T &t, int n) -{ - if (n >= used() || n < 0) { - return false; - } - - buffer.poke_data(n) = t; - return true; -} - -} // namespace tlm - -#endif -/* __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_PEEK_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_put_get.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_put_get.h deleted file mode 100644 index a9a8ee3f4..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_put_get.h +++ /dev/null @@ -1,116 +0,0 @@ -/***************************************************************************** - - 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_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_PUT_GET_H__ -#define \ - __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_PUT_GET_H__ - -namespace tlm -{ - -// Get interface. -template -inline T -tlm_fifo::get(tlm_tag *) -{ - while (is_empty()) { - wait(m_data_written_event); - } - - m_num_read++; - request_update(); - - return buffer.read(); -} - -// Non-blocking read. -template -inline bool -tlm_fifo::nb_get(T &val_) -{ - if (is_empty()) { - return false; - } - - m_num_read++; - request_update(); - - val_ = buffer.read(); - - return true; -} - -template -inline bool -tlm_fifo::nb_can_get(tlm_tag *) const -{ - return !is_empty(); -} - - -// Put interface. -template -inline void -tlm_fifo::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 -inline bool -tlm_fifo::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 -inline bool -tlm_fifo::nb_can_put(tlm_tag *) const -{ - return !is_full(); -} - -} // namespace tlm - -#endif -/* __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_PUT_GET_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h deleted file mode 100644 index 79292fd78..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h +++ /dev/null @@ -1,83 +0,0 @@ -/***************************************************************************** - - 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_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_RESIZE_H__ -#define \ - __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_RESIZE_H__ - -// Resize interface. -namespace tlm -{ - -template -inline void -tlm_fifo::nb_expand(unsigned int n) -{ - if (m_size >= 0) { - m_expand = true; - m_size += n; - request_update(); - } -} - -template -inline void -tlm_fifo::nb_unbound(unsigned int n) -{ - m_expand = true; - m_size = -n; - - if (buffer.size() < static_cast(n)) { - buffer.resize(n); - } - - request_update(); -} - -template -inline bool -tlm_fifo::nb_reduce(unsigned int n) -{ - if (m_size < 0) { - return false; - } - - return nb_bound(size() - n); -} - -template -inline bool -tlm_fifo::nb_bound(unsigned int new_size) -{ - bool ret = true; - - if (static_cast(new_size) < used()) { - new_size = used(); - ret = false; - } - - m_size = new_size; - return ret; -} - -} // namespace tlm - -#endif -/* __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_RESIZE_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h deleted file mode 100644 index 8335cc85c..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h +++ /dev/null @@ -1,115 +0,0 @@ -/***************************************************************************** - - 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_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_REQ_RSP_CHANNELS_TLM_PUT_GET_IMP_H__ -#define \ - __TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_REQ_RSP_CHANNELS_TLM_PUT_GET_IMP_H__ - -#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h" - -namespace tlm -{ - -template -class tlm_put_get_imp : private virtual tlm_put_if, - private virtual tlm_get_peek_if -{ - public: - tlm_put_get_imp(tlm_put_if &p, tlm_get_peek_if &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 *t=nullptr) const - { - return put_fifo.nb_can_put(t); - } - const sc_core::sc_event & - ok_to_put(tlm_tag *t=nullptr) const - { - return put_fifo.ok_to_put(t); - } - - // Get interface. - GET_DATA get(tlm_tag * =nullptr) { return get_fifo.get(); } - bool nb_get(GET_DATA &t) { return get_fifo.nb_get(t); } - bool - nb_can_get(tlm_tag *t=nullptr) const - { - return get_fifo.nb_can_get(t); - } - - virtual const sc_core::sc_event & - ok_to_get(tlm_tag *t=nullptr) const - { - return get_fifo.ok_to_get(t); - } - - // Peek interface. - GET_DATA - peek(tlm_tag * =nullptr) const - { - return get_fifo.peek(); - } - bool nb_peek(GET_DATA &t) const { return get_fifo.nb_peek(t); } - bool - nb_can_peek(tlm_tag *t=nullptr) const - { - return get_fifo.nb_can_peek(t); - } - - virtual const sc_core::sc_event & - ok_to_peek(tlm_tag *t=nullptr) const - { - return get_fifo.ok_to_peek(t); - } - - private: - tlm_put_if &put_fifo; - tlm_get_peek_if &get_fifo; -}; - -template -class tlm_master_imp : private tlm_put_get_imp, - public virtual tlm_master_if -{ - public: - tlm_master_imp(tlm_put_if &req, tlm_get_peek_if &rsp) : - tlm_put_get_imp(req, rsp) - {} -}; - -template -class tlm_slave_imp : private tlm_put_get_imp, - public virtual tlm_slave_if -{ - public: - tlm_slave_imp(tlm_get_peek_if &req, tlm_put_if &rsp) : - tlm_put_get_imp(rsp, req) - {} -}; - -} // namespace tlm - -#endif -/* __TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_REQ_RSP_CHANNELS_TLM_PUT_GET_IMP_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h deleted file mode 100644 index 1548e0852..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h +++ /dev/null @@ -1,140 +0,0 @@ -/***************************************************************************** - - 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_TLM_CHANNELS_TLM_REQ_RSP_CHANNELS_TLM_REQ_RSP_CHANNELS_H__ -#define \ - __TLM_REQ_RSP_TLM_CHANNELS_TLM_REQ_RSP_CHANNELS_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 RSP_CHANNEL=tlm_fifo> -class tlm_req_rsp_channel : public sc_core::sc_module -{ - public: - // Uni-directional slave interface. - sc_core::sc_export> get_request_export; - sc_core::sc_export> put_response_export; - - // Uni-directional master interface. - sc_core::sc_export> put_request_export; - sc_core::sc_export> get_response_export; - - // Master/slave interfaces. - sc_core::sc_export> master_export; - sc_core::sc_export> 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 master; - tlm_slave_imp slave; -}; - -template , - typename RSP_CHANNEL=tlm_fifo> -class tlm_transport_channel : public sc_core::sc_module -{ - public: - // Master transport interface. - sc_core::sc_export> target_export; - - // Slave interfaces. - sc_core::sc_export> get_request_export; - sc_core::sc_export> put_response_export; - - sc_core::sc_export> 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; - tlm_transport_to_master t2m; -}; - -} // namespace tlm - -#endif -/* __TLM_REQ_RSP_TLM_CHANNELS_TLM_REQ_RSP_CHANNELS_TLM_REQ_RSP_CHANNELS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h deleted file mode 100644 index 0f88d3f4e..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h +++ /dev/null @@ -1,69 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_PORTS_TLM_EVENT_FINDER_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_PORTS_TLM_EVENT_FINDER_H__ - -#include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h" - -namespace tlm -{ - -template -class tlm_event_finder_t : public sc_core::sc_event_finder -{ - public: - tlm_event_finder_t(const sc_core::sc_port_base &port_, - const sc_core::sc_event &(IF::*event_method_)( - tlm_tag *) const) : - sc_core::sc_event_finder(port_), m_event_method(event_method_) - {} - - virtual ~tlm_event_finder_t() {} - - virtual const sc_core::sc_event & - find_event(sc_core::sc_interface *if_p=nullptr) const; - - private: - const sc_core::sc_event &(IF::*m_event_method)(tlm_tag *) const; - - private: - // disabled - tlm_event_finder_t(); - tlm_event_finder_t(const tlm_event_finder_t &); - tlm_event_finder_t &operator = (const tlm_event_finder_t &); -}; - -template -inline const sc_core::sc_event & -tlm_event_finder_t::find_event(sc_core::sc_interface *if_p) const -{ - const IF *iface = if_p ? dynamic_cast(if_p) : - dynamic_cast(port()->_gem5Interface(0)); - if (iface == nullptr) { - report_error(sc_core::SC_ID_FIND_EVENT_, "port is not bound"); - return sc_core::sc_event::none; - } - return (const_cast(iface)->*m_event_method)(nullptr); -} - -} // namespace tlm - -// __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_PORTS_TLM_EVENT_FINDER_H__ -#endif diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h deleted file mode 100644 index 370b2cae0..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h +++ /dev/null @@ -1,91 +0,0 @@ -/***************************************************************************** - - 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 \ - __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_PORTS_TLM_NONBLOCKING_PORT_H__ -#define \ - __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_PORTS_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 -class tlm_nonblocking_get_port : - public sc_core::sc_port, 1> -{ - public: - typedef tlm_nonblocking_get_if get_if_type; - - tlm_nonblocking_get_port(const char *port_name) : - sc_core::sc_port, 1>(port_name) - {} - - sc_core::sc_event_finder & - ok_to_get() const - { - return *new tlm_event_finder_t( - *this, &get_if_type::ok_to_get); - } -}; - -template -class tlm_nonblocking_peek_port : - public sc_core::sc_port, 1> -{ - public: - typedef tlm_nonblocking_peek_if peek_if_type; - - tlm_nonblocking_peek_port(const char *port_name) : - sc_core::sc_port, 1>(port_name) - {} - - sc_core::sc_event_finder & - ok_to_peek() const - { - return *new tlm_event_finder_t( - *this, &peek_if_type::ok_to_peek); - } -}; - -template -class tlm_nonblocking_put_port : - public sc_core::sc_port, 1> -{ - public: - typedef tlm_nonblocking_put_if put_if_type; - - tlm_nonblocking_put_port(const char *port_name) : - sc_core::sc_port, 1>(port_name) - {} - - sc_core::sc_event_finder & - ok_to_put() const - { - return *new tlm_event_finder_t( - *this, &put_if_type::ok_to_put); - } -}; - -} // namespace tlm - -#endif -/*__SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_PORTS_TLM_NONBLOCKING_PORT_H__*/ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h deleted file mode 100644 index 0d4d0b966..000000000 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h +++ /dev/null @@ -1,37 +0,0 @@ -/***************************************************************************** - - 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 __SYsTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_REQ_RSP_H__ -#define __SYsTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_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 /*__SYsTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_REQ_RSP_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/README.txt b/src/systemc/ext/tlm_core/tlm_2/README.txt deleted file mode 100644 index cb02af2d8..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/README.txt +++ /dev/null @@ -1,111 +0,0 @@ -TLM-2.0 interoperability layer header files -=========================================== - -Dir: include/tlm_core/tlm_2/ - -SubDirs: tlm_2_interfaces/ - tlm_generic_payload/ - tlm_quantum/ - tlm_sockets - -Files: README.txt - tlm_version.h - - -Comments -======== - -User code should only #include the tlm or tlm.h header file in the include/ -directory and avoid including any of the include files in this directory -directly. All objects defined in this file hierarchy are in the tlm namespace. - -tlm_version.h contains the definitions for the version string and integer values - -The header files are organizated, by subdirectory, as follows: - - -tlm_2_interfaces/ ------------------ - -Contains the TLM-2.0 core interfaces - -Files: - tlm_2_interfaces.h (includes the other header files in this directory ) - tlm_fw_bw_ifs.h (defines the TLM 2.0 interface API's: - tlm_fw_nonblocking_transport_if - tlm_bw_nonblocking_transport_if - tlm_blocking_transport_if - tlm_fw_direct_mem_if - tlm_bw_direct_mem_if - tlm_transport_dbg_if - the enumeration type - tlm_sync_enum - and the TLM 2.0 standard interfaces using the API's - tlm_fw_transport_if - tlm_bw_transport_if ) - tlm_dmi.h (defines tlm_dmi) - - -tlm_generic_payload/ --------------------- - -Contains the TLM-2.0 generic payload and associated classes and helper functions - -Files: - tlm_generic_payload.h ( includes the other header files in this directory) - tlm_gp.h (defines the TLM 2.0 generic payload classes: - tlm_generic_payload - tlm_extension - tlm_extension_base - tlm_mm_interface - and the enumeration types - tlm_command - tlm_response_status ) - tlm_array.h (defines array class used by the extention - mechanism ) - tlm_endian_conv.h (defines the implementation for the endianness - helper functions: - tlm_to_hostendian_generic() - tlm_from_hostendian_generic() - tlm_to_hostendian_word() - tlm_from_hostendian_word() - tlm_to_hostendian_aligned() - tlm_from_hostendian_aligned() - tlm_to_hostendian_single() - tlm_from_hostendian_single() ) - - tlm_helpers.h (defines the helper functions to determine the - hostendianness: - get_host_endianness() - host_has_little_endianness() - has_host_endianness() - and defines the enumeration type: - tlm_endianness - tlm_phase.h (defines tlm_phase as an extendable enum type) - - -tlm_sockets/ ------------- - -Contains the standard TLM-2.0 initiator and target sockets (which are used as -the base classes for the convenience sockets in tlm_utils) - -Files: - tlm_sockets.h (includes the other header files in this directory) - tlm_initiator_socket.h (defines the initiator sockets: - tlm_initiator_socket_base - tlm_initiator_socket_b - tlm_initiator_socket - tlm_target_socket.h (defines the target sockets: - tlm_target_socket_base - tlm_target_socket_b - tlm_target_socket - - -tlm_quantum/ ------------- -This contains the global quantum. (The quantum keeper is in tlm_utils) - -Files: - tlm_quantum.h ( includes the other header file in this directory ) - tlm_global_quantum.h ( defines tlm_global_quantum ) diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_2_interfaces.h b/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_2_interfaces.h deleted file mode 100644 index 386f7cb75..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_2_interfaces.h +++ /dev/null @@ -1,26 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_INTERFACES_TLM_2_INTERFACES_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_INTERFACES_TLM_2_INTERFACES_H__ - -#include "tlm_core/tlm_2/tlm_2_interfaces/tlm_dmi.h" -#include "tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h" - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_INTERFACES_TLM_2_INTERFACES_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_dmi.h b/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_dmi.h deleted file mode 100644 index 573744d28..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_dmi.h +++ /dev/null @@ -1,124 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_2_INTERFACES_TLM_DMI_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_2_INTERFACES_TLM_DMI_H__ - -#include - -namespace tlm -{ - -class tlm_dmi -{ - public: - // Enum for indicating the access granted to the initiator. - // The initiator uses gp.m_command to indicate it intention (read/write) - // The target is allowed to promote DMI_ACCESS_READ or DMI_ACCESS_WRITE - // requests to dmi_access_read_write. - - enum dmi_access_e { - DMI_ACCESS_NONE = 0x00, // no access - DMI_ACCESS_READ = 0x01, // read access - DMI_ACCESS_WRITE = 0x02, // write access - DMI_ACCESS_READ_WRITE = DMI_ACCESS_READ | DMI_ACCESS_WRITE - // read/write access - }; - - tlm_dmi() { init(); } - - void - init() - { - m_dmi_ptr = nullptr; - m_dmi_start_address = 0x0; - m_dmi_end_address = (sc_dt::uint64)(-1); - m_dmi_access = DMI_ACCESS_NONE; - m_dmi_read_latency = sc_core::SC_ZERO_TIME; - m_dmi_write_latency = sc_core::SC_ZERO_TIME; - } - - unsigned char *get_dmi_ptr() const { return m_dmi_ptr; } - sc_dt::uint64 get_start_address() const { return m_dmi_start_address; } - sc_dt::uint64 get_end_address() const { return m_dmi_end_address; } - sc_core::sc_time get_read_latency() const { return m_dmi_read_latency; } - sc_core::sc_time get_write_latency() const { return m_dmi_write_latency; } - dmi_access_e get_granted_access() const { return m_dmi_access; } - bool is_none_allowed() const { return m_dmi_access == DMI_ACCESS_NONE; } - bool - is_read_allowed() const - { - return (m_dmi_access & DMI_ACCESS_READ) == DMI_ACCESS_READ; - } - bool - is_write_allowed() const - { - return (m_dmi_access & DMI_ACCESS_WRITE) == DMI_ACCESS_WRITE; - } - bool - is_read_write_allowed() const - { - return (m_dmi_access & DMI_ACCESS_READ_WRITE) == DMI_ACCESS_READ_WRITE; - } - - void set_dmi_ptr(unsigned char *p) { m_dmi_ptr = p; } - void set_start_address(sc_dt::uint64 addr) { m_dmi_start_address = addr; } - void set_end_address(sc_dt::uint64 addr) { m_dmi_end_address = addr; } - void set_read_latency(sc_core::sc_time t) { m_dmi_read_latency = t; } - void set_write_latency(sc_core::sc_time t) { m_dmi_write_latency = t; } - void set_granted_access(dmi_access_e a) { m_dmi_access = a; } - void allow_none() { m_dmi_access = DMI_ACCESS_NONE; } - void allow_read() { m_dmi_access = DMI_ACCESS_READ; } - void allow_write() { m_dmi_access = DMI_ACCESS_WRITE; } - void allow_read_write() { m_dmi_access = DMI_ACCESS_READ_WRITE; } - - private: - // If the forward call is successful, the target returns the dmi_ptr, - // which must point to the data element corresponding to the - // dmi_start_address. The data is organized as a byte array with the - // endianness of the target (endianness member of the tlm_dmi struct). - - unsigned char *m_dmi_ptr; - - // The absolute start and end addresses of the DMI region. If the decoder - // logic in the interconnect changes the address field e.g. by masking, the - // interconnect is responsible to transform the relative address back to an - // absolute address again. - - sc_dt::uint64 m_dmi_start_address; - sc_dt::uint64 m_dmi_end_address; - - // Granted access - - dmi_access_e m_dmi_access; - - // These members define the latency of read/write transactions. The - // initiator must initialize these members to zero before requesting a - // dmi pointer, because both the interconnect as well as the target can - // add to the total transaction latency. - // Depending on the 'type' attribute only one, or both of these attributes - // will be valid. - - sc_core::sc_time m_dmi_read_latency; - sc_core::sc_time m_dmi_write_latency; -}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_2_INTERFACES_TLM_DMI_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h b/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h deleted file mode 100644 index 3c21ca01e..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h +++ /dev/null @@ -1,222 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_2_INTERFACES_TLM_FW_BW_IFS_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_2_INTERFACES_TLM_FW_BW_IFS_H__ - -#include - -#include "tlm_core/tlm_2/tlm_2_interfaces/tlm_dmi.h" -#include "tlm_core/tlm_2/tlm_generic_payload/tlm_generic_payload.h" - -namespace tlm -{ - -enum tlm_sync_enum { TLM_ACCEPTED, TLM_UPDATED, TLM_COMPLETED }; - -//////////////////////////////////////////////////////////////////////////// -// Basic interfaces -//////////////////////////////////////////////////////////////////////////// -template -class tlm_fw_nonblocking_transport_if : public virtual sc_core::sc_interface -{ - public: - virtual tlm_sync_enum nb_transport_fw(TRANS &trans, PHASE &phase, - sc_core::sc_time& t) = 0; -}; - -template -class tlm_bw_nonblocking_transport_if : public virtual sc_core::sc_interface -{ - public: - virtual tlm_sync_enum nb_transport_bw(TRANS &trans, PHASE &phase, - sc_core::sc_time &t) = 0; -}; - -template -class tlm_blocking_transport_if : public virtual sc_core::sc_interface -{ - public: - virtual void b_transport(TRANS &trans, sc_core::sc_time &t) = 0; -}; - -////////////////////////////////////////////////////////////////////////// -// DMI interfaces for getting and invalidating DMI pointers: -////////////////////////////////////////////////////////////////////////// - -// The semantics of the forward interface are as follows: -// -// - An initiator that wants to get direct access to a target's memory region -// can call the get_direct_mem_ptr method with the 'trans' parameter set to -// the address that it wants to gain access to. It sets the trans.m_command -// to specify if the initiator intended use (read or write) -// to the target's DMI region. The initiator is responsible for calling the -// method with a freshly initialized tlm_dmi object either by using a newly -// constructed object, or by calling an existing object's init() method. -// - Although a reference to a complete 'TRANS' type is passed to the get_ -// direct_mem_ptr call, only the address command, and extension fields are of -// interest in most cases. -// - Read and write ranges are not necessarily identical. If they are, a target -// can specify that the range is valid for all accesses with the tlm_data -// m_type attribute in the. -// - The interconnect, if any, needs to decode the address and forward the -// call to the corresponding target. It needs to handle the address exactly -// as the target would expect on a transaction call, e.g. mask the address -// according to the target's address width. -// - If the target supports DMI access for the given address, it sets the -// data fields in the DMI struct and returns true. -// - If a target does not support DMI access it needs to return false. -// The target can either set the correct address range in the DMI struct -// to indicate the memory region where DMI is disallowed, or it can specify -// the complete address range if it doesn't know it's memory range. In this -// case the interconnect is responsible for clipping the address range to -// the correct range that the target serves. -// - The interconnect must always translate the addresses to the initiator's -// address space. This must be the inverse operation of what the -// interconnect needed to do when forwarding the call. In case the -// component wants to change any member of the tlm_dmi object, e.g. for -// its own latency to the target's latency, it must only do so *after* the -// target has been called. The target is always allowed to overwrite all -// values in the tlm_dmi object. -// - In case the slave returned with an invalid region the bus/interconnect -// must fill in the complete address region for the particular slave in the -// DMI data structure. -// -// DMI hint optimization: -// -// Initiators may use the DMI hint in the tlm_generic_payload to avoid -// unnecessary DMI attempts. The recommended sequence of interface -// method calls would be: -// -// - The initiator first tries to check if it has a valid DMI region for the -// address that it wants to access next. -// - If not, it performs a normal transaction. -// - If the DMI hint in this transaction is true, the initiator can try and -// get the DMI region. -// -// Note that the DMI hint optimization is completely optional and every -// initiator model is free to ignore the DMI hint. However, a target is -// required to set the DMI hint to true if a DMI request on the given address -// with the given transaction type (read or write) would have succeeded. - -template -class tlm_fw_direct_mem_if : public virtual sc_core::sc_interface -{ - public: - virtual bool get_direct_mem_ptr(TRANS &trans, tlm_dmi &dmi_data) = 0; -}; - -// The semantics of the backwards call is as follows: -// -// - An interconnect component or a target is required to invalidate all -// affected DMI regions whenever any change in the regions take place. -// The exact rule is that a component must invalidate all those DMI regions -// that it already reported, if it would answer the same DMI request -// with any member of the tlm_dmi data structure set differently. -// - An interconnect component must forward the invalidate_direct_mem_ptr call -// to all initiators that could potentially have a DMI pointer to the region -// specified in the method arguments. A safe implementation is to call -// every attached initiator. -// - An interconnect component must transform the address region of an -// incoming invalidate_direct_mem_ptr to the corresponding address space -// for the initiators. Basically, this is the same address transformation -// that the interconnect does on the DMI ranges on the forward direction. -// - Each initiator must check if it has a pointer to the given region and -// throw this away. It is recommended that the initiator throws away all DMI -// regions that have any overlap with the given regions, but this is not a -// hard requirement. -// -// - A full DMI pointer invalidation, e.g. for a bus remap can be signaled -// by setting the range: 0x0 - 0xffffffffffffffffull = (sc_dt::uint64)-1 -// - An initiator must throw away all DMI pointers in this case. -// -// - Under no circumstances a model is allowed to call the get_direct_mem_ptr -// from within the invalidate_direct_mem_ptr method, directly or indirectly. -// -class tlm_bw_direct_mem_if : public virtual sc_core::sc_interface -{ - public: - virtual void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, - sc_dt::uint64 end_range) = 0; -}; - -///////////////////////////////////////////////////////////////////// -// debug interface for memory access -///////////////////////////////////////////////////////////////////// -// -// This interface can be used to gain access to a targets memory or registers -// in a non-intrusive manner. No side effects, waits or event notifications -// must happen in the course of the method. -// -// Semantics: -// - The initiator calls the transport_dbg method with transaction 'trans' as -// argument. The commonly used parts of trans for debug are: -// . address: The start address that it wants to peek or poke. -// . length: The number of bytes that it requests to read or write. -// . command: Indicates a read or write access. -// . data: A pointer to the initiator-allocated data buffer, which must -// be at least num_bytes large. The data is always organized in -// the endianness of the machine. -// . extensions: Any extension that could affect the transaction. -// - The interconnect, if any, will decode the address and forward the call to -// the appropriate target. -// - The target must return the number of successfully transmitted bytes, where -// this number must be <= num_bytes. Thus, a target can safely return 0 if it -// does not support debug transactions. -// -template -class tlm_transport_dbg_if : public virtual sc_core::sc_interface -{ - public: - // The return value of defines the number of bytes successfully - // transferred. - virtual unsigned int transport_dbg(TRANS &trans) = 0; -}; - -//////////////////////////////////////////////////////////////////////////// -// Combined interfaces -//////////////////////////////////////////////////////////////////////////// - -struct tlm_base_protocol_types -{ - typedef tlm_generic_payload tlm_payload_type; - typedef tlm_phase tlm_phase_type; -}; - -// The forward interface: -template -class tlm_fw_transport_if : - public virtual tlm_fw_nonblocking_transport_if< - typename TYPES::tlm_payload_type, typename TYPES::tlm_phase_type>, - public virtual tlm_blocking_transport_if, - public virtual tlm_fw_direct_mem_if, - public virtual tlm_transport_dbg_if -{}; - -// The backward interface: -template -class tlm_bw_transport_if : - public virtual tlm_bw_nonblocking_transport_if< - typename TYPES::tlm_payload_type, typename TYPES::tlm_phase_type>, - public virtual tlm_bw_direct_mem_if -{}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_2_INTERFACES_TLM_FW_BW_IFS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_array.h b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_array.h deleted file mode 100644 index 9890a2a2c..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_array.h +++ /dev/null @@ -1,98 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOADS_TLM_ARRAY_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOADS_TLM_ARRAY_H__ - -#include - -namespace tlm -{ - -// This implements a lean and fast array class that supports array expansion on -// request. The class is primarily used in the tlm_generic_payload class for -// storing the pointers to the extensions. -// -// Individual array elements can be accessed through the [] operators, and the -// array length is returned by the size() method. -// -// The size can be dynamically expanded using the expand(uint) method. There -// is no shrinking mechanism implemented, because the extension mechanism -// does not require this feature. Bear in mind that calling the expand method -// may invalidate all direct pointers into the array. - - -// The tlm_array shall always be used with T=tlm_extension_base*. -template -class tlm_array : private std::vector -{ - private: - typedef std::vector base_type; - typedef typename base_type::size_type size_type; - - public: - tlm_array(size_type size=0) : base_type(size), m_entries() {} - - // Operators for dereferencing: - using base_type::operator []; - - // Array size: - using base_type::size; - - // Expand the array if needed: - void - expand(size_type new_size) - { - if (new_size > size()) - base_type::resize(new_size); - } - - static const char *const kind_string; - const char *kind() const { return kind_string; } - - // This function shall get a pointer to an array slot - // it stores this slot in a cache of active slots - void insert_in_cache(T *p) { m_entries.push_back(p - &(*this)[0]); } - - // This functions clears all active slots of the array. - void - free_entire_cache() - { - while (m_entries.size()) { - // We make sure no one cleared the slot manually. - if ((*this)[m_entries.back()]) { - // ...and then we call free on the content of the slot - (*this)[m_entries.back()]->free(); - } - // Afterwards we set the slot to NULL - (*this)[m_entries.back()] = nullptr; - m_entries.pop_back(); - } - } - - protected: - std::vector m_entries; -}; - -template -const char *const tlm_array::kind_string = "tlm_array"; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOADS_TLM_ARRAY_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_endian_conv.h b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_endian_conv.h deleted file mode 100644 index 7eb86fa68..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_endian_conv.h +++ /dev/null @@ -1,942 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_ENDIAN_CONV_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_ENDIAN_CONV_H__ - -#include "tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h" - -#include // std::memset - -namespace tlm -{ - -/* -Tranaction-Level Modelling -Endianness Helper Functions - -DESCRIPTION -A set of functions for helping users to get the endianness -right in their TLM models of system initiators. These functions are -for use within an initiator. They can not be used as-is outside -an initiator because the extension used to store context will not work -if cascaded, and they do not respect the generic payload mutability -rules. However this code may be easily copied and adapted for use -in bridges, etc.. - -These functions are not compulsory. There are other legitimate ways to -achieve the same functionality. If extra information is available at -compile time about the nature of an initiator's transactions, this can -be exploited to accelerate simulations by creating further functions -similar to those in this file. In general a functional transaction can be -described in more than one way by a TLM-2 GP object. - -The functions convert the endianness of a GP object, either on request or -response. They should only be used when the initiator's endianness -does not match the host's endianness. They assume 'arithmetic mode' -meaning that within a data word the byte order is always host-endian. -For non-arithmetic mode initiators they can be used with a data word -size of 1 byte. - -All the functions are templates, for example: - -template inline void - to_hostendian_generic(tlm_generic_payload *txn, int sizeof_databus) - -The template parameter provides the data word width. Having this as a class -makes it easy to use it for copy and swap operations within the functions. -If the assignment operator for this class is overloaded, the endianness -conversion function may not have the desired effect. - -All the functions have the same signature except for different names. - -The principle is that a function to_hostendian_convtype() is called when the -initiator-endian transaction is created, and the matching function -from_hostendian_convtype() is called when the transaction is completed, for -example before read data can be used. In some cases the from_ function is -redundant but an empty function is provided anyway. It is strongly -recommended that the from_ function is called, in case it ceases to be -redundant in future versions of this code. - -No context needs to be managed outside the two functions, except that they -must be called with the same template parameter and the same bus width. - -For initiator models that can not easily manage this context information, -a single entry point for the from_ function is provided, which will be -a little slower than calling the correct from_ function directly, as -it can not be inlined. - -All functions assume power-of-2 bus and data word widths. - -Functions offered: - -0) A pair of functions that work for almost all TLM2 GP transactions. The -only limitations are that data and bus widths should be powers of 2, and that -the data length should be an integer number of streaming widths and that the -streaming width should be an integer number of data words. -These functions always allocate new data and byte enable buffers and copy -data one byte at a time. - tlm_to_hostendian_generic(tlm_generic_payload *txn, int sizeof_databus) - tlm_from_hostendian_generic(tlm_generic_payload *txn, int sizeof_databus) - -1) A pair of functions that work for all transactions regardless of data and -bus data sizes and address alignment except for the the following -limitations: -- byte-enables are supported only when byte-enable granularity is no finer -than the data word (every data word is wholly enabled or wholly disabled) -- byte-enable-length is not supported (if byte enables are present, the byte -enable length must be equal to the data length). -- streaming width is not supported -- data word wider than bus word is not supported -A new data buffer and a new byte enable buffer are always allocated. Byte -enables are assumed to be needed even if not required for the original -(unconverted) transaction. Data is copied to the new buffer on request -(for writes) or on response (for reads). Copies are done word-by-word -where possible. - tlm_to_hostendian_word(tlm_generic_payload *txn, int sizeof_databus) - tlm_from_hostendian_word(tlm_generic_payload *txn, int sizeof_databus) - -2) If the original transaction is both word and bus-aligned then this pair of -functions can be used. It will complete faster than the generic function -because the data reordering function is much simpler and no address -conversion is required. -The following limitations apply: -- byte-enables are supported only when byte-enable granularity is no finer -than the data word (every data word is wholly enabled or wholly disabled) -- byte-enable-length is not supported (if byte enables are present, the byte -enable length must be equal to the data length). -- streaming width is not supported -- data word wider than bus word is not supported -- the transaction must be an integer number of bus words -- the address must be aligned to the bus width - tlm_to_hostendian_aligned(tlm_generic_payload *txn, int sizeof_databus) - tlm_from_hostendian_aligned(tlm_generic_payload *txn, int sizeof_databus) - -3) For single word transactions that don't cross a bus word boundary it -is always safe to work in-place and the conversion is very simple. Again, -streaming width and byte-enable length are not supported, and byte-enables -may not changes within a data word. - tlm_to_hostendian_single(tlm_generic_payload *txn, int sizeof_databus) - tlm_from_hostendian_single(tlm_generic_payload *txn, int sizeof_databus) - -4) A single entry point for accessing the correct from_ function without -needing to store context. - tlm_from_hostendian(tlm_generic_payload *txn) -*/ - -/////////////////////////////////////////////////////////////////////////////// -// Generic Utilities - -class tlm_endian_context; - -class tlm_endian_context_pool -{ - public: - tlm_endian_context *first; - inline tlm_endian_context_pool(); - inline ~tlm_endian_context_pool(); - inline tlm_endian_context *pop(); - inline void push(tlm_endian_context *c); -}; - -static tlm_endian_context_pool global_tlm_endian_context_pool; - -// an extension to keep the information needed for reconversion of response -class tlm_endian_context : public tlm_extension -{ - public: - tlm_endian_context() : dbuf_size(0), bebuf_size(0) {} - - ~tlm_endian_context() { - if (dbuf_size > 0) - delete [] new_dbuf; - if (bebuf_size > 0) - delete [] new_bebuf; - } - - sc_dt::uint64 address; // Used by generic, word. - sc_dt::uint64 new_address; // Used by generic. - unsigned char *data_ptr; // Used by generic, word, aligned. - unsigned char *byte_enable; // Used by word. - int length; // Used by generic, word. - int stream_width; // Used by generic. - - // Used by common entry point on response. - void (*from_f)(tlm_generic_payload *txn, unsigned int sizeof_databus); - int sizeof_databus; - - // Reordering buffers for data and byte-enables. - unsigned char *new_dbuf, *new_bebuf; - int dbuf_size, bebuf_size; - - void - establish_dbuf(int len) - { - if (len <= dbuf_size) - return; - if (dbuf_size > 0) - delete [] new_dbuf; - new_dbuf = new unsigned char[len]; - dbuf_size = len; - } - - void - establish_bebuf(int len) - { - if (len <= bebuf_size) - return; - if (bebuf_size > 0) - delete [] new_bebuf; - new_bebuf = new unsigned char[len]; - bebuf_size = len; - } - - // Required for extension management. - void free() { global_tlm_endian_context_pool.push(this); } - tlm_extension_base *clone() const { return 0; } - void copy_from(tlm_extension_base const &) { return; } - - // For pooling. - tlm_endian_context *next; -}; - -// Assumptions about transaction contexts: -// 1) only the address attribute of a transaction -// is mutable. all other attributes are unchanged from the request to -// response side conversion. -// 2) the conversion functions in this file do not respect the mutability -// rules and do not put the transaction back into its original state after -// completion. so if the initiator has any cleaning up to do (eg of byte -// enable buffers), it needs to store its own context. the transaction -// returned to the initiator may contain pointers to data and byte enable -// that can/must not be deleted. -// 3) the conversion functions in this file use an extension to store -// context information. they do not remove this extension. the initiator -// should not remove it unless it deletes the generic payload -// object. - -inline tlm_endian_context * -establish_context(tlm_generic_payload *txn) -{ - tlm_endian_context *tc = txn->get_extension(); - if (tc == 0) { - tc = global_tlm_endian_context_pool.pop(); - txn->set_extension(tc); - } - return tc; -} - -inline tlm_endian_context_pool::tlm_endian_context_pool() : first(0) {} - -inline tlm_endian_context_pool::~tlm_endian_context_pool() -{ - while (first != 0) { - tlm_endian_context *next = first->next; - delete first; - first = next; - } -} - -tlm_endian_context * -tlm_endian_context_pool::pop() -{ - if (first == 0) - return new tlm_endian_context; - tlm_endian_context *r = first; - first = first->next; - return r; -} - -void tlm_endian_context_pool::push(tlm_endian_context *c) -{ - c->next = first; - first = c; -} - - -// A set of constants for efficient filling of byte enables. -template -class tlm_bool -{ - public: - static D TLM_TRUE; - static D TLM_FALSE; - static D - make_uchar_array(unsigned char c) - { - D d; - unsigned char *tmp = (unsigned char *)(&d); - for (ptrdiff_t i = 0; i != sizeof(D); i++) - tmp[i] = c; // 64BITFIX negligable risk but easy fix. - return d; - } - - // Also provides an syntax-efficient tester, using a - // copy constuctor and an implicit cast to boolean. - tlm_bool(D &d) : b(*((unsigned char *)&d) != TLM_BYTE_DISABLED) {} - operator bool() const { return b; } - private: - bool b; -}; - -template -D tlm_bool::TLM_TRUE = tlm_bool::make_uchar_array(TLM_BYTE_ENABLED); -template -D tlm_bool::TLM_FALSE = tlm_bool::make_uchar_array(TLM_BYTE_DISABLED); - - - -inline void -copy_db0(unsigned char *src1, unsigned char *src2, - unsigned char *dest1, unsigned char *dest2) -{ - *dest1 = *src1; - *dest2 = *src2; -} - -inline void -copy_dbtrue0(unsigned char *src1, unsigned char * /* src2 */, - unsigned char *dest1, unsigned char *dest2) -{ - *dest1 = *src1; - *dest2 = TLM_BYTE_ENABLED; -} - -inline void -copy_btrue0(unsigned char * /* src1 */, unsigned char * /* src2 */, - unsigned char * /* dest1 */, unsigned char *dest2) -{ - *dest2 = TLM_BYTE_ENABLED; -} - -inline void -copy_b0(unsigned char * /* src1 */, unsigned char *src2, - unsigned char * /* dest1 */, unsigned char *dest2) -{ - *dest2 = *src2; -} - -inline void -copy_dbyb0(unsigned char *src1, unsigned char * /* src2 */, - unsigned char *dest1, unsigned char *dest2) -{ - if (*dest2 == TLM_BYTE_ENABLED) - *src1 = *dest1; -} - - -template -inline void -loop_generic0(int new_len, int new_stream_width, int orig_stream_width, - int sizeof_databus, sc_dt::uint64 orig_start_address, - sc_dt::uint64 new_start_address, int be_length, - unsigned char *ie_data, unsigned char *ie_be, - unsigned char *he_data, unsigned char *he_be) -{ - for (int orig_sword = 0, new_sword = 0; new_sword < new_len; - new_sword += new_stream_width, orig_sword += orig_stream_width) { - sc_dt::uint64 ie_addr = orig_start_address; - for (int orig_dword = orig_sword; - orig_dword < orig_sword + orig_stream_width; - orig_dword += sizeof(D)) { - for (int curr_byte = orig_dword + sizeof(D) - 1; - curr_byte >= orig_dword; curr_byte--) { - ptrdiff_t he_index = ((ie_addr++) ^ (sizeof_databus - 1)) - - new_start_address + new_sword; // 64BITFIX - COPY(ie_data + curr_byte, - // 64BITRISK no risk of overflow, always positive. - ie_be + (curr_byte % be_length), - he_data + he_index, he_be + he_index); - } - } - } -} - - -/////////////////////////////////////////////////////////////////////////////// -// function set (0): Response -/////////////////////////////////////////////////////////////////////////////// - -template -inline void -tlm_from_hostendian_generic(tlm_generic_payload *txn, - unsigned int sizeof_databus) -{ - if (txn->is_read()) { - tlm_endian_context *tc = - txn->template get_extension(); - loop_generic0(txn->get_data_length(), - txn->get_streaming_width(), tc->stream_width, sizeof_databus, - tc->address, tc->new_address, txn->get_data_length(), - tc->data_ptr, 0, txn->get_data_ptr(), - txn->get_byte_enable_ptr()); - } -} - - -/////////////////////////////////////////////////////////////////////////////// -// function set (0): Request -template -inline void -tlm_to_hostendian_generic(tlm_generic_payload *txn, - unsigned int sizeof_databus) -{ - tlm_endian_context *tc = establish_context(txn); - tc->from_f = &(tlm_from_hostendian_generic); - tc->sizeof_databus = sizeof_databus; - - // Calculate new size: nr stream words multiplied by big enough stream - // width. - int s_width = txn->get_streaming_width(); - int length = txn->get_data_length(); - if (s_width >= length) - s_width = length; - int nr_stream_words = length / s_width; - - // Find out in which bus word the stream word starts and ends. - sc_dt::uint64 new_address = (txn->get_address() & ~(sizeof_databus - 1)); - sc_dt::uint64 end_address = ((txn->get_address() + s_width - 1) & - ~(sizeof_databus - 1)); - - int new_stream_width = end_address - new_address + sizeof_databus; - int new_length = new_stream_width * nr_stream_words; - - // Store context. - tc->data_ptr = txn->get_data_ptr(); - tc->address = txn->get_address(); - tc->new_address = new_address; - tc->stream_width = s_width; - unsigned char *orig_be = txn->get_byte_enable_ptr(); - int orig_be_length = txn->get_byte_enable_length(); - - // Create data and byte-enable buffers. - txn->set_address(new_address); - tc->establish_dbuf(new_length); - txn->set_data_ptr(tc->new_dbuf); - tc->establish_bebuf(new_length); - txn->set_byte_enable_ptr(tc->new_bebuf); - std::memset(txn->get_byte_enable_ptr(), TLM_BYTE_DISABLED, new_length); - txn->set_streaming_width(new_stream_width); - txn->set_data_length(new_length); - txn->set_byte_enable_length(new_length); - - // Copy data and/or byte enables. - if (txn->is_write()) { - if (orig_be == 0) { - loop_generic0( - new_length, new_stream_width, s_width, sizeof_databus, - tc->address, new_address, new_length, tc->data_ptr, 0, - txn->get_data_ptr(), txn->get_byte_enable_ptr()); - } else { - loop_generic0(new_length, new_stream_width, - s_width, sizeof_databus, tc->address, new_address, - orig_be_length, tc->data_ptr, orig_be, - txn->get_data_ptr(), txn->get_byte_enable_ptr()); - } - } else { - // Read transaction. - if (orig_be == 0) { - loop_generic0(new_length, - new_stream_width, s_width, sizeof_databus, tc->address, - new_address, new_length, tc->data_ptr, 0, - txn->get_data_ptr(), txn->get_byte_enable_ptr()); - } else { - loop_generic0(new_length, new_stream_width, - s_width, sizeof_databus, tc->address, new_address, - orig_be_length, tc->data_ptr, orig_be, - txn->get_data_ptr(), txn->get_byte_enable_ptr()); - } - } -} - - -/////////////////////////////////////////////////////////////////////////////// -// function set (1): Utilities -/////////////////////////////////////////////////////////////////////////////// - -template -inline void -copy_d1(unsigned char *src1, unsigned char *src2, - unsigned char *dest1, unsigned char *dest2) -{ - *((D *)dest1) = *((D *)src1); - *((D *)dest2) = tlm_bool::TLM_TRUE; -} - -template -inline void -copy_db1(unsigned char *src1, unsigned char *src2, - unsigned char *dest1, unsigned char *dest2) -{ - *((D *)dest1) = *((D *)src1); - *((D *)dest2) = *((D *)src2); -} - -template -inline void -true_b1(unsigned char *src1, unsigned char *src2, - unsigned char *dest1, unsigned char *dest2) -{ - *((D *)dest2) = tlm_bool::TLM_TRUE; -} - -template -inline void -copy_b1(unsigned char *src1, unsigned char *src2, - unsigned char *dest1, unsigned char *dest2) -{ - *((D *)dest2) = *((D *)src2); -} - -template -inline void -copy_dbyb1(unsigned char *src1, unsigned char *src2, - unsigned char *dest1, unsigned char *dest2) -{ - if (*src2 != TLM_BYTE_DISABLED) - *((D *)src1) = *((D *)dest1); -} - -template -inline void -copy_dbytrue1(unsigned char *src1, unsigned char *src2, - unsigned char *dest1, unsigned char *dest2) -{ - *((D *)src1) = *((D *)dest1); -} - -template -inline void -false_b1(unsigned char *dest1) -{ - *((D *)dest1) = tlm_bool::TLM_FALSE; -} - -template -inline void -no_b1(unsigned char *dest1) -{} - -template -inline int -loop_word1(int bytes_left, int len0, int lenN, int sizeof_databus, - unsigned char *start, unsigned char *end, - unsigned char *src, unsigned char *bsrc, - unsigned char *dest, unsigned char *bdest) -{ - ptrdiff_t d2b_src = bsrc - src; // 64BITFIX was int - ptrdiff_t d2b_dest = bdest - dest; // 64BITFIX was int - unsigned char *original_dest = dest; - - while (true) { - // len0 bytes at start of a bus word. - if ((src >= start) && (src < end)) { - for (int i = 0; i < len0; i++) { - COPYuchar(src, src + d2b_src, dest, dest + d2b_dest); - src++; - dest++; - } - bytes_left -= len0; - if (bytes_left <= 0) - return int(dest - original_dest); - } else { - for (int i = 0; i < len0; i++) { - FILLFALSEuchar(dest + d2b_dest); - src++; - dest++; - } - } - src -= 2 * sizeof(D); - - // Sequence of full data word fragments. - for (unsigned int i = 1; i < sizeof_databus / sizeof(D); i++) { - if ((src >= start) && (src < end)) { - COPY(src, src + d2b_src, dest, dest + d2b_dest); - bytes_left -= sizeof(D); - } else { - FILLFALSE(dest + d2b_dest); - } - dest += sizeof(D); - if (bytes_left <= 0) - return int(dest - original_dest); - src -= sizeof(D); - } - - // lenN bytes at end of bus word. - if ((src >= start) && (src < end)) { - for (int i = 0; i < lenN; i++) { - COPYuchar(src, src + d2b_src, dest, dest + d2b_dest); - src++; - dest++; - } - bytes_left -= lenN; - if (bytes_left <= 0) - return int(dest - original_dest); - } else { - for (int i = 0; i < lenN; i++) { - FILLFALSEuchar(dest + d2b_dest); - src++; - dest++; - } - } - src += 2 * sizeof_databus; - } -} - - -/////////////////////////////////////////////////////////////////////////////// -// function set (1): Response -/////////////////////////////////////////////////////////////////////////////// - -template -inline void -tlm_from_hostendian_word(tlm_generic_payload *txn, unsigned int sizeof_databus) -{ - if (txn->is_read()) { - tlm_endian_context *tc = - txn->template get_extension(); - sc_dt::uint64 b_mask = sizeof_databus - 1; - int d_mask = sizeof(DATAWORD) - 1; - int a_offset = static_cast(tc->address & b_mask); - int len0 = (sizeof_databus - a_offset) & d_mask; - int lenN = sizeof(DATAWORD) - len0; - unsigned char *d_start = tc->data_ptr; - unsigned char *d_end = - ptrdiff_t(tc->length) + d_start; // 64BITFIX probably redundant - unsigned char *d = - ptrdiff_t(((sizeof_databus - a_offset) & ~d_mask) + lenN) + - d_start; // 64BITFIX probably redundant - - // Iterate over transaction copying data qualified by byte-enables. - if (tc->byte_enable == 0) { - loop_word1, - ©_dbytrue1, &no_b1, - &no_b1>( - tc->length, len0, lenN, sizeof_databus, - d_start, d_end, d, 0, txn->get_data_ptr(), 0); - } else { - loop_word1, - ©_dbyb1, &no_b1, - &no_b1>( - tc->length, len0, lenN, sizeof_databus, - d_start, d_end, d, - tc->byte_enable - d_start + d, - txn->get_data_ptr(), 0); - } - } -} - - -/////////////////////////////////////////////////////////////////////////////// -// function set (1): Request -/////////////////////////////////////////////////////////////////////////////// - -template -inline void -tlm_to_hostendian_word(tlm_generic_payload *txn, unsigned int sizeof_databus) -{ - tlm_endian_context *tc = establish_context(txn); - tc->from_f = &(tlm_from_hostendian_word); - tc->sizeof_databus = sizeof_databus; - - sc_dt::uint64 b_mask = sizeof_databus - 1; - int d_mask = sizeof(DATAWORD) - 1; - sc_dt::uint64 a_aligned = txn->get_address() & ~b_mask; - int a_offset = static_cast(txn->get_address() & b_mask); - int len0 = (sizeof_databus - a_offset) & d_mask; - int lenN = sizeof(DATAWORD) - len0; - unsigned char *d_start = txn->get_data_ptr(); - unsigned char *d_end = - ptrdiff_t(txn->get_data_length()) + d_start; - // 64BITFIX probably redundant. - unsigned char *d = - ptrdiff_t(((sizeof_databus - a_offset) & ~d_mask) + lenN) + d_start; - // 64BITFIX probably redundant. - - // Create new data and byte enable buffers. - int long_enough = txn->get_data_length() + 2 * sizeof_databus; - tc->establish_dbuf(long_enough); - unsigned char *new_data = tc->new_dbuf; - tc->establish_bebuf(long_enough); - unsigned char *new_be = tc->new_bebuf; - - if (txn->is_read()) { - tc->data_ptr = d_start; - tc->address = txn->get_address(); - tc->byte_enable = txn->get_byte_enable_ptr(); - tc->length = txn->get_data_length(); - if (txn->get_byte_enable_ptr() == 0) { - // Iterate over transaction creating new byte enables from all-true - txn->set_data_length( - loop_word1, - &true_b1, &false_b1, - &false_b1>( - txn->get_data_length(), len0, lenN, - sizeof_databus, d_start, d_end, d, 0, - new_data, new_be)); - } else { - // iterate over transaction copying byte enables - txn->set_data_length( - loop_word1, - ©_b1, &false_b1, - &false_b1>( - txn->get_data_length(), len0, lenN, - sizeof_databus, d_start, d_end, d, - txn->get_byte_enable_ptr() - d_start + d, - new_data, new_be)); - } - } else { - // WRITE - if (txn->get_byte_enable_ptr() == 0) { - // Iterate over transaction copying data and creating new - // byte-enables. - txn->set_data_length( - loop_word1, - ©_d1, &false_b1, - &false_b1>( - txn->get_data_length(), len0, lenN, - sizeof_databus, d_start, d_end, d, 0, - new_data, new_be)); - } else { - // Iterate over transaction copying data and byte-enables. - txn->set_data_length( - loop_word1, - ©_db1, &false_b1, - &false_b1>( - txn->get_data_length(), len0, lenN, - sizeof_databus, d_start, d_end, d, - txn->get_byte_enable_ptr() - d_start + d, - new_data, new_be)); - } - } - txn->set_byte_enable_length(txn->get_data_length()); - txn->set_streaming_width(txn->get_data_length()); - txn->set_data_ptr(new_data); - txn->set_byte_enable_ptr(new_be); - txn->set_address(a_aligned); -} - - - -/////////////////////////////////////////////////////////////////////////////// -// function set (2): Utilities -/////////////////////////////////////////////////////////////////////////////// - -template -inline void copy_d2(D *src1, D *src2, D *dest1, D *dest2) { *dest1 = *src1; } - -template -inline void -copy_db2(D *src1, D *src2, D *dest1, D *dest2) -{ - *dest1 = *src1; - *dest2 = *src2; -} - -template -inline void -copy_dbyb2(D *src1, D *src2, D *dest1, D *dest2) -{ - if (tlm_bool(*src2)) - *dest1 = *src1; -} - -template -inline void -loop_aligned2(D *src1, D *src2, D *dest1, D *dest2, int words, - int words_per_bus) -{ - // 64BITFIX was int and operands were cast to int. - ptrdiff_t src1to2 = (char *)src2 - (char *)src1; - // 64BITFIX was int and operands were cast to int. - ptrdiff_t dest1to2 = (char *)dest2 - (char *)dest1; - - D *done = src1 + ptrdiff_t(words); // 64BITFIX. - D *bus_start = src1; - src1 += ptrdiff_t(words_per_bus - 1); // 64BITFIX. - - while (true) { - COPY(src1, (D *)(src1to2 + (char *)src1), dest1, - (D *)(dest1to2 + (char *)dest1)); // 64BITFIX. - dest1++; - if ((--src1) < bus_start) { - bus_start += ptrdiff_t(words_per_bus); // 64BITFIX. - if (bus_start == done) - break; - src1 = bus_start + ptrdiff_t(words_per_bus - 1); // 64BITFIX. - } - } -} - - -/////////////////////////////////////////////////////////////////////////////// -// function set (2): Response -/////////////////////////////////////////////////////////////////////////////// - -template -inline void -tlm_from_hostendian_aligned( - tlm_generic_payload *txn, unsigned int sizeof_databus) -{ - int words_per_bus = sizeof_databus / sizeof(DATAWORD); - if (words_per_bus == 1) - return; - int words = (txn->get_data_length()) / sizeof(DATAWORD); - tlm_endian_context *tc = txn->template get_extension(); - - if (txn->get_byte_enable_ptr() == 0) { - // no byte enables - if (txn->is_read()) { - // RD without byte enables. Copy data to original buffer. - loop_aligned2>( - (DATAWORD *)(txn->get_data_ptr()), 0, - (DATAWORD *)(tc->data_ptr), 0, words, words_per_bus); - } - } else { - // byte enables present - if (txn->is_read()) { - // RD with byte enables. Copy data qualified by byte-enables. - loop_aligned2>( - (DATAWORD *)(txn->get_data_ptr()), - (DATAWORD *)(txn->get_byte_enable_ptr()), - (DATAWORD *)(tc->data_ptr), 0, words, words_per_bus); - } - } -} - - -/////////////////////////////////////////////////////////////////////////////// -// function set (2): Request -/////////////////////////////////////////////////////////////////////////////// - -template -inline void -tlm_to_hostendian_aligned( - tlm_generic_payload *txn, unsigned int sizeof_databus) -{ - tlm_endian_context *tc = establish_context(txn); - tc->from_f = &(tlm_from_hostendian_aligned); - tc->sizeof_databus = sizeof_databus; - - int words_per_bus = sizeof_databus / sizeof(DATAWORD); - if (words_per_bus == 1) - return; - int words = (txn->get_data_length()) / sizeof(DATAWORD); - - DATAWORD *original_be = (DATAWORD *)(txn->get_byte_enable_ptr()); - DATAWORD *original_data = (DATAWORD *)(txn->get_data_ptr()); - - // Always allocate a new data buffer. - tc->establish_dbuf(txn->get_data_length()); - txn->set_data_ptr(tc->new_dbuf); - - if (original_be == 0) { - // No byte enables. - if (txn->is_write()) { - // WR no byte enables. Copy data. - loop_aligned2>( - original_data, 0, (DATAWORD *)(txn->get_data_ptr()), 0, - words, words_per_bus); - } else { - // RD no byte enables. Save original data pointer. - tc->data_ptr = (unsigned char *)original_data; - } - } else { - // Byte enables present. - // Allocate a new buffer for them. - tc->establish_bebuf(txn->get_data_length()); - txn->set_byte_enable_ptr(tc->new_bebuf); - txn->set_byte_enable_length(txn->get_data_length()); - - if (txn->is_write()) { - // WR with byte enables. Copy data and BEs. - loop_aligned2>( - original_data, original_be, - (DATAWORD *)(txn->get_data_ptr()), - (DATAWORD *)(txn->get_byte_enable_ptr()), - words, words_per_bus); - } else { - // RD with byte enables. Save original data pointer. - tc->data_ptr = (unsigned char *)original_data; - // Copy byte enables to new buffer. - loop_aligned2>( - original_be, 0, (DATAWORD *)(txn->get_byte_enable_ptr()), - 0, words, words_per_bus); - } - } -} - - - -/////////////////////////////////////////////////////////////////////////////// -// function set (3): Response -/////////////////////////////////////////////////////////////////////////////// - -template -inline void -tlm_from_hostendian_single( - tlm_generic_payload *txn, unsigned int sizeof_databus) -{} - - -/////////////////////////////////////////////////////////////////////////////// -// function set (3): Request -/////////////////////////////////////////////////////////////////////////////// - -template -inline void -tlm_to_hostendian_single(tlm_generic_payload *txn, unsigned int sizeof_databus) -{ - tlm_endian_context *tc = establish_context(txn); - tc->from_f = &(tlm_from_hostendian_single); - tc->sizeof_databus = sizeof_databus; - - // Only need to change the address, always safe to work in-place. - sc_dt::uint64 mask = sizeof_databus - 1; - sc_dt::uint64 a = txn->get_address(); - txn->set_address((a & ~mask) | - (sizeof_databus - (a & mask) - sizeof(DATAWORD))); -} - - - -/////////////////////////////////////////////////////////////////////////////// -// helper function which works for all responses -/////////////////////////////////////////////////////////////////////////////// - -inline void -tlm_from_hostendian(tlm_generic_payload *txn) -{ - tlm_endian_context *tc = txn->get_extension(); - (*(tc->from_f))(txn, tc->sizeof_databus); -} - -} // namespace tlm - -#endif -/* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_ENDIAN_CONV_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_generic_payload.h b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_generic_payload.h deleted file mode 100644 index c3b6b6bb0..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_generic_payload.h +++ /dev/null @@ -1,28 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_TLM_GENERIC_PAYLOAD_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_TLM_GENERIC_PAYLOAD_H__ - -#include "tlm_core/tlm_2/tlm_generic_payload/tlm_endian_conv.h" -#include "tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h" -#include "tlm_core/tlm_2/tlm_generic_payload/tlm_helpers.h" -#include "tlm_core/tlm_2/tlm_generic_payload/tlm_phase.h" - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_TLM_GENERIC_PAYLOAD_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h deleted file mode 100644 index 0204aed76..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h +++ /dev/null @@ -1,428 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_GP_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_GP_H__ - -#include -#include // std::type_info - -#include "tlm_core/tlm_2/tlm_generic_payload/tlm_array.h" - -namespace tlm -{ - -class tlm_generic_payload; - -class tlm_mm_interface -{ - public: - virtual void free(tlm_generic_payload *) = 0; - virtual ~tlm_mm_interface() {} -}; - -//--------------------------------------------------------------------------- -// Classes and helpers for the extension mechanism -//--------------------------------------------------------------------------- -// Helper function: -unsigned int max_num_extensions(); - -// This class can be used for storing pointers to the extension classes, used -// in tlm_generic_payload: -class tlm_extension_base -{ - public: - virtual tlm_extension_base *clone() const = 0; - virtual void free() { delete this; } - virtual void copy_from(tlm_extension_base const &) = 0; - protected: - virtual ~tlm_extension_base() {} - static unsigned int register_extension(const std::type_info &); -}; - -// Base class for all extension classes, derive your extension class in -// the following way: -// class my_extension : public tlm_extension { ... -// This triggers proper extension registration during C++ static -// contruction time. my_extension::ID will hold the unique index in the -// tlm_generic_payload::m_extensions array. -template -class tlm_extension : public tlm_extension_base -{ - public: - virtual tlm_extension_base *clone() const = 0; - virtual void copy_from(tlm_extension_base const &ext) = 0; - virtual ~tlm_extension() {} - const static unsigned int ID; -}; - -template -const unsigned int tlm_extension::ID = - tlm_extension_base::register_extension(typeid(T)); - -//--------------------------------------------------------------------------- -// enumeration types -//--------------------------------------------------------------------------- -enum tlm_command -{ - TLM_READ_COMMAND, - TLM_WRITE_COMMAND, - TLM_IGNORE_COMMAND -}; - -enum tlm_response_status -{ - TLM_OK_RESPONSE = 1, - TLM_INCOMPLETE_RESPONSE = 0, - TLM_GENERIC_ERROR_RESPONSE = -1, - TLM_ADDRESS_ERROR_RESPONSE = -2, - TLM_COMMAND_ERROR_RESPONSE = -3, - TLM_BURST_ERROR_RESPONSE = -4, - TLM_BYTE_ENABLE_ERROR_RESPONSE = -5 -}; - -enum tlm_gp_option -{ - TLM_MIN_PAYLOAD, - TLM_FULL_PAYLOAD, - TLM_FULL_PAYLOAD_ACCEPTED -}; - -#define TLM_BYTE_DISABLED 0x0 -#define TLM_BYTE_ENABLED 0xff - -//--------------------------------------------------------------------------- -// The generic payload class: -//--------------------------------------------------------------------------- - -extern template class tlm_array; - -class tlm_generic_payload -{ - public: - tlm_generic_payload(); - explicit tlm_generic_payload(tlm_mm_interface *mm); - - void - acquire() - { - sc_assert(m_mm != 0); - m_ref_count++; - } - - void - release() - { - sc_assert(m_mm != 0 && m_ref_count > 0); - if (--m_ref_count == 0) - m_mm->free(this); - } - - int get_ref_count() const { return m_ref_count; } - - void set_mm(tlm_mm_interface *mm) { m_mm = mm; } - bool has_mm() const { return m_mm != 0; } - - void reset(); - - private: - // Disabled copy ctor and assignment operator. - tlm_generic_payload(const tlm_generic_payload &x); - tlm_generic_payload &operator = (const tlm_generic_payload &x); - - public: - // Non-virtual deep-copying of the object. - void deep_copy_from(const tlm_generic_payload &other); - - // To update the state of the original generic payload from a deep copy. - // Assumes that "other" was created from the original by calling - // deep_copy_from Argument use_byte_enable_on_read determines whether to - // use or ignores byte enables when copying back the data array on a read - // command. - - void update_original_from(const tlm_generic_payload &other, - bool use_byte_enable_on_read=true); - - void update_extensions_from(const tlm_generic_payload &other); - - // Free all extensions. Useful when reusing a cloned transaction that - // doesn't have memory manager. Normal and sticky extensions are freed and - // extension array cleared. - void free_all_extensions(); - - virtual ~tlm_generic_payload(); - - //---------------- - // API (including setters & getters). - //--------------- - - // Command related method. - bool is_read() const { return (m_command == TLM_READ_COMMAND); } - void set_read() { m_command = TLM_READ_COMMAND; } - bool is_write() const { return (m_command == TLM_WRITE_COMMAND); } - void set_write() { m_command = TLM_WRITE_COMMAND; } - tlm_command get_command() const { return m_command; } - void set_command(const tlm_command command) { m_command = command; } - - // Address related methods. - sc_dt::uint64 get_address() const { return m_address; } - void set_address(const sc_dt::uint64 address) { m_address = address; } - - // Data related methods. - unsigned char *get_data_ptr() const { return m_data; } - void set_data_ptr(unsigned char *data) { m_data = data; } - - // Transaction length (in bytes) related methods. - unsigned int get_data_length() const { return m_length; } - void set_data_length(const unsigned int length) { m_length = length; } - - // Response status related methods. - bool is_response_ok() const { return (m_response_status > 0); } - bool is_response_error() const { return (m_response_status <= 0); } - tlm_response_status - get_response_status() const - { - return m_response_status; - } - void - set_response_status(const tlm_response_status response_status) - { - m_response_status = response_status; - } - std::string get_response_string() const; - - // Streaming related methods. - unsigned int get_streaming_width() const { return m_streaming_width; } - void - set_streaming_width(const unsigned int streaming_width) - { - m_streaming_width = streaming_width; - } - - // Byte enable related methods. - unsigned char *get_byte_enable_ptr() const { return m_byte_enable; } - void - set_byte_enable_ptr(unsigned char *byte_enable) - { - m_byte_enable = byte_enable; - } - unsigned int - get_byte_enable_length() const - { - return m_byte_enable_length; - } - void - set_byte_enable_length(const unsigned int byte_enable_length) - { - m_byte_enable_length = byte_enable_length; - } - - // This is the "DMI-hint" a slave can set this to true if it - // wants to indicate that a DMI request would be supported: - void - set_dmi_allowed(bool dmi_allowed) - { - m_dmi = dmi_allowed; - } - bool - is_dmi_allowed() const - { - return m_dmi; - } - - // Use full set of attributes in DMI/debug? - tlm_gp_option get_gp_option() const { return m_gp_option; } - void set_gp_option(const tlm_gp_option gp_opt) { m_gp_option = gp_opt; } - - private: - /* --------------------------------------------------------------------- */ - /* Generic Payload attributes: */ - /* --------------------------------------------------------------------- */ - /* - m_command : Type of transaction. Three values supported: */ - /* - TLM_WRITE_COMMAND */ - /* - TLM_READ_COMMAND */ - /* - TLM_IGNORE_COMMAND */ - /* - m_address : Transaction base address (byte-addressing). */ - /* - m_data : When m_command = TLM_WRITE_COMMAND contains a */ - /* pointer to the data to be written in the target.*/ - /* When m_command = TLM_READ_COMMAND contains a */ - /* pointer where to copy the data read from the */ - /* target. */ - /* - m_length : Total number of bytes of the transaction. */ - /* - m_response_status : This attribute indicates whether an error has */ - /* occurred during the transaction. */ - /* Values supported are: */ - /* - TLM_OK_RESP */ - /* - TLM_INCOMPLETE_RESP */ - /* - TLM_GENERIC_ERROR_RESP */ - /* - TLM_ADDRESS_ERROR_RESP */ - /* - TLM_COMMAND_ERROR_RESP */ - /* - TLM_BURST_ERROR_RESP */ - /* - TLM_BYTE_ENABLE_ERROR_RESP */ - /* */ - /* - m_byte_enable : It can be used to create burst transfers where */ - /* the address increment between each beat is greater */ - /* than the word length of each beat, or to place */ - /* words in selected byte lanes of a bus. */ - /* - m_byte_enable_length : For a read or a write command, the target */ - /* interpret the byte enable length attribute as the */ - /* number of elements in the bytes enable array. */ - /* - m_streaming_width : */ - /* --------------------------------------------------------------------- */ - - sc_dt::uint64 m_address; - tlm_command m_command; - unsigned char *m_data; - unsigned int m_length; - tlm_response_status m_response_status; - bool m_dmi; - unsigned char *m_byte_enable; - unsigned int m_byte_enable_length; - unsigned int m_streaming_width; - tlm_gp_option m_gp_option; - - public: - /* --------------------------------------------------------------------- */ - /* Dynamic extension mechanism: */ - /* --------------------------------------------------------------------- */ - /* The extension mechanism is intended to enable initiator modules to */ - /* optionally and transparently add data fields to the */ - /* tlm_generic_payload. Target modules are free to check for extensions */ - /* and may or may not react to the data in the extension fields. The */ - /* definition of the extensions' semantics is solely in the */ - /* responsibility of the user. */ - /* */ - /* The following rules apply: */ - /* */ - /* - Every extension class must be derived from tlm_extension, e.g.: */ - /* class my_extension : public tlm_extension { ... } */ - /* */ - /* - A tlm_generic_payload object should be constructed after C++ */ - /* static initialization time. This way it is guaranteed that the */ - /* extension array is of sufficient size to hold all possible */ - /* extensions. Alternatively, the initiator module can enforce a valid */ - /* extension array size by calling the resize_extensions() method */ - /* once before the first transaction with the payload object is */ - /* initiated. */ - /* */ - /* - Initiators should use the the set_extension(e) or clear_extension(e)*/ - /* methods for manipulating the extension array. The type of the */ - /* argument must be a pointer to the specific registered extension */ - /* type (my_extension in the above example) and is used to */ - /* automatically locate the appropriate index in the array. */ - /* */ - /* - Targets can check for a specific extension by calling */ - /* get_extension(e). e will point to zero if the extension is not */ - /* present. */ - /* */ - /* --------------------------------------------------------------------- */ - - // Stick the pointer to an extension into the vector, return the - // previous value: - template - T * - set_extension(T *ext) - { - return static_cast(set_extension(T::ID, ext)); - } - - // Non-templatized version with manual index: - tlm_extension_base *set_extension( - unsigned int index, tlm_extension_base *ext); - - // Stick the pointer to an extension into the vector, return the - // previous value and schedule its release. - template - T * - set_auto_extension(T *ext) - { - return static_cast(set_auto_extension(T::ID, ext)); - } - - // Non-templatized version with manual index: - tlm_extension_base *set_auto_extension( - unsigned int index, tlm_extension_base *ext); - - // Check for an extension, ext will point to 0 if not present. - template - void get_extension(T *& ext) const { ext = get_extension(); } - template - T * - get_extension() const - { - return static_cast(get_extension(T::ID)); - } - // Non-templatized version with manual index: - tlm_extension_base *get_extension(unsigned int index) const; - - // This call just removes the extension from the txn but does not - // call free() or tells the MM to do so it return false if there was - // active MM so you are now in an unsafe situation recommended use: - // when 100% sure there is no MM. - template - void clear_extension(const T *ext) { clear_extension(); } - - // This call just removes the extension from the txn but does not - // call free() or tells the MM to do so it return false if there was - // active MM so you are now in an unsafe situation recommended use: when - // 100% sure there is no MM. - template - void clear_extension() { clear_extension(T::ID); } - - // This call removes the extension from the txn and does call free() or - // tells the MM to do so when the txn is finally done recommended use: - // when not sure there is no MM. - template - void release_extension(T *ext) - { - release_extension(); - } - - // This call removes the extension from the txn and does call free() or - // tells the MM to do so when the txn is finally done recommended use: - // when not sure there is no MM - template - void release_extension() - { - release_extension(T::ID); - } - - private: - // Non-templatized version with manual index - void clear_extension(unsigned int index); - // Non-templatized version with manual index - void release_extension(unsigned int index); - - public: - // Make sure the extension array is large enough. Can be called once by - // an initiator module (before issuing the first transaction) to make - // sure that the extension array is of correct size. This is only needed - // if the initiator cannot guarantee that the generic payload object is - // allocated after C++ static construction time. - void resize_extensions(); - - private: - tlm_array m_extensions; - tlm_mm_interface *m_mm; - unsigned int m_ref_count; -}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_GP_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_helpers.h b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_helpers.h deleted file mode 100644 index 74c6d935f..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_helpers.h +++ /dev/null @@ -1,70 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_HELPERS_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_HELPERS_H__ - -namespace tlm -{ - -enum tlm_endianness { TLM_UNKNOWN_ENDIAN, TLM_LITTLE_ENDIAN, TLM_BIG_ENDIAN }; - -inline tlm_endianness -get_host_endianness() -{ - static tlm_endianness host_endianness = TLM_UNKNOWN_ENDIAN; - - if (host_endianness == TLM_UNKNOWN_ENDIAN) { - unsigned int number = 1; - unsigned char *p_msb_or_lsb = (unsigned char *)&number; - host_endianness = (p_msb_or_lsb[0] == 0) ? - TLM_BIG_ENDIAN : TLM_LITTLE_ENDIAN; - } - return host_endianness; -} - -inline bool -host_has_little_endianness() -{ - static tlm_endianness host_endianness = TLM_UNKNOWN_ENDIAN; - static bool host_little_endian = false; - - if (host_endianness == TLM_UNKNOWN_ENDIAN) { - unsigned int number = 1; - unsigned char *p_msb_or_lsb = (unsigned char *)&number; - - host_little_endian = (p_msb_or_lsb[0] == 0) ? false : true; - } - - return host_little_endian; -} - -inline bool -has_host_endianness(tlm_endianness endianness) -{ - if (host_has_little_endianness()) { - return endianness == TLM_LITTLE_ENDIAN; - } else { - return endianness == TLM_BIG_ENDIAN; - } -} - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_HELPERS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.h b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.h deleted file mode 100644 index 767cb886c..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.h +++ /dev/null @@ -1,117 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_PHASE_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_PHASE_H__ - -#include -#include -#include - -#define SC_CONCAT_HELPER_(a, b) SC_CONCAT_HELPER_DEFERRED_(a, b) -#define SC_CONCAT_HELPER_DEFERRED_(a, b) SC_CONCAT_HELPER_MORE_DEFERRED_(a, b) -#define SC_CONCAT_HELPER_MORE_DEFERRED_(a, b) a ## b - -#define SC_STRINGIFY_HELPER_(a) SC_STRINGIFY_HELPER_DEFERRED_(a) -#define SC_STRINGIFY_HELPER_DEFERRED_(a) SC_STRINGIFY_HELPER_MORE_DEFERRED_(a) -#define SC_STRINGIFY_HELPER_MORE_DEFERRED_(a) #a - -namespace tlm -{ - -enum tlm_phase_enum -{ - UNINITIALIZED_PHASE = 0, - BEGIN_REQ = 1, - END_REQ, - BEGIN_RESP, - END_RESP -}; - -class tlm_phase -{ - public: - tlm_phase(); - tlm_phase(unsigned int id); - - tlm_phase(tlm_phase_enum standard); - tlm_phase &operator = (tlm_phase_enum standard); - - operator unsigned int() const { return m_id; } - const char *get_name() const; - - protected: - // Register extended phase. - tlm_phase(const std::type_info &type, const char *name); - - private: - unsigned int m_id; -}; - -inline tlm_phase::tlm_phase() : m_id(UNINITIALIZED_PHASE) {} - -inline tlm_phase::tlm_phase(tlm_phase_enum standard) : m_id(standard) {} - -inline tlm_phase & -tlm_phase::operator = (tlm_phase_enum standard) -{ - m_id = standard; - return *this; -} - -inline std::ostream & -operator << (std::ostream &s, const tlm_phase &p) -{ - s << p.get_name(); - return s; -} - -#define TLM_DECLARE_EXTENDED_PHASE(name_arg) \ -static class SC_CONCAT_HELPER_(tlm_phase_, name_arg) : \ - public ::tlm::tlm_phase \ -{ \ - typedef SC_CONCAT_HELPER_(tlm_phase_, name_arg) this_type; \ - public: \ - SC_CONCAT_HELPER_(tlm_phase_, name_arg)() : \ - /* register extended phase */ \ - ::tlm::tlm_phase(typeid(*this), SC_STRINGIFY_HELPER_(name_arg)) \ - {} \ - \ - static const this_type &get_phase() \ - /* needed only for IEEE 1666-2011 */ \ - { \ - static this_type this_; \ - return this_; \ - } \ -} const name_arg - -// for backwards-compatibility -#define DECLARE_EXTENDED_PHASE(NameArg) TLM_DECLARE_EXTENDED_PHASE(NameArg) - -} // namespace tlm - -#undef SC_CONCAT_HELPER_ -#undef SC_CONCAT_HELPER_DEFERRED_ -#undef SC_CONCAT_HELPER_MORE_DEFERRED_ - -#undef SC_STRINGIFY_HELPER_ -#undef SC_STRINGIFY_HELPER_DEFERRED_ -#undef SC_STRINGIFY_HELPER_MORE_DEFERRED_ - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_PHASE_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.h b/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.h deleted file mode 100644 index 74ae57aa5..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.h +++ /dev/null @@ -1,76 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_QUANTUM_TLM_GLOBAL_QUANTUM_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_QUANTUM_TLM_GLOBAL_QUANTUM_H__ - -#include - -namespace tlm -{ - -// -// tlm_global_quantum class -// -// The global quantum is the maximum time an initiator can run ahead of -// SystemC time. All initiators should synchronize on timingpoints that -// are multiples of the global quantum value. -// -// sc_set_time_resolution can only be called before the first -// sc_time object is created. This means that after setting the -// global quantum it will not be possible to call sc_set_time_resolution. -// If sc_set_time_resolution must be called this must be done before -// the global quantum is set. -// - -class tlm_global_quantum -{ - public: - // - // Returns a reference to the tlm_global_quantum singleton - // - static tlm_global_quantum &instance(); - - public: - - // - // Setter/getter for the global quantum - // - void set(const sc_core::sc_time &t) { m_global_quantum = t; } - const sc_core::sc_time &get() const { return m_global_quantum; } - - // - // This function will calculate the maximum value for the next local - // quantum for an initiator. All initiators should synchronize on - // integer multiples of the global quantum value. The value for the - // local quantum of an initiator can be smaller, but should never be - // greater than the value returned by this method. - // - sc_core::sc_time compute_local_quantum(); - - protected: - tlm_global_quantum(); - - protected: - sc_core::sc_time m_global_quantum; -}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_QUANTUM_TLM_GLOBAL_QUANTUM_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_quantum.h b/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_quantum.h deleted file mode 100644 index dc7fdc296..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_quantum.h +++ /dev/null @@ -1,25 +0,0 @@ -/***************************************************************************** - - 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 ____SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_QUANTUM_TLM_QUANTUM_H__ -#define ____SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_QUANTUM_TLM_QUANTUM_H__ - -#include "tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.h" - -#endif /* ____SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_QUANTUM_TLM_QUANTUM_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_base_socket_if.h b/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_base_socket_if.h deleted file mode 100644 index 5dcd40129..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_base_socket_if.h +++ /dev/null @@ -1,57 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_BASE_SOCKET_IF_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_BASE_SOCKET_IF_H__ - -#include - -namespace tlm -{ - -enum tlm_socket_category -{ - TLM_UNKNOWN_SOCKET = 0, - TLM_INITIATOR_SOCKET = 0x1, - TLM_TARGET_SOCKET = 0x2, - - TLM_MULTI_SOCKET = 0x10, - - TLM_MULTI_INITIATOR_SOCKET = TLM_INITIATOR_SOCKET | TLM_MULTI_SOCKET, - TLM_MULTI_TARGET_SOCKET = TLM_TARGET_SOCKET | TLM_MULTI_SOCKET -}; - -class tlm_base_socket_if -{ - public: - virtual sc_core::sc_port_base &get_port_base() = 0; - virtual sc_core::sc_port_base const &get_port_base() const = 0; - virtual sc_core::sc_export_base &get_export_base() = 0; - virtual sc_core::sc_export_base const &get_export_base() const = 0; - virtual unsigned int get_bus_width() const = 0; - virtual sc_core::sc_type_index get_protocol_types() const = 0; - virtual tlm_socket_category get_socket_category() const = 0; - - protected: - virtual ~tlm_base_socket_if() {} -}; - -} // namespace tlm - -#endif // __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_BASE_SOCKET_IF_H__ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h b/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h deleted file mode 100644 index 93ed2fddb..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h +++ /dev/null @@ -1,204 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_INITIATOR_SOCKET_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_INITIATOR_SOCKET_H__ - -#include "tlm_core/tlm_2/tlm_sockets/tlm_base_socket_if.h" -#include "tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h" - -namespace tlm -{ - -template , - typename BW_IF=tlm_bw_transport_if<>> -class tlm_base_initiator_socket_b -{ - public: - virtual ~tlm_base_initiator_socket_b() {} - - virtual sc_core::sc_port_b &get_base_port() = 0; - virtual sc_core::sc_port_b const &get_base_port() const = 0; - virtual BW_IF &get_base_interface() = 0; - virtual BW_IF const &get_base_interface() const = 0; - virtual sc_core::sc_export &get_base_export() = 0; - virtual sc_core::sc_export const &get_base_export() const = 0; -}; - -template -class tlm_base_target_socket_b; - -template -class tlm_base_target_socket; - -template , - typename BW_IF=tlm_bw_transport_if<>, int N=1, - sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> -class tlm_base_initiator_socket : - public tlm_base_socket_if, - public tlm_base_initiator_socket_b, - public sc_core::sc_port -{ - public: - typedef FW_IF fw_interface_type; - typedef BW_IF bw_interface_type; - typedef sc_core::sc_port port_type; - - typedef sc_core::sc_export export_type; - - typedef tlm_base_target_socket_b< - BUSWIDTH, fw_interface_type, bw_interface_type> - base_target_socket_type; - typedef tlm_base_initiator_socket_b< - BUSWIDTH, fw_interface_type, bw_interface_type> base_type; - - template - friend class tlm_base_target_socket; - - public: - tlm_base_initiator_socket() : - port_type(sc_core::sc_gen_unique_name("tlm_base_initiator_socket")), - m_export(sc_core::sc_gen_unique_name( - "tlm_base_initiator_socket_export")) - {} - - explicit tlm_base_initiator_socket(const char *name) : port_type(name), - m_export(sc_core::sc_gen_unique_name( - (std::string(name) + "_export").c_str())) - {} - - virtual const char* kind() const { return "tlm_base_initiator_socket"; } - - // - // Bind initiator socket to target socket - // - Binds the port of the initiator socket to the export of the target - // socket - // - Binds the port of the target socket to the export of the initiator - // socket - // - virtual void - bind(base_target_socket_type &s) - { - // initiator.port -> target.export - (get_base_port())(s.get_base_interface()); - // target.port -> initiator.export - (s.get_base_port())(get_base_interface()); - } - - void operator () (base_target_socket_type &s) { bind(s); } - - // - // Bind initiator socket to initiator socket (hierarchical bind) - // - Binds both the export and the port - // - virtual void - bind(base_type &s) - { - // port - (get_base_port())(s.get_base_port()); - // export - (s.get_base_export())(get_base_export()); - } - - void operator() (base_type &s) { bind(s); } - - // - // Bind interface to socket - // - Binds the interface to the export of this socket - // - virtual void bind(bw_interface_type &ifs) { (get_base_export())(ifs); } - void operator() (bw_interface_type &s) { bind(s); } - - // Implementation of tlm_base_socket_if functions - virtual sc_core::sc_port_base &get_port_base() { return *this; } - virtual sc_core::sc_port_base const & - get_port_base() const - { - return *this; - } - virtual sc_core::sc_export_base &get_export_base() { return m_export; } - virtual sc_core::sc_export_base const & - get_export_base() const - { - return m_export; - } - virtual unsigned int get_bus_width() const { return BUSWIDTH; } - virtual tlm_socket_category - get_socket_category() const - { - return TLM_INITIATOR_SOCKET; - } - - // Implementation of tlm_base_target_socket_b functions - virtual sc_core::sc_port_b &get_base_port() { return *this; } - virtual sc_core::sc_port_b const & - get_base_port() const - { - return *this; - } - - virtual BW_IF &get_base_interface() { return m_export; } - virtual BW_IF const &get_base_interface() const { return m_export; } - - virtual sc_core::sc_export &get_base_export() { return m_export; } - virtual sc_core::sc_export const & - get_base_export() const - { - return m_export; - } - - protected: - export_type m_export; -}; - -// -// Convenience socket classes -// - -template -class tlm_initiator_socket : public tlm_base_initiator_socket< - BUSWIDTH, tlm_fw_transport_if, - tlm_bw_transport_if, N, POL> -{ - public: - tlm_initiator_socket() : tlm_base_initiator_socket< - BUSWIDTH, tlm_fw_transport_if, - tlm_bw_transport_if, N, POL>() - {} - - explicit tlm_initiator_socket(const char *name) : - tlm_base_initiator_socket, - tlm_bw_transport_if, N, POL>(name) - {} - - virtual const char *kind() const { return "tlm_initiator_socket"; } - - virtual sc_core::sc_type_index - get_protocol_types() const - { - return typeid(TYPES); - } -}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_INITIATOR_SOCKET_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_sockets.h b/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_sockets.h deleted file mode 100644 index 75697292b..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_sockets.h +++ /dev/null @@ -1,26 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_SOCKETS_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_SOCKETS_H__ - -#include "tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h" -#include "tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h" - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_SOCKETS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h b/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h deleted file mode 100644 index ba0fcc207..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h +++ /dev/null @@ -1,223 +0,0 @@ -/***************************************************************************** - - 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 __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_TARGET_SOCKET_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_TARGET_SOCKET_H__ - -#include "tlm_core/tlm_2/tlm_sockets/tlm_base_socket_if.h" -#include "tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h" - -namespace tlm -{ - -template , - typename BW_IF=tlm_bw_transport_if<>> -class tlm_base_target_socket_b -{ - public: - virtual ~tlm_base_target_socket_b() {} - - virtual sc_core::sc_port_b &get_base_port() = 0; - virtual sc_core::sc_export &get_base_export() = 0; - virtual FW_IF &get_base_interface() = 0; -}; - -template -class tlm_base_initiator_socket_b; - -template -class tlm_base_initiator_socket; - -template , - typename BW_IF=tlm_bw_transport_if<>, int N=1, - sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> -class tlm_base_target_socket : - public tlm_base_socket_if, - public tlm_base_target_socket_b, - public sc_core::sc_export -{ - public: - typedef FW_IF fw_interface_type; - typedef BW_IF bw_interface_type; - typedef sc_core::sc_port port_type; - - typedef sc_core::sc_export export_type; - typedef tlm_base_initiator_socket_b< - BUSWIDTH, fw_interface_type, bw_interface_type> - base_initiator_socket_type; - - typedef tlm_base_target_socket_b< - BUSWIDTH, fw_interface_type, bw_interface_type> base_type; - - template - friend class tlm_base_initiator_socket; - - public: - tlm_base_target_socket() : - export_type(sc_core::sc_gen_unique_name("tlm_base_target_socket")), - m_port(sc_core::sc_gen_unique_name("tlm_base_target_socket_port")) - {} - - explicit tlm_base_target_socket(const char *name) : - export_type(name), m_port(sc_core::sc_gen_unique_name( - (std::string(name) + "_port").c_str())) - {} - - virtual const char *kind() const { return "tlm_base_target_socket"; } - - // - // Bind target socket to initiator socket - // - Binds the port of the initiator socket to the export of the target - // socket - // - Binds the port of the target socket to the export of the initiator - // socket - // - virtual void - bind(base_initiator_socket_type &s) - { - // initiator.port -> target.export - (s.get_base_port())(get_base_interface()); - // target.port -> initiator.export - get_base_port()(s.get_base_interface()); - } - - void operator () (base_initiator_socket_type &s) { bind(s); } - - // - // Bind target socket to target socket (hierarchical bind) - // - Binds both the export and the port - // - virtual void - bind(base_type &s) - { - // export - (get_base_export())(s.get_base_export()); - // port - (s.get_base_port())(get_base_port()); - } - - void operator () (base_type &s) { bind(s); } - - // - // Bind interface to socket - // - Binds the interface to the export - // - virtual void - bind(fw_interface_type &ifs) - { - export_type *exp = &get_base_export(); - if (this == exp) { - export_type::bind(ifs); - } else { - exp->bind( ifs ); - } - } - - void operator () (fw_interface_type &s) { bind(s); } - - // - // Forward to 'size()' of port class. - // - int size() const { return m_port.size(); } - - // - // Forward to 'operator->()' of port class. - // - bw_interface_type *operator->() { return m_port.operator->(); } - - // - // Forward to 'operator[]()' of port class. - // - bw_interface_type *operator[](int i) { return m_port.operator[](i); } - - // Implementation of tlm_base_socket_if functions. - virtual sc_core::sc_port_base &get_port_base() { return m_port; } - virtual sc_core::sc_port_base const & - get_port_base() const - { - return m_port; - } - virtual sc_core::sc_export_base &get_export_base() { return *this; } - virtual sc_core::sc_export_base const & - get_export_base() const - { - return *this; - } - virtual unsigned int get_bus_width() const { return BUSWIDTH; } - virtual tlm_socket_category - get_socket_category() const - { - return TLM_TARGET_SOCKET; - } - - // Implementation of tlm_base_target_socket_b functions - virtual sc_core::sc_port_b &get_base_port() { return m_port; } - virtual sc_core::sc_port_b const & - get_base_port() const - { - return m_port; - } - - virtual FW_IF &get_base_interface() { return *this; } - virtual FW_IF const &get_base_interface() const { return *this; } - - virtual sc_core::sc_export &get_base_export() { return *this; } - virtual sc_core::sc_export const & - get_base_export() const - { - return *this; - } - - protected: - port_type m_port; -}; - -template -class tlm_target_socket : - public tlm_base_target_socket< - BUSWIDTH, tlm_fw_transport_if, - tlm_bw_transport_if, N, POL> -{ - public: - tlm_target_socket() : - tlm_base_target_socket< - BUSWIDTH, tlm_fw_transport_if, - tlm_bw_transport_if, N, POL>() - {} - - explicit tlm_target_socket(const char *name) : - tlm_base_target_socket< - BUSWIDTH, tlm_fw_transport_if, - tlm_bw_transport_if, N, POL>(name) - {} - - virtual const char* kind() const { return "tlm_target_socket"; } - - virtual sc_core::sc_type_index - get_protocol_types() const - { - return typeid(TYPES); - } -}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_TARGET_SOCKET_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_version.h b/src/systemc/ext/tlm_core/tlm_2/tlm_version.h deleted file mode 100644 index 36c36debe..000000000 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_version.h +++ /dev/null @@ -1,155 +0,0 @@ -/***************************************************************************** - - 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. - - *****************************************************************************/ - -/* --------------------------------------------------------------------------- - Original Author: - Charles Wilson, XtremeEDA Corporation - - @description - This header contains preprocessor and compiler symbols to allow for the - determination of the TLM version information. This conforms to - IEEE 1666-2005 section 8.5.5 - 8.5.7 - The following are provided: - - preprocessor: TLM_VERSION_MAJOR numeric - TLM_VERSION_MINOR numeric - TLM_VERSION_PATCH numeric - TLM_VERSION_ORIGINATOR string ([A-Z][a-z][0-9]_) - TLM_VERSION_RELEASE_DATE ISO8601 date (YYYYMMDD) - TLM_VERSION_PRERELEASE string ([A-Z][a-z][0-9]_) - TLM_IS_PRERELEASE bool (1,0) - TLM_VERSION string {2.0.0_DR3-TLMWG} - TLM_COPYRIGHT string - - compiler: tlm_version_major const unsigned int - tlm_version_minor const unsigned int - tlm_version_patch const unsigned int - tlm_version_originator const std::string - tlm_version_release_date const std::string - tlm_version_prerelease const std::string - tlm_is_prerelease const bool - tlm_version const string - tlm_copyright const string - - accessors: inline const char* tlm_release (void) - inline const char* tlm_version (void) - inline const char* tlm_copyright (void) ---------------------------------------------------------------------------- */ - -#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_VERSION_H__ -#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_VERSION_H__ - -namespace tlm -{ - -#define TLM_VERSION_MAJOR 2 ///< version major level ( numeric ) -#define TLM_VERSION_MINOR 0 ///< version minor level ( numeric ) -#define TLM_VERSION_PATCH 4 ///< version patch level ( numeric ) -#define TLM_VERSION_ORIGINATOR "Accellera" ///< TLM creator string -#define TLM_VERSION_SEPARATOR "." ///< version string separator - -#define TLM_IS_PRERELEASE 0 ///< pre-release flag (1/0) - -#if TLM_IS_PRERELEASE -# define TLM_VERSION_PRERELEASE "pub_rev" ///< pre-release version string -#else -# define TLM_VERSION_PRERELEASE "" ///< pre-release version string -#endif - -#define TLM_VERSION_RELEASE_YEAR "2017" ///< release year ( YYYY ) -#define TLM_VERSION_RELEASE_MONTH "10" ///< release month ( MM ) -#define TLM_VERSION_RELEASE_DAY "12" ///< release day ( DD ) - -#define TLM_COPYRIGHT \ - "Copyright (c) 1996-" TLM_VERSION_RELEASE_YEAR " by all Contributors\n" \ - "ALL RIGHTS RESERVED" - -/******************** do not modify below this line *************************/ - -/************************* preprocessor symbols *****************************/ - -#define TLM_VERSION_RELEASE_DATE TLM_VERSION_RELEASE_YEAR \ - TLM_VERSION_RELEASE_MONTH \ - TLM_VERSION_RELEASE_DAY - -#define TLM_VERSION_STR(x) TLM_VERSION_STR_HELPER(x) -#define TLM_VERSION_STR_HELPER(x) #x - -#define TLM_VERSION_STRING_MAJOR TLM_VERSION_STR(TLM_VERSION_MAJOR) -#define TLM_VERSION_STRING_MINOR TLM_VERSION_STR(TLM_VERSION_MINOR) -#define TLM_VERSION_STRING_PATCH TLM_VERSION_STR(TLM_VERSION_PATCH) - -#define TLM_VERSION_STRING_MMP TLM_VERSION_STRING_MAJOR TLM_VERSION_SEPARATOR \ - TLM_VERSION_STRING_MINOR TLM_VERSION_SEPARATOR \ - TLM_VERSION_STRING_PATCH - -#define TLM_VERSION_STRING_PRE_START "_" -#define TLM_VERSION_STRING_PRE_END "-" - -#if (TLM_IS_PRERELEASE == 1) - -# define TLM_VERSION_STRING_PRERELEASE TLM_VERSION_PRERELEASE -# define TLM_VERSION_STRING_RELEASE_DATE "" - -#else /* TLM_IS_PRERELEASE == 1 */ - -# define TLM_VERSION_STRING_PRERELEASE "" -# define TLM_VERSION_STRING_RELEASE_DATE TLM_VERSION_RELEASE_DATE - -#endif /* TLM_IS_PRERELEASE == 1 */ - -#define TLM_VERSION_STRING TLM_VERSION_STRING_MMP \ - TLM_VERSION_STRING_PRE_START \ - TLM_VERSION_STRING_PRERELEASE \ - TLM_VERSION_STRING_PRE_END \ - TLM_VERSION_ORIGINATOR - -#define TLM_VERSION_STRING_2 "TLM " \ - TLM_VERSION_STRING_MMP \ - " --- " \ - TLM_VERSION_RELEASE_YEAR \ - "-" \ - TLM_VERSION_RELEASE_MONTH \ - "-" \ - TLM_VERSION_RELEASE_DAY - -#define TLM_VERSION TLM_VERSION_STRING - -/*************************** compiler symbols ********************************/ - -const unsigned int tlm_version_major(TLM_VERSION_MAJOR); -const unsigned int tlm_version_minor(TLM_VERSION_MINOR); -const unsigned int tlm_version_patch(TLM_VERSION_PATCH); - -const bool tlm_is_prerelease(TLM_IS_PRERELEASE); - -const std::string tlm_version_string(TLM_VERSION_STRING); -const std::string tlm_version_originator(TLM_VERSION_ORIGINATOR); -const std::string tlm_version_prerelease(TLM_VERSION_PRERELEASE); -const std::string tlm_version_release_date(TLM_VERSION_STRING_RELEASE_DATE); -const std::string tlm_copyright_string(TLM_COPYRIGHT); -const std::string tlm_version_string_2(TLM_VERSION_STRING_2); - -inline const char *tlm_release() { return tlm_version_string.c_str(); } -inline const char *tlm_version() { return tlm_version_string_2.c_str(); } -inline const char *tlm_copyright() { return tlm_copyright_string.c_str(); } - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_VERSION_H__ */ diff --git a/src/systemc/ext/tlm_utils/tlm_quantumkeeper.h b/src/systemc/ext/tlm_utils/tlm_quantumkeeper.h index 6403fd8a4..bad46ad11 100644 --- a/src/systemc/ext/tlm_utils/tlm_quantumkeeper.h +++ b/src/systemc/ext/tlm_utils/tlm_quantumkeeper.h @@ -20,7 +20,7 @@ #ifndef __SYSTEMC_EXT_TLM_UTILS_TLM_QUANTUMKEEPER_H__ #define __SYSTEMC_EXT_TLM_UTILS_TLM_QUANTUMKEEPER_H__ -#include "tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.h" +#include namespace tlm_utils { diff --git a/src/systemc/tlm_core/2/generic_payload/SConscript b/src/systemc/tlm_core/2/generic_payload/SConscript new file mode 100644 index 000000000..bea993450 --- /dev/null +++ b/src/systemc/tlm_core/2/generic_payload/SConscript @@ -0,0 +1,32 @@ +# Copyright 2018 Google, Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Authors: Gabe Black + +Import('*') + +if env['USE_SYSTEMC']: + Source('gp.cc') + Source('phase.cc') diff --git a/src/systemc/tlm_core/2/generic_payload/gp.cc b/src/systemc/tlm_core/2/generic_payload/gp.cc new file mode 100644 index 000000000..ff3c92bd9 --- /dev/null +++ b/src/systemc/tlm_core/2/generic_payload/gp.cc @@ -0,0 +1,355 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +#include // std::memcpy et.al. +#include +#include +#include + +using sc_core::sc_type_index; + +namespace tlm +{ + +template class tlm_array; + +//--------------------------------------------------------------------------- +// Classes for the extension mechanism +//--------------------------------------------------------------------------- + +namespace +{ + +class tlm_extension_registry +{ + typedef unsigned int key_type; + typedef std::map type_map; + public: + static tlm_extension_registry & + instance() + { + if (!instance_) { + // Don't cleanup registry. + instance_ = new tlm_extension_registry(); + } + return *instance_; + } + + unsigned int + register_extension(sc_type_index type) + { + type_map::const_iterator it = ids_.find(type); + + if (it == ids_.end()) { + // New extension - generate/store ID. + type_map::value_type v(type, static_cast(ids_.size())); + ids_.insert(v); + return v.second; + } + return it->second; + } + + static unsigned int + max_num_extensions() + { + return (instance_) ? instance().ids_.size() : 0; + } + + private: + static tlm_extension_registry *instance_; + type_map ids_; + tlm_extension_registry() {} + +}; + +tlm_extension_registry *tlm_extension_registry::instance_ = NULL; + +} // anonymous namespace + +unsigned int +max_num_extensions() +{ + return tlm_extension_registry::max_num_extensions(); +} + +unsigned int +tlm_extension_base::register_extension(const std::type_info &type) +{ + return tlm_extension_registry::instance().register_extension(type); +} + +//--------------------------------------------------------------------------- +// The generic payload class: +//--------------------------------------------------------------------------- + +tlm_generic_payload::tlm_generic_payload() : m_address(0), + m_command(TLM_IGNORE_COMMAND), m_data(0), m_length(0), + m_response_status(TLM_INCOMPLETE_RESPONSE), m_dmi(false), m_byte_enable(0), + m_byte_enable_length(0), m_streaming_width(0), + m_gp_option(TLM_MIN_PAYLOAD), m_extensions(max_num_extensions()), m_mm(0), + m_ref_count(0) +{} + +tlm_generic_payload::tlm_generic_payload(tlm_mm_interface *mm): m_address(0), + m_command(TLM_IGNORE_COMMAND), m_data(0), m_length(0), + m_response_status(TLM_INCOMPLETE_RESPONSE), m_dmi(false), m_byte_enable(0), + m_byte_enable_length(0), m_streaming_width(0), + m_gp_option(TLM_MIN_PAYLOAD), m_extensions(max_num_extensions()), m_mm(mm), + m_ref_count(0) +{} + +void +tlm_generic_payload::reset() +{ + // Should the other members be reset too? + m_gp_option = TLM_MIN_PAYLOAD; + m_extensions.free_entire_cache(); +}; + +// Non-virtual deep-copying of the object. +void +tlm_generic_payload::deep_copy_from(const tlm_generic_payload &other) +{ + m_command = other.get_command(); + m_address = other.get_address(); + m_length = other.get_data_length(); + m_response_status = other.get_response_status(); + m_byte_enable_length = other.get_byte_enable_length(); + m_streaming_width = other.get_streaming_width(); + m_gp_option = other.get_gp_option(); + m_dmi = other.is_dmi_allowed(); + + // Deep copy data. + // There must be enough space in the target transaction! + if (m_data && other.m_data) { + std::memcpy(m_data, other.m_data, m_length); + } + // Deep copy byte enables. + // There must be enough space in the target transaction! + if (m_byte_enable && other.m_byte_enable) { + std::memcpy(m_byte_enable, other.m_byte_enable, m_byte_enable_length); + } + // Deep copy extensions (sticky and non-sticky). + if (m_extensions.size() < other.m_extensions.size()) { + m_extensions.expand(other.m_extensions.size()); + } + for (unsigned int i = 0; i < other.m_extensions.size(); i++) { + if (other.m_extensions[i]) { + // Original has extension i. + if (!m_extensions[i]) { + // We don't: clone. + tlm_extension_base *ext = other.m_extensions[i]->clone(); + if (ext) { // Extension may not be clonable. + if (has_mm()) { + // mm can take care of removing cloned extensions. + set_auto_extension(i, ext); + } else { + // no mm, user will call free_all_extensions(). + set_extension(i, ext); + } + } + } else { + // We already have such extension. Copy original over it. + m_extensions[i]->copy_from(*other.m_extensions[i]); + } + } + } +} + +// To update the state of the original generic payload from a deep copy. +// Assumes that "other" was created from the original by calling +// deep_copy_from. Argument use_byte_enable_on_read determines whether to use +// or ignores byte enables when copying back the data array on a read command. + +void +tlm_generic_payload::update_original_from( + const tlm_generic_payload &other, bool use_byte_enable_on_read) +{ + // Copy back extensions that are present on the original. + update_extensions_from(other); + + // Copy back the response status and DMI hint attributes. + m_response_status = other.get_response_status(); + m_dmi = other.is_dmi_allowed(); + + // Copy back the data array for a read command only deep_copy_from allowed + // null pointers, and so will we. + // We assume the arrays are the same size. + // We test for equal pointers in case the original and the copy share the + // same array. + + if (is_read() && m_data && other.m_data && m_data != other.m_data) { + if (m_byte_enable && use_byte_enable_on_read) { + if (m_byte_enable_length == 8 && m_length % 8 == 0) { + // Optimized implementation copies 64-bit words by masking. + for (unsigned int i = 0; i < m_length; i += 8) { + typedef sc_dt::uint64 *u; + *reinterpret_cast(&m_data[i]) &= + ~*reinterpret_cast(m_byte_enable); + *reinterpret_cast(&m_data[i]) |= + *reinterpret_cast(&other.m_data[i]) & + *reinterpret_cast(m_byte_enable); + } + } else if (m_byte_enable_length == 4 && m_length % 4 == 0) { + // Optimized implementation copies 32-bit words by masking. + for (unsigned int i = 0; i < m_length; i += 4) { + typedef unsigned int *u; + *reinterpret_cast(&m_data[i]) &= + ~*reinterpret_cast(m_byte_enable); + *reinterpret_cast(&m_data[i]) |= + *reinterpret_cast(&other.m_data[i]) & + *reinterpret_cast(m_byte_enable); + } + } else { + // Unoptimized implementation. + for (unsigned int i = 0; i < m_length; i++) { + if (m_byte_enable[i % m_byte_enable_length]) + m_data[i] = other.m_data[i]; + } + } + } else { + std::memcpy(m_data, other.m_data, m_length); + } + } +} + +void +tlm_generic_payload::update_extensions_from(const tlm_generic_payload &other) +{ + // Deep copy extensions that are already present. + sc_assert(m_extensions.size() <= other.m_extensions.size()); + for (unsigned int i = 0; i < m_extensions.size(); i++) { + if (other.m_extensions[i]) { + // Original has extension i. + if (m_extensions[i]) { + // We have it too. Copy. + m_extensions[i]->copy_from(*other.m_extensions[i]); + } + } + } +} + +// Free all extensions. Useful when reusing a cloned transaction that doesn't +// have memory manager. Normal and sticky extensions are freed and extension +// array cleared. +void +tlm_generic_payload::free_all_extensions() +{ + m_extensions.free_entire_cache(); + for (unsigned int i = 0; i < m_extensions.size(); i++) { + if (m_extensions[i]) { + m_extensions[i]->free(); + m_extensions[i] = 0; + } + } +} + +tlm_generic_payload::~tlm_generic_payload() +{ + for (unsigned int i = 0; i < m_extensions.size(); i++) { + if (m_extensions[i]) + m_extensions[i]->free(); + } +} + +//---------------- +// API (including setters & getters) +//--------------- + +std::string +tlm_generic_payload::get_response_string() const +{ + switch (m_response_status) { + case TLM_OK_RESPONSE: + return "TLM_OK_RESPONSE"; + case TLM_INCOMPLETE_RESPONSE: + return "TLM_INCOMPLETE_RESPONSE"; + case TLM_GENERIC_ERROR_RESPONSE: + return "TLM_GENERIC_ERROR_RESPONSE"; + case TLM_ADDRESS_ERROR_RESPONSE: + return "TLM_ADDRESS_ERROR_RESPONSE"; + case TLM_COMMAND_ERROR_RESPONSE: + return "TLM_COMMAND_ERROR_RESPONSE"; + case TLM_BURST_ERROR_RESPONSE: + return "TLM_BURST_ERROR_RESPONSE"; + case TLM_BYTE_ENABLE_ERROR_RESPONSE: + return "TLM_BYTE_ENABLE_ERROR_RESPONSE"; + } + return "TLM_UNKNOWN_RESPONSE"; +} + +/* --------------------------------------------------------------------- */ +/* Dynamic extension mechanism: */ +/* --------------------------------------------------------------------- */ + +tlm_extension_base * +tlm_generic_payload::set_extension(unsigned int index, tlm_extension_base *ext) +{ + sc_assert(index < m_extensions.size()); + tlm_extension_base *tmp = m_extensions[index]; + m_extensions[index] = ext; + return tmp; +} + +tlm_extension_base * +tlm_generic_payload::set_auto_extension( + unsigned int index, tlm_extension_base *ext) +{ + sc_assert(index < m_extensions.size()); + tlm_extension_base *tmp = m_extensions[index]; + m_extensions[index] = ext; + if (!tmp) + m_extensions.insert_in_cache(&m_extensions[index]); + sc_assert(m_mm != 0); + return tmp; +} + +tlm_extension_base * +tlm_generic_payload::get_extension(unsigned int index) const +{ + sc_assert(index < m_extensions.size()); + return m_extensions[index]; +} + +void +tlm_generic_payload::clear_extension(unsigned int index) +{ + sc_assert(index < m_extensions.size()); + m_extensions[index] = static_cast(0); +} + +void +tlm_generic_payload::release_extension(unsigned int index) +{ + sc_assert(index < m_extensions.size()); + if (m_mm) { + m_extensions.insert_in_cache(&m_extensions[index]); + } else { + m_extensions[index]->free(); + m_extensions[index] = static_cast(nullptr); + } +} + +void +tlm_generic_payload::resize_extensions() +{ + m_extensions.expand(max_num_extensions()); +} + +} // namespace tlm diff --git a/src/systemc/tlm_core/2/generic_payload/phase.cc b/src/systemc/tlm_core/2/generic_payload/phase.cc new file mode 100644 index 000000000..2c8b1e1a0 --- /dev/null +++ b/src/systemc/tlm_core/2/generic_payload/phase.cc @@ -0,0 +1,111 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +#include +#include +#include +#include + +using sc_core::sc_string_view; +using sc_core::sc_type_index; + +namespace tlm +{ + +namespace +{ + +struct tlm_phase_registry +{ + typedef unsigned int key_type; + + static tlm_phase_registry & + instance() + { + static tlm_phase_registry inst; + return inst; + } + + unsigned int + register_phase(sc_type_index type, sc_string_view name) + { + type_map::const_iterator it = ids_.find(type); + + if (name.empty()) { + SC_REPORT_FATAL( sc_core::SC_ID_INTERNAL_ERROR_, + "unexpected empty tlm_phase name" ); + return UNINITIALIZED_PHASE; + } + + if (it == ids_.end()) { + // new phase - generate/store ID and name + type_map::value_type v(type, static_cast(names_.size())); + names_.push_back(name_table::value_type(name.data(), name.size())); + ids_.insert(v); + return v.second; + } + + if (names_[it->second] != name) { + SC_REPORT_FATAL(sc_core::SC_ID_INTERNAL_ERROR_, + "tlm_phase registration failed: duplicate type info" ); + sc_core::sc_abort(); + } + return it->second; + } + + const char * + get_name(key_type id) const + { + sc_assert(id < names_.size()); + return names_[id].c_str(); + } + + private: + typedef std::map type_map; + typedef std::vector name_table; + + type_map ids_; + name_table names_; + + tlm_phase_registry() : names_(END_RESP + 1) + { + names_[UNINITIALIZED_PHASE] = "UNINITIALIZED_PHASE"; + names_[BEGIN_REQ] = "BEGIN_REQ"; + names_[END_REQ] = "END_REQ"; + names_[BEGIN_RESP] = "BEGIN_RESP"; + names_[END_RESP] = "END_RESP"; + } +}; + +} // anonymous namespace + +tlm_phase::tlm_phase(unsigned int id) : m_id(id) +{} + +tlm_phase::tlm_phase(const std::type_info &type, const char *name) : + m_id(tlm_phase_registry::instance().register_phase(type, name)) +{} + +const char * +tlm_phase::get_name() const +{ + return tlm_phase_registry::instance().get_name(m_id); +} + +} // namespace tlm diff --git a/src/systemc/tlm_core/2/quantum/SConscript b/src/systemc/tlm_core/2/quantum/SConscript new file mode 100644 index 000000000..a1580471f --- /dev/null +++ b/src/systemc/tlm_core/2/quantum/SConscript @@ -0,0 +1,31 @@ +# Copyright 2018 Google, Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Authors: Gabe Black + +Import('*') + +if env['USE_SYSTEMC']: + Source('global_quantum.cc') diff --git a/src/systemc/tlm_core/2/quantum/global_quantum.cc b/src/systemc/tlm_core/2/quantum/global_quantum.cc new file mode 100644 index 000000000..7ba44e3cb --- /dev/null +++ b/src/systemc/tlm_core/2/quantum/global_quantum.cc @@ -0,0 +1,49 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +#include +#include + +namespace tlm +{ + +tlm_global_quantum::tlm_global_quantum() : + m_global_quantum(sc_core::SC_ZERO_TIME) +{} + +tlm_global_quantum & +tlm_global_quantum::instance() +{ + static tlm_global_quantum instance_; + return instance_; +} + +sc_core::sc_time +tlm_global_quantum::compute_local_quantum() +{ + if (m_global_quantum != sc_core::SC_ZERO_TIME) { + const sc_core::sc_time current = sc_core::sc_time_stamp(); + const sc_core::sc_time g_quant = m_global_quantum; + return g_quant - (current % g_quant); + } else { + return sc_core::SC_ZERO_TIME; + } +} + +} // namespace tlm diff --git a/src/systemc/tlm_core/tlm_2/tlm_generic_payload/SConscript b/src/systemc/tlm_core/tlm_2/tlm_generic_payload/SConscript deleted file mode 100644 index 0d6557931..000000000 --- a/src/systemc/tlm_core/tlm_2/tlm_generic_payload/SConscript +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2018 Google, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer; -# redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution; -# neither the name of the copyright holders nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# Authors: Gabe Black - -Import('*') - -if env['USE_SYSTEMC']: - Source('tlm_gp.cc') - Source('tlm_phase.cc') diff --git a/src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_gp.cc b/src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_gp.cc deleted file mode 100644 index ff3c92bd9..000000000 --- a/src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_gp.cc +++ /dev/null @@ -1,355 +0,0 @@ -/***************************************************************************** - - 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. - - *****************************************************************************/ - -#include // std::memcpy et.al. -#include -#include -#include - -using sc_core::sc_type_index; - -namespace tlm -{ - -template class tlm_array; - -//--------------------------------------------------------------------------- -// Classes for the extension mechanism -//--------------------------------------------------------------------------- - -namespace -{ - -class tlm_extension_registry -{ - typedef unsigned int key_type; - typedef std::map type_map; - public: - static tlm_extension_registry & - instance() - { - if (!instance_) { - // Don't cleanup registry. - instance_ = new tlm_extension_registry(); - } - return *instance_; - } - - unsigned int - register_extension(sc_type_index type) - { - type_map::const_iterator it = ids_.find(type); - - if (it == ids_.end()) { - // New extension - generate/store ID. - type_map::value_type v(type, static_cast(ids_.size())); - ids_.insert(v); - return v.second; - } - return it->second; - } - - static unsigned int - max_num_extensions() - { - return (instance_) ? instance().ids_.size() : 0; - } - - private: - static tlm_extension_registry *instance_; - type_map ids_; - tlm_extension_registry() {} - -}; - -tlm_extension_registry *tlm_extension_registry::instance_ = NULL; - -} // anonymous namespace - -unsigned int -max_num_extensions() -{ - return tlm_extension_registry::max_num_extensions(); -} - -unsigned int -tlm_extension_base::register_extension(const std::type_info &type) -{ - return tlm_extension_registry::instance().register_extension(type); -} - -//--------------------------------------------------------------------------- -// The generic payload class: -//--------------------------------------------------------------------------- - -tlm_generic_payload::tlm_generic_payload() : m_address(0), - m_command(TLM_IGNORE_COMMAND), m_data(0), m_length(0), - m_response_status(TLM_INCOMPLETE_RESPONSE), m_dmi(false), m_byte_enable(0), - m_byte_enable_length(0), m_streaming_width(0), - m_gp_option(TLM_MIN_PAYLOAD), m_extensions(max_num_extensions()), m_mm(0), - m_ref_count(0) -{} - -tlm_generic_payload::tlm_generic_payload(tlm_mm_interface *mm): m_address(0), - m_command(TLM_IGNORE_COMMAND), m_data(0), m_length(0), - m_response_status(TLM_INCOMPLETE_RESPONSE), m_dmi(false), m_byte_enable(0), - m_byte_enable_length(0), m_streaming_width(0), - m_gp_option(TLM_MIN_PAYLOAD), m_extensions(max_num_extensions()), m_mm(mm), - m_ref_count(0) -{} - -void -tlm_generic_payload::reset() -{ - // Should the other members be reset too? - m_gp_option = TLM_MIN_PAYLOAD; - m_extensions.free_entire_cache(); -}; - -// Non-virtual deep-copying of the object. -void -tlm_generic_payload::deep_copy_from(const tlm_generic_payload &other) -{ - m_command = other.get_command(); - m_address = other.get_address(); - m_length = other.get_data_length(); - m_response_status = other.get_response_status(); - m_byte_enable_length = other.get_byte_enable_length(); - m_streaming_width = other.get_streaming_width(); - m_gp_option = other.get_gp_option(); - m_dmi = other.is_dmi_allowed(); - - // Deep copy data. - // There must be enough space in the target transaction! - if (m_data && other.m_data) { - std::memcpy(m_data, other.m_data, m_length); - } - // Deep copy byte enables. - // There must be enough space in the target transaction! - if (m_byte_enable && other.m_byte_enable) { - std::memcpy(m_byte_enable, other.m_byte_enable, m_byte_enable_length); - } - // Deep copy extensions (sticky and non-sticky). - if (m_extensions.size() < other.m_extensions.size()) { - m_extensions.expand(other.m_extensions.size()); - } - for (unsigned int i = 0; i < other.m_extensions.size(); i++) { - if (other.m_extensions[i]) { - // Original has extension i. - if (!m_extensions[i]) { - // We don't: clone. - tlm_extension_base *ext = other.m_extensions[i]->clone(); - if (ext) { // Extension may not be clonable. - if (has_mm()) { - // mm can take care of removing cloned extensions. - set_auto_extension(i, ext); - } else { - // no mm, user will call free_all_extensions(). - set_extension(i, ext); - } - } - } else { - // We already have such extension. Copy original over it. - m_extensions[i]->copy_from(*other.m_extensions[i]); - } - } - } -} - -// To update the state of the original generic payload from a deep copy. -// Assumes that "other" was created from the original by calling -// deep_copy_from. Argument use_byte_enable_on_read determines whether to use -// or ignores byte enables when copying back the data array on a read command. - -void -tlm_generic_payload::update_original_from( - const tlm_generic_payload &other, bool use_byte_enable_on_read) -{ - // Copy back extensions that are present on the original. - update_extensions_from(other); - - // Copy back the response status and DMI hint attributes. - m_response_status = other.get_response_status(); - m_dmi = other.is_dmi_allowed(); - - // Copy back the data array for a read command only deep_copy_from allowed - // null pointers, and so will we. - // We assume the arrays are the same size. - // We test for equal pointers in case the original and the copy share the - // same array. - - if (is_read() && m_data && other.m_data && m_data != other.m_data) { - if (m_byte_enable && use_byte_enable_on_read) { - if (m_byte_enable_length == 8 && m_length % 8 == 0) { - // Optimized implementation copies 64-bit words by masking. - for (unsigned int i = 0; i < m_length; i += 8) { - typedef sc_dt::uint64 *u; - *reinterpret_cast(&m_data[i]) &= - ~*reinterpret_cast(m_byte_enable); - *reinterpret_cast(&m_data[i]) |= - *reinterpret_cast(&other.m_data[i]) & - *reinterpret_cast(m_byte_enable); - } - } else if (m_byte_enable_length == 4 && m_length % 4 == 0) { - // Optimized implementation copies 32-bit words by masking. - for (unsigned int i = 0; i < m_length; i += 4) { - typedef unsigned int *u; - *reinterpret_cast(&m_data[i]) &= - ~*reinterpret_cast(m_byte_enable); - *reinterpret_cast(&m_data[i]) |= - *reinterpret_cast(&other.m_data[i]) & - *reinterpret_cast(m_byte_enable); - } - } else { - // Unoptimized implementation. - for (unsigned int i = 0; i < m_length; i++) { - if (m_byte_enable[i % m_byte_enable_length]) - m_data[i] = other.m_data[i]; - } - } - } else { - std::memcpy(m_data, other.m_data, m_length); - } - } -} - -void -tlm_generic_payload::update_extensions_from(const tlm_generic_payload &other) -{ - // Deep copy extensions that are already present. - sc_assert(m_extensions.size() <= other.m_extensions.size()); - for (unsigned int i = 0; i < m_extensions.size(); i++) { - if (other.m_extensions[i]) { - // Original has extension i. - if (m_extensions[i]) { - // We have it too. Copy. - m_extensions[i]->copy_from(*other.m_extensions[i]); - } - } - } -} - -// Free all extensions. Useful when reusing a cloned transaction that doesn't -// have memory manager. Normal and sticky extensions are freed and extension -// array cleared. -void -tlm_generic_payload::free_all_extensions() -{ - m_extensions.free_entire_cache(); - for (unsigned int i = 0; i < m_extensions.size(); i++) { - if (m_extensions[i]) { - m_extensions[i]->free(); - m_extensions[i] = 0; - } - } -} - -tlm_generic_payload::~tlm_generic_payload() -{ - for (unsigned int i = 0; i < m_extensions.size(); i++) { - if (m_extensions[i]) - m_extensions[i]->free(); - } -} - -//---------------- -// API (including setters & getters) -//--------------- - -std::string -tlm_generic_payload::get_response_string() const -{ - switch (m_response_status) { - case TLM_OK_RESPONSE: - return "TLM_OK_RESPONSE"; - case TLM_INCOMPLETE_RESPONSE: - return "TLM_INCOMPLETE_RESPONSE"; - case TLM_GENERIC_ERROR_RESPONSE: - return "TLM_GENERIC_ERROR_RESPONSE"; - case TLM_ADDRESS_ERROR_RESPONSE: - return "TLM_ADDRESS_ERROR_RESPONSE"; - case TLM_COMMAND_ERROR_RESPONSE: - return "TLM_COMMAND_ERROR_RESPONSE"; - case TLM_BURST_ERROR_RESPONSE: - return "TLM_BURST_ERROR_RESPONSE"; - case TLM_BYTE_ENABLE_ERROR_RESPONSE: - return "TLM_BYTE_ENABLE_ERROR_RESPONSE"; - } - return "TLM_UNKNOWN_RESPONSE"; -} - -/* --------------------------------------------------------------------- */ -/* Dynamic extension mechanism: */ -/* --------------------------------------------------------------------- */ - -tlm_extension_base * -tlm_generic_payload::set_extension(unsigned int index, tlm_extension_base *ext) -{ - sc_assert(index < m_extensions.size()); - tlm_extension_base *tmp = m_extensions[index]; - m_extensions[index] = ext; - return tmp; -} - -tlm_extension_base * -tlm_generic_payload::set_auto_extension( - unsigned int index, tlm_extension_base *ext) -{ - sc_assert(index < m_extensions.size()); - tlm_extension_base *tmp = m_extensions[index]; - m_extensions[index] = ext; - if (!tmp) - m_extensions.insert_in_cache(&m_extensions[index]); - sc_assert(m_mm != 0); - return tmp; -} - -tlm_extension_base * -tlm_generic_payload::get_extension(unsigned int index) const -{ - sc_assert(index < m_extensions.size()); - return m_extensions[index]; -} - -void -tlm_generic_payload::clear_extension(unsigned int index) -{ - sc_assert(index < m_extensions.size()); - m_extensions[index] = static_cast(0); -} - -void -tlm_generic_payload::release_extension(unsigned int index) -{ - sc_assert(index < m_extensions.size()); - if (m_mm) { - m_extensions.insert_in_cache(&m_extensions[index]); - } else { - m_extensions[index]->free(); - m_extensions[index] = static_cast(nullptr); - } -} - -void -tlm_generic_payload::resize_extensions() -{ - m_extensions.expand(max_num_extensions()); -} - -} // namespace tlm diff --git a/src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.cc b/src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.cc deleted file mode 100644 index 2c8b1e1a0..000000000 --- a/src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.cc +++ /dev/null @@ -1,111 +0,0 @@ -/***************************************************************************** - - 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. - - *****************************************************************************/ - -#include -#include -#include -#include - -using sc_core::sc_string_view; -using sc_core::sc_type_index; - -namespace tlm -{ - -namespace -{ - -struct tlm_phase_registry -{ - typedef unsigned int key_type; - - static tlm_phase_registry & - instance() - { - static tlm_phase_registry inst; - return inst; - } - - unsigned int - register_phase(sc_type_index type, sc_string_view name) - { - type_map::const_iterator it = ids_.find(type); - - if (name.empty()) { - SC_REPORT_FATAL( sc_core::SC_ID_INTERNAL_ERROR_, - "unexpected empty tlm_phase name" ); - return UNINITIALIZED_PHASE; - } - - if (it == ids_.end()) { - // new phase - generate/store ID and name - type_map::value_type v(type, static_cast(names_.size())); - names_.push_back(name_table::value_type(name.data(), name.size())); - ids_.insert(v); - return v.second; - } - - if (names_[it->second] != name) { - SC_REPORT_FATAL(sc_core::SC_ID_INTERNAL_ERROR_, - "tlm_phase registration failed: duplicate type info" ); - sc_core::sc_abort(); - } - return it->second; - } - - const char * - get_name(key_type id) const - { - sc_assert(id < names_.size()); - return names_[id].c_str(); - } - - private: - typedef std::map type_map; - typedef std::vector name_table; - - type_map ids_; - name_table names_; - - tlm_phase_registry() : names_(END_RESP + 1) - { - names_[UNINITIALIZED_PHASE] = "UNINITIALIZED_PHASE"; - names_[BEGIN_REQ] = "BEGIN_REQ"; - names_[END_REQ] = "END_REQ"; - names_[BEGIN_RESP] = "BEGIN_RESP"; - names_[END_RESP] = "END_RESP"; - } -}; - -} // anonymous namespace - -tlm_phase::tlm_phase(unsigned int id) : m_id(id) -{} - -tlm_phase::tlm_phase(const std::type_info &type, const char *name) : - m_id(tlm_phase_registry::instance().register_phase(type, name)) -{} - -const char * -tlm_phase::get_name() const -{ - return tlm_phase_registry::instance().get_name(m_id); -} - -} // namespace tlm diff --git a/src/systemc/tlm_core/tlm_2/tlm_quantum/SConscript b/src/systemc/tlm_core/tlm_2/tlm_quantum/SConscript deleted file mode 100644 index bdfc2a034..000000000 --- a/src/systemc/tlm_core/tlm_2/tlm_quantum/SConscript +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2018 Google, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer; -# redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution; -# neither the name of the copyright holders nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# Authors: Gabe Black - -Import('*') - -if env['USE_SYSTEMC']: - Source('tlm_global_quantum.cc') diff --git a/src/systemc/tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.cc b/src/systemc/tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.cc deleted file mode 100644 index 7ba44e3cb..000000000 --- a/src/systemc/tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.cc +++ /dev/null @@ -1,49 +0,0 @@ -/***************************************************************************** - - 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. - - *****************************************************************************/ - -#include -#include - -namespace tlm -{ - -tlm_global_quantum::tlm_global_quantum() : - m_global_quantum(sc_core::SC_ZERO_TIME) -{} - -tlm_global_quantum & -tlm_global_quantum::instance() -{ - static tlm_global_quantum instance_; - return instance_; -} - -sc_core::sc_time -tlm_global_quantum::compute_local_quantum() -{ - if (m_global_quantum != sc_core::SC_ZERO_TIME) { - const sc_core::sc_time current = sc_core::sc_time_stamp(); - const sc_core::sc_time g_quant = m_global_quantum; - return g_quant - (current % g_quant); - } else { - return sc_core::SC_ZERO_TIME; - } -} - -} // namespace tlm