diff options
author | Gabe Black <gabeblack@google.com> | 2018-10-01 03:59:05 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-10-16 00:44:17 +0000 |
commit | e16ca903f240c750f34207b4c98735f81d2312b8 (patch) | |
tree | a33efdef5b37d047b40cded3d9bbf00fb0241d1d /src/systemc/ext/channel/sc_fifo.hh | |
parent | b2e1f81f51e630ef4399f24024c82404601f8340 (diff) | |
download | gem5-e16ca903f240c750f34207b4c98735f81d2312b8.tar.xz |
systemc: Implement register_port in all the predefined channels.
Something the Accellera implementation does which would be good to do
in the gem5 implementation is to create a base class for sc_signal
which isn't templated, and which holds the common/non-type specific
versions of the various sc_signal methods. This will reduce code
redundancy and binary size, and also let us hide more code in .cc
files so that it's less likely we'd need to recompile model code to
fix a bug.
Also, since this all uses of sc_channel_warn_unimple have now been
eliminated, remove that function.
Change-Id: Ia574647c034e7136093c2047b69de725ac34f52f
Reviewed-on: https://gem5-review.googlesource.com/c/13200
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/ext/channel/sc_fifo.hh')
-rw-r--r-- | src/systemc/ext/channel/sc_fifo.hh | 35 |
1 files changed, 30 insertions, 5 deletions
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; |