summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-08-23 17:55:18 -0700
committerGabe Black <gabeblack@google.com>2018-09-26 00:01:23 +0000
commitccd671c4891e79bbb2359089ffa494e06254b0af (patch)
treecfacb715bc484460b777458d2c45a42f06fb9d9b /src
parentabb7d288e9e278a0e7428846909c2d5c790c5e3a (diff)
downloadgem5-ccd671c4891e79bbb2359089ffa494e06254b0af.tar.xz
systemc: Implement positional binding.
Change-Id: Ifbcd7e4148b82b9bf5241e040e812925daea3705 Reviewed-on: https://gem5-review.googlesource.com/12263 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/systemc/core/module.cc20
-rw-r--r--src/systemc/core/module.hh2
-rw-r--r--src/systemc/core/sc_module.cc33
-rw-r--r--src/systemc/ext/core/sc_module.hh13
-rw-r--r--src/systemc/ext/core/sc_port.hh3
5 files changed, 60 insertions, 11 deletions
diff --git a/src/systemc/core/module.cc b/src/systemc/core/module.cc
index 0c118e0c5..78ce2c6fb 100644
--- a/src/systemc/core/module.cc
+++ b/src/systemc/core/module.cc
@@ -32,6 +32,7 @@
#include <cassert>
#include "base/logging.hh"
+#include "systemc/ext/core/sc_port.hh"
#include "systemc/ext/utils/sc_report_handler.hh"
namespace sc_gem5
@@ -85,6 +86,25 @@ Module::pop()
_modules.pop_back();
}
+void
+Module::bindPorts(std::vector<const ::sc_core::sc_bind_proxy *> &proxies)
+{
+ panic_if(proxies.size() > ports.size(),
+ "Trying to bind %d interfaces/ports to %d ports.\n",
+ proxies.size(), ports.size());
+
+ auto proxyIt = proxies.begin();
+ auto portIt = ports.begin();
+ for (; proxyIt != proxies.end(); proxyIt++, portIt++) {
+ auto proxy = *proxyIt;
+ auto port = *portIt;
+ if (proxy->interface())
+ port->vbind(*proxy->interface());
+ else
+ port->vbind(*proxy->port());
+ }
+}
+
Module *
currentModule()
{
diff --git a/src/systemc/core/module.hh b/src/systemc/core/module.hh
index e276dad19..e60018e2b 100644
--- a/src/systemc/core/module.hh
+++ b/src/systemc/core/module.hh
@@ -111,6 +111,8 @@ class Module
const char *uniqueName(const char *seed) { return nameGen.gen(seed); }
+ void bindPorts(std::vector<const ::sc_core::sc_bind_proxy *> &proxies);
+
std::vector<::sc_core::sc_port_base *> ports;
std::vector<::sc_core::sc_export_base *> exports;
};
diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc
index c515aaf09..bbb9993be 100644
--- a/src/systemc/core/sc_module.cc
+++ b/src/systemc/core/sc_module.cc
@@ -72,19 +72,19 @@ UniqueNameGen nameGen;
namespace sc_core
{
-sc_bind_proxy::sc_bind_proxy(const sc_interface &_interface) :
+sc_bind_proxy::sc_bind_proxy(sc_interface &_interface) :
_interface(&_interface), _port(nullptr)
{}
-sc_bind_proxy::sc_bind_proxy(const sc_port_base &_port) :
+sc_bind_proxy::sc_bind_proxy(sc_port_base &_port) :
_interface(nullptr), _port(&_port)
{}
-const sc_bind_proxy SC_BIND_PROXY_NUL(*(const sc_port_base *)nullptr);
+const sc_bind_proxy SC_BIND_PROXY_NUL(*(sc_port_base *)nullptr);
sc_module::~sc_module() { delete _gem5_module; }
-const sc_bind_proxy SC_BIND_PROXY_NIL(*(const sc_port_base *)nullptr);
+const sc_bind_proxy SC_BIND_PROXY_NIL(*(sc_port_base *)nullptr);
void
sc_module::operator () (const sc_bind_proxy &p001,
@@ -152,7 +152,30 @@ sc_module::operator () (const sc_bind_proxy &p001,
const sc_bind_proxy &p063,
const sc_bind_proxy &p064)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ std::vector<const ::sc_core::sc_bind_proxy *> proxies;
+ auto insert = [&proxies](const ::sc_core::sc_bind_proxy &p) -> bool {
+ if (!p.port() && !p.interface())
+ return false;
+ proxies.push_back(&p);
+ return true;
+ };
+ insert(p001) && insert(p002) && insert(p003) && insert(p004) &&
+ insert(p005) && insert(p006) && insert(p007) && insert(p008) &&
+ insert(p009) && insert(p010) && insert(p011) && insert(p012) &&
+ insert(p013) && insert(p014) && insert(p015) && insert(p016) &&
+ insert(p017) && insert(p018) && insert(p019) && insert(p020) &&
+ insert(p021) && insert(p022) && insert(p023) && insert(p024) &&
+ insert(p025) && insert(p026) && insert(p027) && insert(p028) &&
+ insert(p029) && insert(p030) && insert(p031) && insert(p032) &&
+ insert(p033) && insert(p034) && insert(p035) && insert(p036) &&
+ insert(p037) && insert(p038) && insert(p039) && insert(p040) &&
+ insert(p041) && insert(p042) && insert(p043) && insert(p044) &&
+ insert(p045) && insert(p046) && insert(p047) && insert(p048) &&
+ insert(p049) && insert(p050) && insert(p051) && insert(p052) &&
+ insert(p053) && insert(p054) && insert(p055) && insert(p056) &&
+ insert(p057) && insert(p058) && insert(p059) && insert(p060) &&
+ insert(p061) && insert(p062) && insert(p063) && insert(p064);
+ _gem5_module->bindPorts(proxies);
}
const std::vector<sc_object *> &
diff --git a/src/systemc/ext/core/sc_module.hh b/src/systemc/ext/core/sc_module.hh
index 8de57b575..539d275ec 100644
--- a/src/systemc/ext/core/sc_module.hh
+++ b/src/systemc/ext/core/sc_module.hh
@@ -78,14 +78,15 @@ class sc_module_name;
class sc_bind_proxy
{
private:
- const sc_interface *_interface;
- const sc_port_base *_port;
-
- friend class sc_module;
+ sc_interface *_interface;
+ sc_port_base *_port;
public:
- sc_bind_proxy(const sc_interface &_interface);
- sc_bind_proxy(const sc_port_base &_port);
+ sc_bind_proxy(sc_interface &_interface);
+ sc_bind_proxy(sc_port_base &_port);
+
+ sc_interface *interface() const { return _interface; }
+ sc_port_base *port() const { return _port; }
};
extern const sc_bind_proxy SC_BIND_PROXY_NIL;
diff --git a/src/systemc/ext/core/sc_port.hh b/src/systemc/ext/core/sc_port.hh
index f9e50da2e..b39235960 100644
--- a/src/systemc/ext/core/sc_port.hh
+++ b/src/systemc/ext/core/sc_port.hh
@@ -40,6 +40,7 @@ namespace sc_gem5
{
class BindInfo;
+class Module;
class PendingSensitivityPort;
};
@@ -71,6 +72,8 @@ class sc_port_base : public sc_object
void bind(sc_interface &);
void bind(sc_port_base &);
+ friend class ::sc_gem5::Module;
+
// Implementation defined, but depended on by the tests.
virtual int vbind(sc_interface &) = 0;
virtual int vbind(sc_port_base &) = 0;