-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsim_foundation.h
85 lines (68 loc) · 2.24 KB
/
sim_foundation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef SIM_FOUNDATION_
#define SIM_FOUNDATION_
#include "sim_router.h"
#include "flit.h"
#include "mess_event.h"
#include <vector>
#include "configuration.h"
#include "SRGen.h"
#include <exception>
#include <utility>
#include <map>
#include <functional>
#include <iostream>
#include <fstream>
class sim_foundation {
friend ostream& operator<<(ostream&, const sim_foundation&);
private:
//changed at 2022-4-3
//改为继承关系
//vector<sim_router_template> inter_network_;
vector<CRouter>inter_network_;
long ary_size_;//每个维度下的尺寸
long cube_size_;//维度
long router_counter_;//路由器总数
long packet_counter_;
//changed at 2021-10-26
//将文件流改为队列,以提高速度
//ifstream inFile_;
std::queue<SPacket>inputTraces;
static string file_name_;
static sim_foundation * s_f_;
public:
class file_error: public exception {
public:
file_error(const string & err) : what_(err) {}
virtual const char * what() const throw() {return what_.c_str();}
virtual ~file_error() throw();
private:
string what_;
};
static const sim_foundation & sf() {return *s_f_;}
static sim_foundation & wsf() {return *s_f_;}
sim_foundation();
~sim_foundation(){s_f_ = nullptr;}
long ary_size() const {return ary_size_;}
long cube_size() const {return cube_size_;}
long packet_counter() {return packet_counter_;}
long packet_counter() const {return packet_counter_;}
//changed at 2022-4-3
vector</*sim_router_template*/CRouter> & inter_network() {return inter_network_;}
const vector</*sim_router_template*/CRouter> & inter_network() const
{return inter_network_;}
/*sim_router_template*/CRouter & router(const add_type& a);
const /*sim_router_template*/CRouter & router(const add_type& a) const;
bool valid_address(const add_type & a) const;
void receive_EVG_message(mess_event mesg);
void receive_ROUTER_message(mess_event mesg);
void receive_WIRE_message(mess_event mesg);
void receive_CREDIT_message(mess_event mesg);
void router_power_exchange();
void simulation_results();
void simulation_check();
void init_file();
//changed at 2021-10-26
void readTraceFile();
};
void readPacket(SPacket&packet,std::ifstream&ifs,size_t dimension);
#endif