-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectronic_mesh_single_random_source_test.h
More file actions
125 lines (91 loc) · 3 KB
/
electronic_mesh_single_random_source_test.h
File metadata and controls
125 lines (91 loc) · 3 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* electronic_mesh_single_random_source_test.h
* PhoenixSim
*
* Created by Johnnie Chan on 6/29/11.
* Copyright 2011 Johnnie Chan. All rights reserved.
*
* This is to test network's ability to handle interface credit return.
*/
#include <vector>
#include <list>
#include <time.h>
#include <stdlib.h>
#include "systemc.h"
#include "electronicmesh_topology.h"
#include "random_interface.h"
#include "terminate_interface.h"
const int SIZE_X = 4;
const int SIZE_Y = 4;
const double MEANARRIVALTIME = 1e-9;
const int MESSAGESIZE = 32;
using namespace std;
using namespace PhoenixSim;
void run_net_single_node ()
{
// Global Simulation Parameters
sc_set_time_resolution(100, SC_FS);
std::cout<<"time resolution: "<<sc_get_time_resolution()<<endl;
srand(time(NULL));
// Top Level Signals
vector< sc_buffer<ElectronicMessage>* > data_in;
vector< sc_buffer<ElectronicMessage>* > data_out;
vector< sc_buffer<int>* > credit_in;
vector< sc_buffer<int>* > credit_out;
data_in.resize(SIZE_X * SIZE_Y);
data_out.resize(SIZE_X * SIZE_Y);
credit_in.resize(SIZE_X * SIZE_Y);
credit_out.resize(SIZE_X * SIZE_Y);
ElectronicMesh_Topology network("myNetwork", SIZE_X, SIZE_Y);
vector<Credit_Interface*> node(SIZE_X * SIZE_Y);
node[0] = new Random_Interface("Node_zero", 0, SIZE_X * SIZE_Y, MEANARRIVALTIME, MESSAGESIZE, 32);
for(int i = 1; i < SIZE_X * SIZE_Y; i++)
{
std::stringstream so;
so << "Node" << "<" << i << ">";
node[i] = new Terminate_Interface(so.str().c_str(), 32);
}
for(int i = 0 ; i < SIZE_X * SIZE_Y ; i++)
{
data_in[i] = new sc_core::sc_buffer<ElectronicMessage>;
data_out[i] = new sc_core::sc_buffer<ElectronicMessage>;
credit_in[i] = new sc_core::sc_buffer<int>;
credit_out[i] = new sc_core::sc_buffer<int>;
network.inputPort[i]->bind(*data_in[i]);
network.outputPort[i]->bind(*data_out[i]);
network.inputCreditPort[i]->bind(*credit_in[i]);
network.outputCreditPort[i]->bind(*credit_out[i]);
node[i]->outputPort[0]->bind(*data_in[i]);
node[i]->inputPort[0]->bind(*data_out[i]);
node[i]->creditInputPort[0]->bind(*credit_out[i]);
node[i]->creditOutputPort[0]->bind(*credit_in[i]);
}
sc_trace_file *tf = sc_create_vcd_trace_file("electronic_mesh");
for(int i = 0; i < SIZE_X * SIZE_Y; i++)
{
std::stringstream so, so1;
so << "DataIn" << "<" << i << ">";
sc_trace(tf, data_in[i]->read().messageId, so.str());
}
for(int i = 0; i < SIZE_X * SIZE_Y; i++)
{
std::stringstream so, so1;
so1 << "CreditIn" << "<" << i << ">";
sc_trace(tf, credit_in[i]->read(), so1.str());
}
for(int i = 0; i < SIZE_X * SIZE_Y; i++)
{
std::stringstream so, so1;
so << "DataOut" << "<" << i << ">";
sc_trace(tf, data_out[i]->read().messageId, so.str());
}
for(int i = 0; i < SIZE_X * SIZE_Y; i++)
{
std::stringstream so, so1;
so1 << "CreditOut" << "<" << i << ">";
sc_trace(tf, credit_out[i]->read(), so1.str());
}
sc_trace(tf,network.horizontalRightPath[7]->read().messageId, "path");
sc_start();
sc_close_vcd_trace_file(tf);
}