-
Notifications
You must be signed in to change notification settings - Fork 0
/
source_interface.cpp
45 lines (38 loc) · 1.19 KB
/
source_interface.cpp
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
/*
* source_interface.cpp
* PhoenixSim
*
* Created by Johnnie Chan on 7/8/11.
* Copyright 2011 Johnnie Chan. All rights reserved.
*
*/
#include "source_interface.h"
#include <stdexcept>
#include <sstream>
#include "trafficgeneratorfactory.h"
using namespace std;
using namespace PhoenixSim;
Source_Interface::Source_Interface(sc_module_name name, int p_numOfNetworkPorts, int p_numOfProcessorPorts, int p_bufferWidth)
:Credit_Interface(name, p_numOfNetworkPorts, p_bufferWidth), numOfProcessorPorts(p_numOfProcessorPorts), processorDataInputPort(p_numOfProcessorPorts), processorDataOutputPort(p_numOfProcessorPorts)
{
for(int i = 0; i < numOfProcessorPorts; i++)
{
std::stringstream so;
so << "outputProcessorPort" << "<" << i << ">";
processorDataOutputPort[i] = new sc_out<ElectronicMessage*>(so.str().c_str());
}
for(int i = 0; i < numOfProcessorPorts; i++)
{
std::stringstream so;
so << "inputProcessorPort" << "<" << i << ">";
processorDataInputPort[i] = new sc_in<ElectronicMessage*>(so.str().c_str());
}
}
Source_Interface::~Source_Interface()
{
for(int i = 0; i < numOfProcessorPorts; i++)
{
delete processorDataInputPort[i];
delete processorDataOutputPort[i];
}
}