ruby: controller: slight code refactoring

This commit is contained in:
Nilay Vaish 2014-02-20 17:27:45 -06:00
parent 0ce8c25919
commit 896654746a
3 changed files with 6 additions and 9 deletions

View file

@ -89,8 +89,7 @@ Topology::Topology(uint32_t num_routers, vector<BasicExtLink *> ext_links,
// Store the ExtLink pointers for later // Store the ExtLink pointers for later
m_ext_link_vector.push_back(ext_link); m_ext_link_vector.push_back(ext_link);
int machine_base_idx = MachineType_base_number( int machine_base_idx = MachineType_base_number(abs_cntrl->getType());
string_to_MachineType(abs_cntrl->getName()));
int ext_idx1 = machine_base_idx + abs_cntrl->getVersion(); int ext_idx1 = machine_base_idx + abs_cntrl->getVersion();
int ext_idx2 = ext_idx1 + m_nodes; int ext_idx2 = ext_idx1 + m_nodes;
int int_idx = router->params()->router_id + 2*m_nodes; int int_idx = router->params()->router_id + 2*m_nodes;

View file

@ -56,11 +56,12 @@ class AbstractController : public ClockedObject, public Consumer
void init(); void init();
const Params *params() const { return (const Params *)_params; } const Params *params() const { return (const Params *)_params; }
const NodeID getVersion() const { return m_version; } const NodeID getVersion() const { return m_machineID.getNum(); }
const MachineType getType() const { return m_machineID.getType(); }
void initNetworkPtr(Network* net_ptr) { m_net_ptr = net_ptr; } void initNetworkPtr(Network* net_ptr) { m_net_ptr = net_ptr; }
// return instance name // return instance name
const std::string getName() const { return m_name; }
void blockOnQueue(Address, MessageBuffer*); void blockOnQueue(Address, MessageBuffer*);
void unblock(Address); void unblock(Address);
@ -129,7 +130,6 @@ class AbstractController : public ClockedObject, public Consumer
void wakeUpAllBuffers(); void wakeUpAllBuffers();
protected: protected:
std::string m_name;
NodeID m_version; NodeID m_version;
MachineID m_machineID; MachineID m_machineID;
NodeID m_clusterID; NodeID m_clusterID;

View file

@ -458,7 +458,8 @@ stringstream ${ident}_transitionComment;
$c_ident::$c_ident(const Params *p) $c_ident::$c_ident(const Params *p)
: AbstractController(p) : AbstractController(p)
{ {
m_name = "${ident}"; m_machineID.type = MachineType_${ident};
m_machineID.num = m_version;
''') ''')
num_in_ports = len(self.in_ports) num_in_ports = len(self.in_ports)
code(' m_in_ports = $num_in_ports;') code(' m_in_ports = $num_in_ports;')
@ -545,9 +546,6 @@ $c_ident::init()
MachineType machine_type = string_to_MachineType("${{var.machine.ident}}"); MachineType machine_type = string_to_MachineType("${{var.machine.ident}}");
int base M5_VAR_USED = MachineType_base_number(machine_type); int base M5_VAR_USED = MachineType_base_number(machine_type);
m_machineID.type = MachineType_${ident};
m_machineID.num = m_version;
// initialize objects // initialize objects
''') ''')