-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.cpp
48 lines (40 loc) · 1003 Bytes
/
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
46
47
48
/*
* interface.cpp
* PhoenixSim
*
* Created by Johnnie Chan on 6/24/11.
* Copyright 2011 Johnnie Chan. All rights reserved.
*
*/
#include "interface.h"
#include <sstream>
using namespace PhoenixSim;
int Interface::currentMessageCount = 0;
Interface::Interface(sc_module_name name, int p_numOfNetworkPorts)
:sc_module(name), numOfNetworkPorts(p_numOfNetworkPorts), inputPort(p_numOfNetworkPorts), outputPort(p_numOfNetworkPorts)
{
for(int i = 0; i < numOfNetworkPorts; i++)
{
std::stringstream so;
so << "inputPort" << "<" << i << ">";
inputPort[i] = new sc_in<ElectronicMessage*>(so.str().c_str());
}
for(int i = 0; i < numOfNetworkPorts; i++)
{
std::stringstream so;
so << "outputPort" << "<" << i << ">";
outputPort[i] = new sc_out<ElectronicMessage*>(so.str().c_str());
}
}
Interface::~Interface()
{
for(int i = 0; i < numOfNetworkPorts; i++)
{
delete inputPort[i];
delete outputPort[i];
}
}
int Interface::GetUniqueId()
{
return currentMessageCount++;
}