[gem5-dev] Change in gem5/gem5[master]: mem: Move bind() and unbind() into the Port class.

2019-03-19 Thread Gabe Black (Gerrit)
Gabe Black has submitted this change and it was merged. (  
https://gem5-review.googlesource.com/c/public/gem5/+/17038 )


Change subject: mem: Move bind() and unbind() into the Port class.
..

mem: Move bind() and unbind() into the Port class.

These are now pure virtual methods which more specialized port
subclasses will need to implement. The SlavePort class implements them
by ignoring them and then providing parallel functions for the
MasterPort to call. The MasterPort's methods do basically what they
did before, except now bind() uses dynamic cast to check if its peer
is of the appropriate type and also to convert it into that type before
connecting to it.

Change-Id: I0948799bc954acaebf371e6b6612cee1d3023bc4
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17038
Reviewed-by: Daniel Carvalho 
Reviewed-by: Andreas Sandberg 
Maintainer: Andreas Sandberg 
---
M src/dev/net/etherint.cc
M src/dev/net/etherint.hh
M src/mem/port.cc
M src/mem/port.hh
M src/sim/port.cc
M src/sim/port.hh
6 files changed, 67 insertions(+), 41 deletions(-)

Approvals:
  Andreas Sandberg: Looks good to me, approved; Looks good to me, approved
  Daniel Carvalho: Looks good to me, approved



diff --git a/src/dev/net/etherint.cc b/src/dev/net/etherint.cc
index 0c5e6b8..b55e625 100644
--- a/src/dev/net/etherint.cc
+++ b/src/dev/net/etherint.cc
@@ -34,6 +34,25 @@
 #include "sim/sim_object.hh"

 void
+EtherInt::bind(Port )
+{
+EtherInt *p = dynamic_cast();
+if (!p) {
+fatal("Attempt to bind port %s to non-ethernet port %s.",
+name(), peer.name());
+}
+setPeer(p);
+_connected = true;
+}
+
+void
+EtherInt::unbind()
+{
+peer = nullptr;
+_connected = false;
+}
+
+void
 EtherInt::setPeer(EtherInt *p)
 {
 if (peer && peer != p)
diff --git a/src/dev/net/etherint.hh b/src/dev/net/etherint.hh
index 7703220..0486631 100644
--- a/src/dev/net/etherint.hh
+++ b/src/dev/net/etherint.hh
@@ -60,6 +60,9 @@
 /** Return port name (for DPRINTF). */
 const std::string () const { return portName; }

+void bind(Port ) override;
+void unbind() override;
+
 void setPeer(EtherInt *p);
 EtherInt* getPeer() { return peer; }

diff --git a/src/mem/port.cc b/src/mem/port.cc
index 6f72bbd..001576f 100644
--- a/src/mem/port.cc
+++ b/src/mem/port.cc
@@ -70,12 +70,6 @@
 return *_baseSlavePort;
 }

-bool
-BaseMasterPort::isConnected() const
-{
-return _baseSlavePort != NULL;
-}
-
 BaseSlavePort::BaseSlavePort(const std::string , PortID _id)
 : Port(name, _id), _baseMasterPort(NULL)
 {
@@ -95,12 +89,6 @@
 return *_baseMasterPort;
 }

-bool
-BaseSlavePort::isConnected() const
-{
-return _baseMasterPort != NULL;
-}
-
 /**
  * Master port
  */
@@ -114,24 +102,21 @@
 }

 void
-MasterPort::bind(BaseSlavePort& slave_port)
+MasterPort::bind(Port )
 {
-// bind on the level of the base ports
-_baseSlavePort = _port;
-
-// also attempt to base the slave to the appropriate type
-SlavePort* cast_slave_port = dynamic_cast(_port);
-
-// if this port is compatible, then proceed with the binding
-if (cast_slave_port != NULL) {
-// master port keeps track of the slave port
-_slavePort = cast_slave_port;
-// slave port also keeps track of master port
-_slavePort->bind(*this);
-} else {
-fatal("Master port %s cannot bind to %s\n", name(),
-  slave_port.name());
+auto *slave_port = dynamic_cast();
+if (!slave_port) {
+fatal("Attempt to bind port %s to non-slave port %s.",
+name(), peer.name());
 }
+// bind on the level of the base ports
+_baseSlavePort = slave_port;
+
+// master port keeps track of the slave port
+_slavePort = slave_port;
+_connected = true;
+// slave port also keeps track of master port
+_slavePort->slaveBind(*this);
 }

 void
@@ -140,8 +125,9 @@
 if (_slavePort == NULL)
 panic("Attempting to unbind master port %s that is not  
connected\n",

   name());
-_slavePort->unbind();
+_slavePort->slaveUnbind();
 _slavePort = NULL;
+_connected = false;
 _baseSlavePort = NULL;
 }

@@ -218,17 +204,19 @@
 }

 void
-SlavePort::unbind()
+SlavePort::slaveUnbind()
 {
 _baseMasterPort = NULL;
 _masterPort = NULL;
+_connected = false;
 }

 void
-SlavePort::bind(MasterPort& master_port)
+SlavePort::slaveBind(MasterPort& master_port)
 {
 _baseMasterPort = _port;
 _masterPort = _port;
+_connected = true;
 }

 Tick
diff --git a/src/mem/port.hh b/src/mem/port.hh
index 77081db..2154da0 100644
--- a/src/mem/port.hh
+++ b/src/mem/port.hh
@@ -77,10 +77,7 @@

   public:

-virtual void bind(BaseSlavePort& slave_port) = 0;
-virtual void unbind() = 0;
 BaseSlavePort& getSlavePort() const;
-bool isConnected() const;

 };

@@ -101,7 +98,6 @@
   public:

 BaseMasterPort& getMasterPort() const;
-  

[gem5-dev] Change in gem5/gem5[master]: mem: Move bind() and unbind() into the Port class.

2019-03-18 Thread Gabe Black (Gerrit)
Hello Jason Lowe-Power, Nikos Nikoleris, Weiping Liao, Daniel Carvalho,  
Andreas Sandberg,


I'd like you to reexamine a change. Please visit

https://gem5-review.googlesource.com/c/public/gem5/+/17038

to look at the new patch set (#5).

Change subject: mem: Move bind() and unbind() into the Port class.
..

mem: Move bind() and unbind() into the Port class.

These are now pure virtual methods which more specialized port
subclasses will need to implement. The SlavePort class implements them
by ignoring them and then providing parallel functions for the
MasterPort to call. The MasterPort's methods do basically what they
did before, except now bind() uses dynamic cast to check if its peer
is of the appropriate type and also to convert it into that type before
connecting to it.

Change-Id: I0948799bc954acaebf371e6b6612cee1d3023bc4
---
M src/dev/net/etherint.cc
M src/dev/net/etherint.hh
M src/mem/port.cc
M src/mem/port.hh
M src/sim/port.cc
M src/sim/port.hh
6 files changed, 67 insertions(+), 41 deletions(-)


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/17038
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I0948799bc954acaebf371e6b6612cee1d3023bc4
Gerrit-Change-Number: 17038
Gerrit-PatchSet: 5
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Andreas Sandberg 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Nikos Nikoleris 
Gerrit-Reviewer: Weiping Liao 
Gerrit-MessageType: newpatchset
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: mem: Move bind() and unbind() into the Port class.

2019-03-14 Thread Gabe Black (Gerrit)

Hello Jason Lowe-Power, Nikos Nikoleris, Weiping Liao,

I'd like you to reexamine a change. Please visit

https://gem5-review.googlesource.com/c/public/gem5/+/17038

to look at the new patch set (#3).

Change subject: mem: Move bind() and unbind() into the Port class.
..

mem: Move bind() and unbind() into the Port class.

These are now pure virtual methods which more specialized port
subclasses will need to implement. The SlavePort class implements them
by ignoring them and then providing parallel functions for the
MasterPort to call. The MasterPort's methods do basically what they
did before, except now bind() uses dynamic cast to check if its peer
is of the appropriate type and also to convert it into that type before
connecting to it.

Change-Id: I0948799bc954acaebf371e6b6612cee1d3023bc4
---
M src/dev/net/etherint.cc
M src/dev/net/etherint.hh
M src/mem/port.cc
M src/mem/port.hh
M src/sim/port.cc
M src/sim/port.hh
6 files changed, 61 insertions(+), 29 deletions(-)


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/17038
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I0948799bc954acaebf371e6b6612cee1d3023bc4
Gerrit-Change-Number: 17038
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Nikos Nikoleris 
Gerrit-Reviewer: Weiping Liao 
Gerrit-CC: Andreas Sandberg 
Gerrit-MessageType: newpatchset
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: mem: Move bind() and unbind() into the Port class.

2019-03-07 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/17038



Change subject: mem: Move bind() and unbind() into the Port class.
..

mem: Move bind() and unbind() into the Port class.

These are now pure virtual methods which more specialized port
subclasses will need to implement. The SlavePort class implements them
by ignoring them and then providing parallel functions for the
MasterPort to call. The MasterPort's methods do basically what they
did before, except now bind() uses dynamic cast to check if its peer
is of the appropriate type and also to convert it into that type before
connecting to it.

Change-Id: I0948799bc954acaebf371e6b6612cee1d3023bc4
---
M src/dev/net/etherint.cc
M src/dev/net/etherint.hh
M src/mem/port.cc
M src/mem/port.hh
M src/sim/port.hh
M src/sim/sim_object.cc
6 files changed, 62 insertions(+), 30 deletions(-)



diff --git a/src/dev/net/etherint.cc b/src/dev/net/etherint.cc
index 0c5e6b8..816d615 100644
--- a/src/dev/net/etherint.cc
+++ b/src/dev/net/etherint.cc
@@ -34,6 +34,25 @@
 #include "sim/sim_object.hh"

 void
+EtherInt::bind(Port )
+{
+EtherInt *p = dynamic_cast();
+if (!p) {
+fatal("Attempt to bind port %s to non-ethernet port %s.",
+name(), peer.name());
+}
+setPeer(p);
+_connected = (p != nullptr);
+}
+
+void
+EtherInt::unbind()
+{
+peer = nullptr;
+_connected = false;
+}
+
+void
 EtherInt::setPeer(EtherInt *p)
 {
 if (peer && peer != p)
diff --git a/src/dev/net/etherint.hh b/src/dev/net/etherint.hh
index 7703220..0486631 100644
--- a/src/dev/net/etherint.hh
+++ b/src/dev/net/etherint.hh
@@ -60,6 +60,9 @@
 /** Return port name (for DPRINTF). */
 const std::string () const { return portName; }

+void bind(Port ) override;
+void unbind() override;
+
 void setPeer(EtherInt *p);
 EtherInt* getPeer() { return peer; }

diff --git a/src/mem/port.cc b/src/mem/port.cc
index 6f72bbd..73f96e5 100644
--- a/src/mem/port.cc
+++ b/src/mem/port.cc
@@ -70,12 +70,6 @@
 return *_baseSlavePort;
 }

-bool
-BaseMasterPort::isConnected() const
-{
-return _baseSlavePort != NULL;
-}
-
 BaseSlavePort::BaseSlavePort(const std::string , PortID _id)
 : Port(name, _id), _baseMasterPort(NULL)
 {
@@ -95,12 +89,6 @@
 return *_baseMasterPort;
 }

-bool
-BaseSlavePort::isConnected() const
-{
-return _baseMasterPort != NULL;
-}
-
 /**
  * Master port
  */
@@ -114,23 +102,29 @@
 }

 void
-MasterPort::bind(BaseSlavePort& slave_port)
+MasterPort::bind(Port )
 {
+auto *slave_port = dynamic_cast();
+if (!slave_port) {
+fatal("Attempt to bind port %s to non-slave port %s.",
+name(), peer.name());
+}
 // bind on the level of the base ports
-_baseSlavePort = _port;
+_baseSlavePort = slave_port;

 // also attempt to base the slave to the appropriate type
-SlavePort* cast_slave_port = dynamic_cast(_port);
+SlavePort* cast_slave_port = dynamic_cast(slave_port);

 // if this port is compatible, then proceed with the binding
 if (cast_slave_port != NULL) {
 // master port keeps track of the slave port
 _slavePort = cast_slave_port;
+_connected = true;
 // slave port also keeps track of master port
-_slavePort->bind(*this);
+_slavePort->slaveBind(*this);
 } else {
 fatal("Master port %s cannot bind to %s\n", name(),
-  slave_port.name());
+  slave_port->name());
 }
 }

@@ -140,8 +134,9 @@
 if (_slavePort == NULL)
 panic("Attempting to unbind master port %s that is not  
connected\n",

   name());
-_slavePort->unbind();
+_slavePort->slaveUnbind();
 _slavePort = NULL;
+_connected = false;
 _baseSlavePort = NULL;
 }

@@ -218,17 +213,19 @@
 }

 void
-SlavePort::unbind()
+SlavePort::slaveUnbind()
 {
 _baseMasterPort = NULL;
 _masterPort = NULL;
+_connected = false;
 }

 void
-SlavePort::bind(MasterPort& master_port)
+SlavePort::slaveBind(MasterPort& master_port)
 {
 _baseMasterPort = _port;
 _masterPort = _port;
+_connected = true;
 }

 Tick
diff --git a/src/mem/port.hh b/src/mem/port.hh
index 77081db..e94b144 100644
--- a/src/mem/port.hh
+++ b/src/mem/port.hh
@@ -77,10 +77,7 @@

   public:

-virtual void bind(BaseSlavePort& slave_port) = 0;
-virtual void unbind() = 0;
 BaseSlavePort& getSlavePort() const;
-bool isConnected() const;

 };

@@ -101,7 +98,6 @@
   public:

 BaseMasterPort& getMasterPort() const;
-bool isConnected() const;

 };

@@ -138,12 +134,12 @@
  * Bind this master port to a slave port. This also does the
  * mirror action and binds the slave port to the master port.
  */
-void bind(BaseSlavePort& slave_port);
+void bind(Port ) override;

 /**
  * Unbind this master port and the associated slave port.
  */
-