+++ /dev/null
-/*
- * 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
#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
{
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
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;
#define __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__
#include <iostream>
+#include <sstream>
#include <string>
#include <vector>
#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
{
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; }
private:
sc_event _valueChangedEvent;
uint64_t _changeStamp;
+ sc_port_base *_gem5Writer;
// Disabled
sc_signal(const sc_signal<T, 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; }
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("")
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; }
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("")
+++ /dev/null
-/*
- * 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__