-
Notifications
You must be signed in to change notification settings - Fork 1
/
OutputDisplayer.cpp
178 lines (158 loc) · 5.49 KB
/
OutputDisplayer.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include "OutputDisplayer.h"
/// <summary>
/// Default constructor.
/// </summary>
OutputDisplayer::OutputDisplayer(/* args */) {
}
/// <summary>
/// Deconstructor.
/// </summary>
OutputDisplayer::~OutputDisplayer() {
}
#pragma region input-methods
/// <summary>
/// Give configuration to display later.
/// </summary>
/// <param name="mem">memory congfig to display</param>
void OutputDisplayer::FeedConfigOutput(MemoryOptions mem) {
this->configOutput = mem;
if(configOutput.dcPolicy == 0) {
policyStr = "Write-Through";
}
else {
policyStr = "Write-Back";
}
}
/// <summary>
/// Give TLB stats to display later.
/// </summary>
/// <param name="stats">TLB stats to display</param>
void OutputDisplayer::FeedTLBStats(HardwareStats stats) {
this->TLBOutput = stats;
}
/// <summary>
/// Give pT stats to display later.
/// </summary>
/// <param name="stats">PT stats to display</param>
void OutputDisplayer::FeedPTStats(HardwareStats stats) {
this->PTOutput = stats;
}
/// <summary>
/// Give DC stats to display later.
/// </summary>
/// <param name="stats">DC stats to display</param>
void OutputDisplayer::FeedDCStats(HardwareStats stats) {
this->DCOutput = stats;
}
/// <summary>
/// Give reference stats to display later.
/// </summary>
/// <param name="stats">stats to display.</param>
void OutputDisplayer::FeedReferenceOutput(ReferenceStats stats) {
this->miscOutput = stats;
}
/// <summary>
/// Give read/write info to display later.
/// </summary>
/// <param name="numReads">number of reads.</param>
/// <param name="numWrites">number of writes.</param>
void OutputDisplayer::FeedReadWriteInfo(int numReads, int numWrites) {
reads = numReads;
writes = numWrites;
rwRatio = (double) numReads / (double)(numReads + numWrites);
}
#pragma endregion
#pragma region Display-methods
/// <summary>
/// Display configuration file
/// </summary>
void OutputDisplayer::DisplayConfig() {
printf("Data TLB contains %d entries.\n", configOutput.tlbEntries);
printf("\n");
printf("Number of virtual pages is %d.\n", configOutput.pageCount);
printf("Number of physical frames is %d.\n", configOutput.frameCount);
printf("Each page contains %d bytes.\n", configOutput.pageSize);
printf("Number of bits for page-table index is %d.\n", configOutput.vpnBits);
printf("Number of bits for page offset is %d.\n", configOutput.offBits);
printf("\n");
printf("Data cache contains %d sets.\n", configOutput.dcTotalSets);
printf("Each set contains %d entries.\n", configOutput.cacheEntriesPerSet);
printf("Each line is %d bytes.\n", configOutput.dcLineSize);
printf("The set uses a %s policy\n", policyStr.c_str());
printf("Number of bits used for the tag is %d.\n", configOutput.cacheTagBits);
printf("Number of bits used for the index is %d.\n", configOutput.cacheIndexBits);
printf("Number of bits used for the offset is %d.\n", configOutput.cacheOffsetBits);
printf("\n");
if(configOutput.useVirt) {
printf("The addresses read in are VIRTUAL addresses.\n");
} else {
printf("The addresses read in are PHYSICAL addresses.\n");
}
if(configOutput.useTLB) {
printf("The translation lookaside buffer is ENABLED.\n");
} else {
printf("The translation lookaside buffer is DISABLED.\n");
}
printf("\n");
}
/// <summary>
/// Display trace header.
/// </summary>
void OutputDisplayer::DisplayTraceHeader() {
printf("Virtual Virt. Page TLB PT Phys DC DC \n");
printf("Address Page # Off. Res. Res. Pg # DC Tag Idx Res.\n");
printf("-------- ------ ---- ---- ---- ---- ------ --- ----\n");
}
/// <summary>
/// Display trace.
/// </summary>
/// <param name="line">trace to display</param>
void OutputDisplayer::DisplayTraceLine(TraceStats line) {
printf("%08x %6x %4x %4s %4s %4x %6x %3x %4s\n",
line.trace.hexAddress,
line.VPN,
line.pageOffset,
line.TLBresult.c_str(),
line.PTresult.c_str(),
line.PFN,
line.DCtag,
line.DCidx,
line.DCresult.c_str());
}
/// <summary>
/// Display component stats.
/// </summary>
void OutputDisplayer::DisplayComponentStats() {
printf("\n\nSimulation Statistics\n");
printf("---------------------\n");
printf("\n");
printf("Data TLB hits : %d\n", TLBOutput.hits);
printf("Data TLB misses : %d\n", TLBOutput.misses);
printf("Data TLB hit ratio : %f\n", TLBOutput.hitrate);
printf("\n");
printf("Page Table hits : %d\n", PTOutput.hits);
printf("Page Table misses : %d\n", PTOutput.misses);
printf("Page Table hit ratio : %f\n", PTOutput.hitrate);
printf("\n");
printf("Data Cache hits : %d\n", DCOutput.hits);
printf("Data Cache misses : %d\n", DCOutput.misses);
printf("Data Cache hit ratio : %f\n", DCOutput.hitrate);
printf("\n");
}
/// <summary>
/// Display read/write info
/// </summary>
void OutputDisplayer::DisplayReadWriteInfo() {
printf("Total reads : %d\n", reads);
printf("Total writes : %d\n", writes);
printf("Ratio of reads : %f\n", rwRatio);
}
/// <summary>
/// Display reference info
/// </summary>
void OutputDisplayer::DisplayReferenceStats() {
printf("Main Memory references: %d\n",miscOutput.mainMemoryRefCount);
printf("Page Table references: %d\n",miscOutput.pageTableRefCount);
printf("Disk References : %d\n",miscOutput.diskRefCount);
}
#pragma endregion