Skip to content

Commit 8670e22

Browse files
committed
Clock Modeling: Refactored load_rr_switch_inf for code reuse
1 parent 5c0bde0 commit 8670e22

File tree

3 files changed

+44
-45
lines changed

3 files changed

+44
-45
lines changed

vpr/src/route/rr_graph.cpp

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -851,32 +851,44 @@ static void load_rr_switch_inf(const int num_arch_switches, const float R_minW_n
851851
// setup device_ctx.switch_fanin_remap, for future swich usage analysis
852852
device_ctx.switch_fanin_remap[i_arch_switch][fanin] = i_rr_switch;
853853

854-
/* figure out, by looking at the arch switch's Tdel map, what the delay of the new
855-
rr switch should be */
856-
double rr_switch_Tdel = device_ctx.arch_switch_inf[i_arch_switch].Tdel(fanin);
857-
858-
/* copy over the arch switch to rr_switch_inf[i_rr_switch], but with the changed Tdel value */
859-
device_ctx.rr_switch_inf[i_rr_switch].set_type(device_ctx.arch_switch_inf[i_arch_switch].type());
860-
device_ctx.rr_switch_inf[i_rr_switch].R = device_ctx.arch_switch_inf[i_arch_switch].R;
861-
device_ctx.rr_switch_inf[i_rr_switch].Cin = device_ctx.arch_switch_inf[i_arch_switch].Cin;
862-
device_ctx.rr_switch_inf[i_rr_switch].Cout = device_ctx.arch_switch_inf[i_arch_switch].Cout;
863-
device_ctx.rr_switch_inf[i_rr_switch].Tdel = rr_switch_Tdel;
864-
device_ctx.rr_switch_inf[i_rr_switch].mux_trans_size = device_ctx.arch_switch_inf[i_arch_switch].mux_trans_size;
865-
if (device_ctx.arch_switch_inf[i_arch_switch].buf_size_type == BufferSize::AUTO) {
866-
//Size based on resistance
867-
device_ctx.rr_switch_inf[i_rr_switch].buf_size = trans_per_buf(device_ctx.arch_switch_inf[i_arch_switch].R, R_minW_nmos, R_minW_pmos);
868-
} else {
869-
VTR_ASSERT(device_ctx.arch_switch_inf[i_arch_switch].buf_size_type == BufferSize::ABSOLUTE);
870-
//Use the specified size
871-
device_ctx.rr_switch_inf[i_rr_switch].buf_size = device_ctx.arch_switch_inf[i_arch_switch].buf_size;
872-
}
873-
device_ctx.rr_switch_inf[i_rr_switch].name = device_ctx.arch_switch_inf[i_arch_switch].name;
874-
device_ctx.rr_switch_inf[i_rr_switch].power_buffer_type = device_ctx.arch_switch_inf[i_arch_switch].power_buffer_type;
875-
device_ctx.rr_switch_inf[i_rr_switch].power_buffer_size = device_ctx.arch_switch_inf[i_arch_switch].power_buffer_size;
854+
add_rr_switch(i_arch_switch, i_rr_switch, fanin, R_minW_nmos, R_minW_pmos);
876855
}
877856
}
878857
}
879858

859+
void add_rr_switch(
860+
int arch_switch_idx,
861+
int rr_switch_idx,
862+
int fanin,
863+
const float R_minW_nmos,
864+
const float R_minW_pmos)
865+
{
866+
auto& device_ctx = g_vpr_ctx.mutable_device();
867+
868+
/* figure out, by looking at the arch switch's Tdel map, what the delay of the new
869+
rr switch should be */
870+
double rr_switch_Tdel = device_ctx.arch_switch_inf[arch_switch_idx].Tdel(fanin);
871+
872+
/* copy over the arch switch to rr_switch_inf[rr_switch_idx], but with the changed Tdel value */
873+
device_ctx.rr_switch_inf[rr_switch_idx].set_type(device_ctx.arch_switch_inf[arch_switch_idx].type());
874+
device_ctx.rr_switch_inf[rr_switch_idx].R = device_ctx.arch_switch_inf[arch_switch_idx].R;
875+
device_ctx.rr_switch_inf[rr_switch_idx].Cin = device_ctx.arch_switch_inf[arch_switch_idx].Cin;
876+
device_ctx.rr_switch_inf[rr_switch_idx].Cout = device_ctx.arch_switch_inf[arch_switch_idx].Cout;
877+
device_ctx.rr_switch_inf[rr_switch_idx].Tdel = rr_switch_Tdel;
878+
device_ctx.rr_switch_inf[rr_switch_idx].mux_trans_size = device_ctx.arch_switch_inf[arch_switch_idx].mux_trans_size;
879+
if (device_ctx.arch_switch_inf[arch_switch_idx].buf_size_type == BufferSize::AUTO) {
880+
//Size based on resistance
881+
device_ctx.rr_switch_inf[rr_switch_idx].buf_size = trans_per_buf(device_ctx.arch_switch_inf[arch_switch_idx].R, R_minW_nmos, R_minW_pmos);
882+
} else {
883+
VTR_ASSERT(device_ctx.arch_switch_inf[arch_switch_idx].buf_size_type == BufferSize::ABSOLUTE);
884+
//Use the specified size
885+
device_ctx.rr_switch_inf[rr_switch_idx].buf_size = device_ctx.arch_switch_inf[arch_switch_idx].buf_size;
886+
}
887+
device_ctx.rr_switch_inf[rr_switch_idx].name = device_ctx.arch_switch_inf[arch_switch_idx].name;
888+
device_ctx.rr_switch_inf[rr_switch_idx].power_buffer_type = device_ctx.arch_switch_inf[arch_switch_idx].power_buffer_type;
889+
device_ctx.rr_switch_inf[rr_switch_idx].power_buffer_size = device_ctx.arch_switch_inf[arch_switch_idx].power_buffer_size;
890+
}
891+
880892
/* switch indices of each rr_node original point into the global device_ctx.arch_switch_inf array.
881893
now we want to remap these indices to point into the global device_ctx.rr_switch_inf array
882894
which contains switch info at different fan-in values */

vpr/src/route/rr_graph.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,13 @@ void print_rr_node(FILE *fp, const std::vector<t_rr_node> &L_rr_node, int inode)
5555

5656
void init_fan_in(std::vector<t_rr_node>& L_rr_node, const int num_rr_nodes);
5757

58+
// Sets the spec for the rr_switch based on the arch switch
59+
void add_rr_switch(
60+
int arch_switch_idx,
61+
int rr_switch_idx,
62+
int fanin,
63+
const float R_minW_nmos,
64+
const float R_minW_pmos);
65+
5866
#endif
5967

vpr/src/route/rr_graph_clock.cpp

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -123,32 +123,11 @@ int ClockRRGraphBuilder::add_rr_switch_from_arch_switch_inf(
123123
int rr_switch_idx = rr_switch_inf.size() - 1;
124124

125125
// TODO: Add support for non fixed Tdel based on fanin information
126+
// and move assigning Tdel into add_rr_switch
126127
VTR_ASSERT(arch_switch_inf[arch_switch_idx].fixed_Tdel());
127128
int fanin = UNDEFINED;
128129

129-
rr_switch_inf[rr_switch_idx].set_type(arch_switch_inf[arch_switch_idx].type());
130-
rr_switch_inf[rr_switch_idx].R = arch_switch_inf[arch_switch_idx].R;
131-
rr_switch_inf[rr_switch_idx].Cin = arch_switch_inf[arch_switch_idx].Cin;
132-
rr_switch_inf[rr_switch_idx].Cout = arch_switch_inf[arch_switch_idx].Cout;
133-
rr_switch_inf[rr_switch_idx].Tdel = arch_switch_inf[arch_switch_idx].Tdel(fanin);
134-
rr_switch_inf[rr_switch_idx].mux_trans_size = arch_switch_inf[arch_switch_idx].mux_trans_size;
135-
136-
if (device_ctx.arch_switch_inf[arch_switch_idx].buf_size_type == BufferSize::AUTO) {
137-
//Size based on resistance
138-
device_ctx.rr_switch_inf[rr_switch_idx].buf_size =
139-
trans_per_buf(device_ctx.arch_switch_inf[arch_switch_idx].R, R_minW_nmos, R_minW_pmos);
140-
} else {
141-
VTR_ASSERT(device_ctx.arch_switch_inf[arch_switch_idx].buf_size_type==BufferSize::ABSOLUTE);
142-
//Use the specified size
143-
device_ctx.rr_switch_inf[rr_switch_idx].buf_size =
144-
device_ctx.arch_switch_inf[arch_switch_idx].buf_size;
145-
}
146-
147-
rr_switch_inf[rr_switch_idx].name = arch_switch_inf[arch_switch_idx].name;
148-
rr_switch_inf[rr_switch_idx].power_buffer_type =
149-
arch_switch_inf[arch_switch_idx].power_buffer_type;
150-
rr_switch_inf[rr_switch_idx].power_buffer_size =
151-
arch_switch_inf[arch_switch_idx].power_buffer_size;
130+
add_rr_switch(arch_switch_idx, rr_switch_idx, fanin, R_minW_nmos, R_minW_pmos);
152131

153132
return rr_switch_idx;
154133
}

0 commit comments

Comments
 (0)