diff --git a/src/mem/ruby/structures/MN_TBEStorage.hh b/src/mem/ruby/structures/MN_TBEStorage.hh index d8991d0321..b75bc9f58e 100644 --- a/src/mem/ruby/structures/MN_TBEStorage.hh +++ b/src/mem/ruby/structures/MN_TBEStorage.hh @@ -53,6 +53,9 @@ namespace gem5 namespace ruby { +namespace CHI +{ + // MN_TBEStorage is composed of multiple TBEStorage // partitions that could be used for specific types of TBEs. // Partition number 0 is the generic partition and will @@ -263,6 +266,8 @@ class MN_TBEStorage } }; +} // namespace CHI + } // namespace ruby } // namespace gem5 diff --git a/src/mem/ruby/structures/MN_TBETable.cc b/src/mem/ruby/structures/MN_TBETable.cc index 43a2dabbfe..a948d5a4a7 100644 --- a/src/mem/ruby/structures/MN_TBETable.cc +++ b/src/mem/ruby/structures/MN_TBETable.cc @@ -43,6 +43,9 @@ namespace gem5 namespace ruby { +namespace CHI +{ + // Based on the current set of TBEs, choose a new "distributor" // Can return null -> no distributor MiscNode_TBE* @@ -144,6 +147,8 @@ MN_TBETable::chooseNewDistributor() return *it; } +} // namespace CHI + } // namespace ruby } // namespace gem5 diff --git a/src/mem/ruby/structures/MN_TBETable.hh b/src/mem/ruby/structures/MN_TBETable.hh index 7cb92ab8fc..04c666ac52 100644 --- a/src/mem/ruby/structures/MN_TBETable.hh +++ b/src/mem/ruby/structures/MN_TBETable.hh @@ -50,6 +50,9 @@ namespace gem5 namespace ruby { +namespace CHI +{ + // Custom class only used for the CHI protocol Misc Node // Includes the definition of the MiscNode_TBE, because it // includes functions that rely on fields in the structure @@ -63,6 +66,8 @@ class MN_TBETable : public TBETable MiscNode_TBE* chooseNewDistributor(); }; +} // namespace CHI + } // namespace ruby } // namespace gem5 diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py index 4925765a33..a0be1a227c 100644 --- a/src/mem/slicc/symbols/StateMachine.py +++ b/src/mem/slicc/symbols/StateMachine.py @@ -277,7 +277,7 @@ from m5.objects.Controller import RubyController class $py_ident(RubyController): type = '$py_ident' cxx_header = 'mem/ruby/protocol/${c_ident}.hh' - cxx_class = 'gem5::ruby::$py_ident' + cxx_class = 'gem5::ruby::$protocol::$py_ident' """ ) code.indent() @@ -345,6 +345,9 @@ namespace gem5 namespace ruby { +namespace ${protocol} +{ + extern std::stringstream ${ident}_transitionComment; class $c_ident : public AbstractController @@ -530,6 +533,7 @@ void unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr); """ }; +} // namespace ${protocol} } // namespace ruby } // namespace gem5 @@ -623,6 +627,9 @@ namespace gem5 namespace ruby { +namespace ${protocol} +{ + // for adding information to the protocol debug trace std::stringstream ${ident}_transitionComment; @@ -1400,6 +1407,7 @@ $c_ident::functionalReadBuffers(PacketPtr& pkt, WriteMask &mask) return read; } +} // namespace ${protocol} } // namespace ruby } // namespace gem5 """ @@ -1468,6 +1476,9 @@ namespace gem5 namespace ruby { +namespace ${protocol} +{ + void ${ident}_Controller::wakeup() { @@ -1551,6 +1562,7 @@ ${ident}_Controller::wakeup() } } +} // namespace ${protocol} } // namespace ruby } // namespace gem5 """ @@ -1591,6 +1603,9 @@ namespace gem5 namespace ruby { +namespace ${protocol} +{ + TransitionResult ${ident}_Controller::doTransition(${ident}_Event event, """ @@ -1864,6 +1879,7 @@ if (!checkResourceAvailable({}_RequestType_{}, addr)) {{ return TransitionResult_Valid; } +} // namespace ${protocol} } // namespace ruby } // namespace gem5 """ diff --git a/src/mem/slicc/symbols/Type.py b/src/mem/slicc/symbols/Type.py index 8038444bd3..52ed858ebe 100644 --- a/src/mem/slicc/symbols/Type.py +++ b/src/mem/slicc/symbols/Type.py @@ -259,6 +259,16 @@ namespace ruby class RubySystem; +""") + # For protocol-specific types, wrap in the protocol namespace + if not self.shared: + code(""" +namespace ${{protocol}} +{ +""") + + code(""" + $klass ${{self.c_ident}}$parent { public: @@ -539,6 +549,14 @@ operator<<(::std::ostream& out, const ${{self.c_ident}}& obj) return out; } +""") + # For protocol-specific types, close the protocol namespace + if not self.shared: + code(""" +} // namespace ${{protocol}} +""") + + code(""" } // namespace ruby } // namespace gem5 @@ -564,6 +582,16 @@ namespace gem5 namespace ruby { +""") + # For protocol-specific types, wrap in the protocol namespace + if not self.shared: + code(""" + +namespace ${{protocol}} +{ +""") + + code(""" /** \\brief Print the state of this object */ void @@ -597,6 +625,14 @@ out << "${{dm.ident}} = " << printAddress(m_${{dm.ident}}, block_size_bits) << " for item in self.methods: code(self.methods[item].generateCode()) + # For protocol-specific types, close the protocol namespace + if not self.shared: + code( + """ + +} // namespace ${{protocol}} +""") + code( """ } // namespace ruby @@ -635,8 +671,14 @@ namespace gem5 namespace ruby { -""" - ) +""") + # For protocol-specific types, wrap in the protocol namespace + if not self.shared: + code(""" + +namespace ${{protocol}} +{ +""") if self.isMachineType: code("struct MachineID;") @@ -714,6 +756,15 @@ AccessPermission ${{self.c_ident}}_to_permission(const ${{self.c_ident}}& obj); ::std::ostream& operator<<(::std::ostream& out, const ${{self.c_ident}}& obj); +""") + + # For protocol-specific types, close the protocol namespace + if not self.shared: + code(""" +} // namespace ${{protocol}} +""") + + code(""" } // namespace ruby } // namespace gem5 """ @@ -770,6 +821,16 @@ namespace gem5 namespace ruby { +""") + # For protocol-specific types, wrap in the protocol namespace + if not self.shared: + code(""" + +namespace ${{protocol}} +{ +""") + + code(""" // Code to convert the current state to an access permission AccessPermission ${{self.c_ident}}_to_permission(const ${{self.c_ident}}& obj) @@ -792,6 +853,16 @@ AccessPermission ${{self.c_ident}}_to_permission(const ${{self.c_ident}}& obj) return AccessPermission_Invalid; } +""") + + # For protocol-specific types, close the protocol namespace + if not self.shared: + code(""" +} // namespace ${{protocol}} +""") + + code(""" + } // namespace ruby } // namespace gem5 @@ -814,6 +885,15 @@ namespace gem5 namespace ruby { +""") + # For protocol-specific types, wrap in the protocol namespace + if not self.shared: + code(""" + +namespace ${{protocol}} +{ +""") + code(""" // Code for output operator ::std::ostream& @@ -1027,8 +1107,14 @@ get${{enum.ident}}MachineID(NodeID RubyNode) MachineID mach = {MachineType_${{enum.ident}}, RubyNode}; return mach; } -""" - ) +""") + + # For protocol-specific types, close the protocol namespace + if not self.shared: + code(""" + +} // namespace ${{protocol}} +""") code( """