Deleted Added
sdiff udiff text old ( 8255:73089f793a0a ) new ( 8257:7226aebb77b4 )
full compact
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 30 unchanged lines hidden (view full) ---

39
40#ifndef __MEM_RUBY_NETWORK_SIMPLE_TOPOLOGY_HH__
41#define __MEM_RUBY_NETWORK_SIMPLE_TOPOLOGY_HH__
42
43#include <iostream>
44#include <string>
45#include <vector>
46
47#include "mem/protocol/LinkDirection.hh"
48#include "mem/ruby/common/Global.hh"
49#include "mem/ruby/system/NodeID.hh"
50#include "params/Topology.hh"
51#include "sim/sim_object.hh"
52
53class NetDest;
54class Network;
55
56typedef std::vector<std::vector<int> > Matrix;
57
58struct LinkEntry
59{
60 BasicLink *link;
61 LinkDirection direction;
62};
63
64typedef std::map<std::pair<int, int>, LinkEntry> LinkMap;
65
66class Topology : public SimObject
67{
68 public:
69 typedef TopologyParams Params;
70 Topology(const Params *p);
71 virtual ~Topology() {}
72 const Params *params() const { return (const Params *)_params; }
73
74 void init();
75 int numSwitches() const { return m_number_of_switches; }
76 void createLinks(Network *net, bool isReconfiguration);
77
78 void initNetworkPtr(Network* net_ptr);
79
80 const std::string getName() { return m_name; }
81 void printStats(std::ostream& out) const;
82 void clearStats();
83 void printConfig(std::ostream& out) const;
84 void print(std::ostream& out) const { out << "[Topology]"; }
85
86 protected:
87 void addLink(SwitchID src, SwitchID dest, BasicLink* link,
88 LinkDirection dir);
89 void makeLink(Network *net, SwitchID src, SwitchID dest,
90 const NetDest& routing_table_entry,
91 bool isReconfiguration);
92
93 std::string getDesignStr();
94 // Private copy constructor and assignment operator
95 Topology(const Topology& obj);
96 Topology& operator=(const Topology& obj);
97
98 std::string m_name;
99 bool m_print_config;
100 NodeID m_nodes;
101 int m_number_of_switches;
102
103 std::vector<AbstractController*> m_controller_vector;
104 std::vector<BasicExtLink*> m_ext_link_vector;
105 std::vector<BasicIntLink*> m_int_link_vector;
106
107 Matrix m_component_latencies;
108 Matrix m_component_inter_switches;
109
110 LinkMap m_link_map;
111 std::vector<BasicRouter*> m_router_vector;
112};
113
114inline std::ostream&
115operator<<(std::ostream& out, const Topology& obj)
116{
117 obj.print(out);
118 out << std::flush;
119 return out;
120}
121
122#endif // __MEM_RUBY_NETWORK_SIMPLE_TOPOLOGY_HH__