-
Notifications
You must be signed in to change notification settings - Fork 66
/
interconnect.cc
228 lines (191 loc) · 7.11 KB
/
interconnect.cc
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/*****************************************************************************
* McPAT
* SOFTWARE LICENSE AGREEMENT
* Copyright 2012 Hewlett-Packard Development Company, L.P.
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.”
*
***************************************************************************/
#include "interconnect.h"
#include "wire.h"
#include <assert.h>
#include <iostream>
#include "globalvar.h"
interconnect::interconnect(
string name_,
enum Device_ty device_ty_,
double base_w, double base_h,
int data_w, double len,const InputParameter *configure_interface,
int start_wiring_level_,
bool pipelinable_ ,
double route_over_perc_ ,
bool opt_local_,
enum Core_type core_ty_,
enum Wire_type wire_model,
double width_s, double space_s,
TechnologyParameter::DeviceType *dt
)
:name(name_),
device_ty(device_ty_),
in_rise_time(0),
out_rise_time(0),
base_width(base_w),
base_height(base_h),
data_width(data_w),
wt(wire_model),
width_scaling(width_s),
space_scaling(space_s),
start_wiring_level(start_wiring_level_),
length(len),
//interconnect_latency(1e-12),
//interconnect_throughput(1e-12),
opt_local(opt_local_),
core_ty(core_ty_),
pipelinable(pipelinable_),
route_over_perc(route_over_perc_),
deviceType(dt)
{
wt = Global;
l_ip=*configure_interface;
local_result = init_interface(&l_ip);
max_unpipelined_link_delay = 0; //TODO
min_w_nmos = g_tp.min_w_nmos_;
min_w_pmos = deviceType->n_to_p_eff_curr_drv_ratio * min_w_nmos;
latency = l_ip.latency;
throughput = l_ip.throughput;
latency_overflow=false;
throughput_overflow=false;
/*
* TODO: Add wiring option from semi-global to global automatically
* And directly jump to global if semi-global cannot satisfy timing
* Fat wires only available for global wires, thus
* if signal wiring layer starts from semi-global,
* the next layer up will be global, i.e., semi-global does
* not have fat wires.
*/
if (pipelinable == false)
//Non-pipelinable wires, such as bypass logic, care latency
{
compute();
if (opt_for_clk && opt_local)
{
while (delay > latency && width_scaling<3.0)
{
width_scaling *= 2;
space_scaling *= 2;
Wire winit(width_scaling, space_scaling);
compute();
}
if (delay > latency)
{
latency_overflow=true;
}
}
}
else //Pipelinable wires, such as bus, does not care latency but throughput
{
/*
* TODO: Add pipe regs power, area, and timing;
* Pipelinable wires optimize latency first.
*/
compute();
if (opt_for_clk && opt_local)
{
while (delay > throughput && width_scaling<3.0)
{
width_scaling *= 2;
space_scaling *= 2;
Wire winit(width_scaling, space_scaling);
compute();
}
if (delay > throughput)
// insert pipeline stages
{
num_pipe_stages = (int)ceil(delay/throughput);
assert(num_pipe_stages>0);
delay = delay/num_pipe_stages + num_pipe_stages*0.05*delay;
}
}
}
power_bit = power;
power.readOp.dynamic *= data_width;
power.readOp.leakage *= data_width;
power.readOp.gate_leakage *= data_width;
area.set_area(area.get_area()*data_width);
no_device_under_wire_area.h *= data_width;
if (latency_overflow==true)
cout<< "Warning: "<< name <<" wire structure cannot satisfy latency constraint." << endl;
assert(power.readOp.dynamic > 0);
assert(power.readOp.leakage > 0);
assert(power.readOp.gate_leakage > 0);
double long_channel_device_reduction = longer_channel_device_reduction(device_ty,core_ty);
double pg_reduction = power_gating_leakage_reduction(false);//
double sckRation = g_tp.sckt_co_eff;
power.readOp.dynamic *= sckRation;
power.writeOp.dynamic *= sckRation;
power.searchOp.dynamic *= sckRation;
power.readOp.longer_channel_leakage =
power.readOp.leakage*long_channel_device_reduction;
power.readOp.power_gated_leakage =
power.readOp.leakage*pg_reduction;
power.readOp.power_gated_with_long_channel_leakage =
power.readOp.power_gated_leakage*long_channel_device_reduction;
if (pipelinable)//Only global wires has the option to choose whether routing over or not
area.set_area(area.get_area()*route_over_perc + no_device_under_wire_area.get_area()*(1-route_over_perc));
Wire wreset();
}
void
interconnect::compute()
{
Wire *wtemp1 = 0;
wtemp1 = new Wire(wt, length, 1, width_scaling, space_scaling);
delay = wtemp1->delay;
power.readOp.dynamic = wtemp1->power.readOp.dynamic;
power.readOp.leakage = wtemp1->power.readOp.leakage;
power.readOp.gate_leakage = wtemp1->power.readOp.gate_leakage;
area.set_area(wtemp1->area.get_area());
no_device_under_wire_area.h = (wtemp1->wire_width + wtemp1->wire_spacing);
no_device_under_wire_area.w = length;
if (wtemp1)
delete wtemp1;
}
void interconnect::leakage_feedback(double temperature)//TODO: add code for processing power gating
{
l_ip.temp = (unsigned int)round(temperature/10.0)*10;
uca_org_t init_result = init_interface(&l_ip); // init_result is dummy
compute();
power_bit = power;
power.readOp.dynamic *= data_width;
power.readOp.leakage *= data_width;
power.readOp.gate_leakage *= data_width;
assert(power.readOp.dynamic > 0);
assert(power.readOp.leakage > 0);
assert(power.readOp.gate_leakage > 0);
double long_channel_device_reduction = longer_channel_device_reduction(device_ty,core_ty);
double sckRation = g_tp.sckt_co_eff;
power.readOp.dynamic *= sckRation;
power.writeOp.dynamic *= sckRation;
power.searchOp.dynamic *= sckRation;
power.readOp.longer_channel_leakage = power.readOp.leakage*long_channel_device_reduction;
}