summaryrefslogtreecommitdiff
path: root/src/systemc
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc')
-rw-r--r--src/systemc/channel/SConscript1
-rw-r--r--src/systemc/channel/warn_unimpl.cc42
-rw-r--r--src/systemc/ext/channel/sc_fifo.hh35
-rw-r--r--src/systemc/ext/channel/sc_signal.hh100
-rw-r--r--src/systemc/ext/channel/sc_signal_rv.hh7
-rw-r--r--src/systemc/ext/channel/warn_unimpl.hh40
-rw-r--r--src/systemc/tests/systemc/communication/sc_signal/check_writer/test08/expected_returncode1
-rw-r--r--src/systemc/tests/systemc/communication/sc_signal/check_writer/test09/expected_returncode1
-rw-r--r--src/systemc/tests/systemc/communication/sc_signal/check_writer/test10/expected_returncode1
-rw-r--r--src/systemc/tests/systemc/communication/sc_signal/check_writer/test11/expected_returncode1
-rw-r--r--src/systemc/tests/systemc/communication/sc_signal/check_writer/test12/expected_returncode1
-rw-r--r--src/systemc/tests/systemc/communication/sc_signal/register_port/test01/expected_returncode1
-rw-r--r--src/systemc/tests/systemc/communication/sc_signal/register_port/test02/expected_returncode1
-rw-r--r--src/systemc/tests/systemc/communication/sc_signal/register_port/test03/expected_returncode1
14 files changed, 120 insertions, 113 deletions
diff --git a/src/systemc/channel/SConscript b/src/systemc/channel/SConscript
index 3ca8801c8..c83c233c9 100644
--- a/src/systemc/channel/SConscript
+++ b/src/systemc/channel/SConscript
@@ -36,4 +36,3 @@ if env['USE_SYSTEMC']:
Source('sc_mutex.cc')
Source('sc_semaphore.cc')
Source('sc_signal_resolved.cc')
- Source('warn_unimpl.cc')
diff --git a/src/systemc/channel/warn_unimpl.cc b/src/systemc/channel/warn_unimpl.cc
deleted file mode 100644
index 82fd8367b..000000000
--- a/src/systemc/channel/warn_unimpl.cc
+++ /dev/null
@@ -1,42 +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
- */
-
-#include "base/logging.hh"
-#include "systemc/ext/channel/warn_unimpl.hh"
-
-namespace sc_core
-{
-
-void
-sc_channel_warn_unimpl(const char *func)
-{
- warn("%s not implemented.\n", func);
-}
-
-} // namespace sc_core
diff --git a/src/systemc/ext/channel/sc_fifo.hh b/src/systemc/ext/channel/sc_fifo.hh
index 7bf9efce0..02a0ddb98 100644
--- a/src/systemc/ext/channel/sc_fifo.hh
+++ b/src/systemc/ext/channel/sc_fifo.hh
@@ -31,12 +31,13 @@
#define __SYSTEMC_EXT_CHANNEL_SC_FIFO_HH__
#include <list>
+#include <string>
#include "../core/sc_module.hh" // for sc_gen_unique_name
#include "../core/sc_prim.hh"
+#include "../utils/sc_report_handler.hh"
#include "sc_fifo_in_if.hh"
#include "sc_fifo_out_if.hh"
-#include "warn_unimpl.hh"
namespace sc_core
{
@@ -53,18 +54,39 @@ class sc_fifo : public sc_fifo_in_if<T>,
explicit sc_fifo(int size=16) :
sc_fifo_in_if<T>(), sc_fifo_out_if<T>(),
sc_prim_channel(sc_gen_unique_name("fifo")),
- _size(size), _readsHappened(false)
+ _size(size), _readsHappened(false), _reader(NULL), _writer(NULL)
{}
explicit sc_fifo(const char *name, int size=16) :
sc_fifo_in_if<T>(), sc_fifo_out_if<T>(),
- sc_prim_channel(name), _size(size), _readsHappened(false)
+ sc_prim_channel(name), _size(size), _readsHappened(false),
+ _reader(NULL), _writer(NULL)
{}
virtual ~sc_fifo() {}
virtual void
- register_port(sc_port_base &, const char *)
+ register_port(sc_port_base &port, const char *iface_type_name)
{
- sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
+ std::string tn(iface_type_name);
+ if (tn == typeid(sc_fifo_in_if<T>).name() ||
+ tn == typeid(sc_fifo_blocking_in_if<T>).name()) {
+ if (_reader) {
+ SC_REPORT_ERROR(
+ "(E104) sc_fifo<T> cannot have more than one reader",
+ "");
+ }
+ _reader = &port;
+ } else if (tn == typeid(sc_fifo_out_if<T>).name() ||
+ tn == typeid(sc_fifo_blocking_out_if<T>).name()) {
+ if (_writer) {
+ SC_REPORT_ERROR(
+ "(E105) sc_fifo<T> cannot have more than one writer",
+ "");
+ }
+ _writer = &port;
+ } else {
+ SC_REPORT_ERROR("(E107) bind interface to port failed",
+ "sc_fifo<T> port not recognized");
+ }
}
virtual void
@@ -192,6 +214,9 @@ class sc_fifo : public sc_fifo_in_if<T>,
sc_event _dataReadEvent;
sc_event _dataWriteEvent;
+ sc_port_base *_reader;
+ sc_port_base *_writer;
+
int _size;
mutable std::list<T> _entries;
mutable std::list<T> _pending;
diff --git a/src/systemc/ext/channel/sc_signal.hh b/src/systemc/ext/channel/sc_signal.hh
index 7c0183763..672eef596 100644
--- a/src/systemc/ext/channel/sc_signal.hh
+++ b/src/systemc/ext/channel/sc_signal.hh
@@ -31,6 +31,7 @@
#define __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__
#include <iostream>
+#include <sstream>
#include <string>
#include <vector>
@@ -39,7 +40,6 @@
#include "../core/sc_prim.hh"
#include "../dt/bit/sc_logic.hh"
#include "sc_signal_inout_if.hh"
-#include "warn_unimpl.hh" // for warn_unimpl
namespace sc_core
{
@@ -53,22 +53,41 @@ class sc_signal : public sc_signal_inout_if<T>,
public:
sc_signal() : sc_signal_inout_if<T>(),
sc_prim_channel(sc_gen_unique_name("signal")),
- m_cur_val(T()), m_new_val(T()), _changeStamp(~0ULL)
+ m_cur_val(T()), m_new_val(T()), _changeStamp(~0ULL),
+ _gem5Writer(NULL)
{}
explicit sc_signal(const char *name) :
sc_signal_inout_if<T>(), sc_prim_channel(name),
- m_cur_val(T()), m_new_val(T()), _changeStamp(~0ULL)
+ m_cur_val(T()), m_new_val(T()), _changeStamp(~0ULL),
+ _gem5Writer(NULL)
{}
explicit sc_signal(const char *name, const T &initial_value) :
sc_signal_inout_if<T>(), sc_prim_channel(name),
- m_cur_val(initial_value), m_new_val(initial_value), _changeStamp(~0ULL)
+ m_cur_val(initial_value), m_new_val(initial_value),
+ _changeStamp(~0ULL), _gem5Writer(NULL)
{}
virtual ~sc_signal() {}
virtual void
- register_port(sc_port_base &, const char *)
- {
- sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
+ register_port(sc_port_base &port, const char *iface_type_name)
+ {
+ if (WRITER_POLICY == SC_ONE_WRITER &&
+ std::string(iface_type_name) ==
+ typeid(sc_signal_inout_if<T>).name()) {
+ if (_gem5Writer) {
+ std::ostringstream ss;
+ ss << "\n signal " << "`" << name() << "' (" <<
+ kind() << ")";
+ ss << "\n first driver `" << _gem5Writer->name() << "' (" <<
+ _gem5Writer->kind() << ")";
+ ss << "\n second driver `" << port.name() << "' (" <<
+ port.kind() << ")";
+ SC_REPORT_ERROR(
+ "(E115) sc_signal<T> cannot have more than one driver",
+ ss.str().c_str());
+ }
+ _gem5Writer = &port;
+ }
}
virtual const T &read() const { return m_cur_val; }
@@ -156,6 +175,7 @@ class sc_signal : public sc_signal_inout_if<T>,
private:
sc_event _valueChangedEvent;
uint64_t _changeStamp;
+ sc_port_base *_gem5Writer;
// Disabled
sc_signal(const sc_signal<T, WRITER_POLICY> &) :
@@ -179,24 +199,43 @@ class sc_signal<bool, WRITER_POLICY> :
sc_signal() : sc_signal_inout_if<bool>(),
sc_prim_channel(sc_gen_unique_name("signal")),
m_cur_val(bool()), m_new_val(bool()),
- _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL)
+ _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL),
+ _gem5Writer(NULL)
{}
explicit sc_signal(const char *name) :
sc_signal_inout_if<bool>(), sc_prim_channel(name),
m_cur_val(bool()), m_new_val(bool()),
- _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL)
+ _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL),
+ _gem5Writer(NULL)
{}
explicit sc_signal(const char *name, const bool &initial_value) :
sc_signal_inout_if<bool>(), sc_prim_channel(name),
m_cur_val(initial_value), m_new_val(initial_value),
- _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL)
+ _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL),
+ _gem5Writer(NULL)
{}
virtual ~sc_signal() {}
virtual void
- register_port(sc_port_base &, const char *)
- {
- sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
+ register_port(sc_port_base &port, const char *iface_type_name)
+ {
+ if (WRITER_POLICY == SC_ONE_WRITER &&
+ std::string(iface_type_name) ==
+ typeid(sc_signal_inout_if<bool>).name()) {
+ if (_gem5Writer) {
+ std::ostringstream ss;
+ ss << "\n signal " << "`" << name() << "' (" <<
+ kind() << ")";
+ ss << "\n first driver `" << _gem5Writer->name() << "' (" <<
+ _gem5Writer->kind() << ")";
+ ss << "\n second driver `" << port.name() << "' (" <<
+ port.kind() << ")";
+ SC_REPORT_ERROR(
+ "(E115) sc_signal<T> cannot have more than one driver",
+ ss.str().c_str());
+ }
+ _gem5Writer = &port;
+ }
}
virtual const bool &read() const { return m_cur_val; }
@@ -314,6 +353,8 @@ class sc_signal<bool, WRITER_POLICY> :
uint64_t _posStamp;
uint64_t _negStamp;
+ sc_port_base *_gem5Writer;
+
// Disabled
sc_signal(const sc_signal<bool, WRITER_POLICY> &) :
sc_signal_inout_if<bool>(), sc_prim_channel("")
@@ -328,25 +369,44 @@ class sc_signal<sc_dt::sc_logic, WRITER_POLICY> :
sc_signal() : sc_signal_inout_if<sc_dt::sc_logic>(),
sc_prim_channel(sc_gen_unique_name("signal")),
m_cur_val(sc_dt::sc_logic()), m_new_val(sc_dt::sc_logic()),
- _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL)
+ _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL),
+ _gem5Writer(NULL)
{}
explicit sc_signal(const char *name) :
sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel(name),
m_cur_val(sc_dt::sc_logic()), m_new_val(sc_dt::sc_logic()),
- _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL)
+ _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL),
+ _gem5Writer(NULL)
{}
explicit sc_signal(const char *name,
const sc_dt::sc_logic &initial_value) :
sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel(name),
m_cur_val(initial_value), m_new_val(initial_value),
- _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL)
+ _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL),
+ _gem5Writer(NULL)
{}
virtual ~sc_signal() {}
virtual void
- register_port(sc_port_base &, const char *)
- {
- sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
+ register_port(sc_port_base &port, const char *iface_type_name)
+ {
+ if (WRITER_POLICY == SC_ONE_WRITER &&
+ std::string(iface_type_name) ==
+ typeid(sc_signal_inout_if<sc_dt::sc_logic>).name()) {
+ if (_gem5Writer) {
+ std::ostringstream ss;
+ ss << "\n signal " << "`" << name() << "' (" <<
+ kind() << ")";
+ ss << "\n first driver `" << _gem5Writer->name() << "' (" <<
+ _gem5Writer->kind() << ")";
+ ss << "\n second driver `" << port.name() << "' (" <<
+ port.kind() << ")";
+ SC_REPORT_ERROR(
+ "(E115) sc_signal<T> cannot have more than one driver",
+ ss.str().c_str());
+ }
+ _gem5Writer = &port;
+ }
}
virtual const sc_dt::sc_logic &read() const { return m_cur_val; }
@@ -464,6 +524,8 @@ class sc_signal<sc_dt::sc_logic, WRITER_POLICY> :
uint64_t _posStamp;
uint64_t _negStamp;
+ sc_port_base *_gem5Writer;
+
// Disabled
sc_signal(const sc_signal<sc_dt::sc_logic, WRITER_POLICY> &) :
sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel("")
diff --git a/src/systemc/ext/channel/sc_signal_rv.hh b/src/systemc/ext/channel/sc_signal_rv.hh
index d333da052..1a47e84ad 100644
--- a/src/systemc/ext/channel/sc_signal_rv.hh
+++ b/src/systemc/ext/channel/sc_signal_rv.hh
@@ -35,7 +35,6 @@
#include "../dt/bit/sc_logic.hh"
#include "../dt/bit/sc_lv.hh"
#include "sc_signal.hh"
-#include "warn_unimpl.hh"
namespace sc_dt
{
@@ -62,11 +61,7 @@ class sc_signal_rv : public sc_signal<sc_dt::sc_lv<W>, SC_MANY_WRITERS>
{}
virtual ~sc_signal_rv() {}
- virtual void
- register_port(sc_port_base &, const char *)
- {
- sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
- }
+ virtual void register_port(sc_port_base &, const char *) {}
virtual void
write(const sc_dt::sc_lv<W> &l)
diff --git a/src/systemc/ext/channel/warn_unimpl.hh b/src/systemc/ext/channel/warn_unimpl.hh
deleted file mode 100644
index 8262ae29e..000000000
--- a/src/systemc/ext/channel/warn_unimpl.hh
+++ /dev/null
@@ -1,40 +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
- */
-
-#ifndef __SYSTEMC_EXT_CHANNEL_WARN_UNIMPL_HH__
-#define __SYSTEMC_EXT_CHANNEL_WARN_UNIMPL_HH__
-
-namespace sc_core
-{
-
-void sc_channel_warn_unimpl(const char *func);
-
-} // namespace sc_core
-
-#endif //__SYSTEMC_EXT_CHANNEL_WARN_UNIMPL_HH__
diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test08/expected_returncode b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test08/expected_returncode
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test08/expected_returncode
@@ -0,0 +1 @@
+1
diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test09/expected_returncode b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test09/expected_returncode
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test09/expected_returncode
@@ -0,0 +1 @@
+1
diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test10/expected_returncode b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test10/expected_returncode
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test10/expected_returncode
@@ -0,0 +1 @@
+1
diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test11/expected_returncode b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test11/expected_returncode
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test11/expected_returncode
@@ -0,0 +1 @@
+1
diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test12/expected_returncode b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test12/expected_returncode
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test12/expected_returncode
@@ -0,0 +1 @@
+1
diff --git a/src/systemc/tests/systemc/communication/sc_signal/register_port/test01/expected_returncode b/src/systemc/tests/systemc/communication/sc_signal/register_port/test01/expected_returncode
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_signal/register_port/test01/expected_returncode
@@ -0,0 +1 @@
+1
diff --git a/src/systemc/tests/systemc/communication/sc_signal/register_port/test02/expected_returncode b/src/systemc/tests/systemc/communication/sc_signal/register_port/test02/expected_returncode
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_signal/register_port/test02/expected_returncode
@@ -0,0 +1 @@
+1
diff --git a/src/systemc/tests/systemc/communication/sc_signal/register_port/test03/expected_returncode b/src/systemc/tests/systemc/communication/sc_signal/register_port/test03/expected_returncode
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_signal/register_port/test03/expected_returncode
@@ -0,0 +1 @@
+1