-
Notifications
You must be signed in to change notification settings - Fork 0
/
processor.h
94 lines (77 loc) · 2.63 KB
/
processor.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
86
87
88
89
90
91
92
93
94
/*
* processor.h
*
* Created on: 2017年4月26日
* Author: Vincent
*/
#ifndef PROCESSOR_H_
#define PROCESSOR_H_
#include <stdio.h>
#include <string.h>
#include <omnetpp.h>
#include <algorithm>
#include "data_pkt_m.h"
#include "buffer_info_m.h"
#include "topoconfig.h"
using namespace omnetpp;
/**
* This model is exciting enough so that we can collect some statistics.
* We'll record in output vectors the hop count of every message upon arrival.
* Output vectors are written into the omnetpp.vec file and can be visualized
* with the Plove program.
*
* We also collect basic statistics (min, max, mean, std.dev.) and histogram
* about the hop count which we'll print out at the end of the simulation.
*/
// Processor
class Processor : public cSimpleModule
{
private:
cMessage *selfMsgGenMsg;//产生flit定时,package产生按泊松分布或均匀分布
cMessage *selfMsgSendMsg;//发送flit定时,每周期都检查buffer,再发送
long numFlitSent;
long numPackageSent;
long numFlitReceived;
long numPackageReceived;
long numPktDropped; //丢弃的数据包
long flitByHop; //用于计算链路利用率, flit * Hop
bool dropFlag; //判断本轮是否drop过
int BufferConnectCredit[VC]; //连接Processor端口的Router的buffer的credit
cQueue txQueue; //发送数据队列
// cOutVector hopCountVector;
// cOutVector flitDelayTime;
// cOutVector packageDelayTime;
// cOutVector creditMsgDelayTime;
long hopCountTotal;
int hopCountCount;
double flitDelayTimeTotal;
int flitDelayTimeCount;
double packetDelayTimeTotal;
int packetDelayTimeCount;
double creditMsgDelayTimeTotal;
int creditMsgDelayTimeCount;
public:
Processor();
virtual ~Processor();
protected:
virtual DataPkt* generateMessage(bool isHead, bool isTail, int flitCount, int flidID, int vcid);
virtual void forwardMessage(DataPkt *msg);
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
virtual void checkGenMsg(DataPkt* datapkt); //检测生成的数据包是否有问题
virtual simtime_t channelAvailTime();
virtual int generateBestVCID();
// virtual double ParetoON();
// virtual double ParetoOFF();
virtual double Poisson();
virtual double Uniform();
// The finish() function is called by OMNeT++ at the end of the simulation:
virtual void finish() override; //需要把processor buffer中的pkt给析构掉
//纯虚函数,由子类实现
virtual int ppid2plid(int ppid) = 0;
virtual int plid2ppid(int plid) = 0;
virtual int getNextRouterPortP() = 0; //计算与processor相连的router的端口
};
//Cannot allocate abstract class
//Define_Module(Processor);
#endif /* PROCESSOR_H_ */