Skip to content

Commit 063a429

Browse files
committed
Added Switchs into reverse lookup
1 parent f07fd66 commit 063a429

File tree

4 files changed

+100
-68
lines changed

4 files changed

+100
-68
lines changed

vpr/src/route/clock_network_types.cpp

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,19 @@ void ClockRib::set_drive_switch(int switch_idx) {
7373
drive.switch_idx = switch_idx;
7474
}
7575

76+
void ClockRib::set_drive_name(std::string name) {
77+
drive.name = name;
78+
}
79+
7680
void ClockRib::set_tap_locations(int offset_x, int increment_x) {
7781
tap.offset = offset_x;
7882
tap.increment = increment_x;
7983
}
8084

85+
void ClockRib::set_tap_name(std::string name) {
86+
tap.name = name;
87+
}
88+
8189
/*
8290
* ClockRib (member functions)
8391
*/
@@ -98,7 +106,7 @@ void ClockRib::create_rr_nodes_for_one_instance(int inst_num, ClockRRGraph& cloc
98106
int drive_x = x_start + drive.offset;
99107
// create drive point (length zero wire)
100108
auto drive_node_idx = create_chanx_wire(drive_x, drive_x, y, ptc_num, rr_nodes);
101-
clock_graph.add_switch_location(get_name(), "drive", drive_x, y, drive_node_idx);
109+
clock_graph.add_switch_location(get_name(), drive.name, drive_x, y, drive_node_idx);
102110

103111
// create rib wire to the right and left of the drive point
104112
auto left_node_idx = create_chanx_wire(x_start, drive_x, y, ptc_num, rr_nodes);
@@ -139,12 +147,11 @@ void ClockRib::record_tap_locations(
139147
int right_rr_node_idx,
140148
ClockRRGraph& clock_graph)
141149
{
142-
std::string tap_name = "tap"; // only supporting one tap
143150
for(unsigned x = x_start+tap.offset; x <= x_end; x+=tap.increment) {
144151
if(x < x_start + drive.offset) {
145-
clock_graph.add_switch_location(get_name(), tap_name, x, y, left_rr_node_idx);
152+
clock_graph.add_switch_location(get_name(), tap.name, x, y, left_rr_node_idx);
146153
} else {
147-
clock_graph.add_switch_location(get_name(), tap_name, x, y, right_rr_node_idx);
154+
clock_graph.add_switch_location(get_name(), tap.name, x, y, right_rr_node_idx);
148155
}
149156
}
150157
}
@@ -188,11 +195,19 @@ void ClockSpine::set_drive_switch(int switch_idx) {
188195
drive.switch_idx = switch_idx;
189196
}
190197

198+
void ClockSpine::set_drive_name(std::string name) {
199+
drive.name = name;
200+
}
201+
191202
void ClockSpine::set_tap_locations(int offset_y, int increment_y) {
192203
tap.offset = offset_y;
193204
tap.increment = increment_y;
194205
}
195206

207+
void ClockSpine::set_tap_name(std::string name) {
208+
tap.name = name;
209+
}
210+
196211
/*
197212
* ClockSpine (member functions)
198213
*/
@@ -203,14 +218,27 @@ void ClockSpine::create_rr_nodes_for_one_instance(int inst_num, ClockRRGraph& cl
203218
auto& rr_nodes = device_ctx.rr_nodes;
204219
auto& grid = device_ctx.grid;
205220

206-
int ptc_num = inst_num;
221+
int ptc_num = inst_num + 50;
207222

208-
for(unsigned y_start = y_chan_wire.start, y_end = y_chan_wire.end;
209-
y_end < grid.height();
223+
for(unsigned y_start = y_chan_wire.start + 1, y_end = y_chan_wire.end;
224+
y_end < grid.height() - 1;
210225
y_start += repeat.y, y_end += repeat.y) {
211-
for(unsigned x = y_chan_wire.position; x < grid.width(); x += repeat.x) {
212-
auto rr_node_index = create_chany_wire(y_start, y_end, x, ptc_num, rr_nodes);
213-
record_switch_point_locations_for_rr_node(y_start, y_end, x, rr_node_index, clock_graph);
226+
for(unsigned x = y_chan_wire.position; x < grid.width() - 1; x += repeat.x) {
227+
228+
int drive_y = y_start + drive.offset;
229+
//create drive point (length zero wire)
230+
auto drive_node_idx = create_chany_wire(drive_y, drive_y, x, ptc_num, rr_nodes);
231+
clock_graph.add_switch_location(get_name(), drive.name, x, drive_y, drive_node_idx);
232+
233+
// create spine wire to the right and left of the drive point
234+
auto left_node_idx = create_chany_wire(y_start, drive_y, x, ptc_num, rr_nodes);
235+
auto right_node_idx = create_chany_wire(drive_y, y_end, x, ptc_num, rr_nodes);
236+
237+
record_tap_locations(y_start, y_end, x, left_node_idx, right_node_idx, clock_graph);
238+
239+
// connect drive point to each half spine using a directed switch
240+
rr_nodes[drive_node_idx].add_edge(left_node_idx, drive.switch_idx);
241+
rr_nodes[drive_node_idx].add_edge(right_node_idx, drive.switch_idx);
214242
}
215243
}
216244
}
@@ -233,13 +261,21 @@ int ClockSpine::create_chany_wire(
233261
return node_index;
234262
}
235263

236-
void ClockSpine::record_switch_point_locations_for_rr_node(
237-
int y_start,
238-
int y_end,
239-
int x,
240-
int rr_node_index,
241-
ClockRRGraph& clock_graph) {
242-
264+
void ClockSpine::record_tap_locations(
265+
unsigned y_start,
266+
unsigned y_end,
267+
unsigned x,
268+
int left_node_idx,
269+
int right_node_idx,
270+
ClockRRGraph& clock_graph)
271+
{
272+
for (unsigned y = y_start+tap.offset; y <= y_end; y+=tap.increment) {
273+
if(y < y_start + drive.offset) {
274+
clock_graph.add_switch_location(get_name(), tap.name, x, y, left_node_idx);
275+
} else {
276+
clock_graph.add_switch_location(get_name(), tap.name, x, y, right_node_idx);
277+
}
278+
}
243279
}
244280

245281

vpr/src/route/clock_network_types.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,37 @@ struct WireRepeat {
3434
};
3535

3636
struct RibDrive {
37+
std::string name;
3738
int offset;
3839
int switch_idx;
3940
};
4041

4142
struct RibTaps {
43+
std::string name;
4244
int offset;
4345
int increment;
4446
};
4547

4648
struct SpineDrive {
49+
std::string name;
4750
int offset;
4851
int switch_idx;
4952
};
5053

5154
struct SpineTaps {
55+
std::string name;
5256
int offset;
5357
int increment;
5458
};
5559

5660
struct HtreeDrive {
61+
std::string name;
5762
Point offset;
5863
int switch_idx;
5964
};
6065

6166
struct HtreeTaps {
67+
std::string name;
6268
Point offset;
6369
Point increment;
6470
};
@@ -126,7 +132,9 @@ class ClockRib : public ClockNetwork {
126132
void set_wire_repeat(int repeat_x, int repeat_y);
127133
void set_drive_location(int offset_x);
128134
void set_drive_switch(int switch_idx);
135+
void set_drive_name(std::string name);
129136
void set_tap_locations(int offset_x, int increment_x);
137+
void set_tap_name(std::string name);
130138

131139
/*
132140
* Member functions
@@ -174,7 +182,9 @@ class ClockSpine : public ClockNetwork {
174182
void set_wire_repeat(int repeat_x, int repeat_y);
175183
void set_drive_location(int offset_y);
176184
void set_drive_switch(int switch_idx);
185+
void set_drive_name(std::string name);
177186
void set_tap_locations(int offset_y, int increment_y);
187+
void set_tap_name(std::string name);
178188

179189
/*
180190
* Member functions
@@ -186,11 +196,12 @@ class ClockSpine : public ClockNetwork {
186196
int x,
187197
int ptc_num,
188198
std::vector<t_rr_node>& rr_nodes);
189-
void record_switch_point_locations_for_rr_node(
190-
int y_start,
191-
int y_end,
192-
int x,
193-
int rr_node_index,
199+
void record_tap_locations(
200+
unsigned y_start,
201+
unsigned y_end,
202+
unsigned x,
203+
int left_node_idx,
204+
int right_node_idx,
194205
ClockRRGraph& clock_graph);
195206

196207
};

vpr/src/route/rr_graph_clock.cpp

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ void ClockRRGraph::create_and_append_clock_rr_graph() {
3232
rib->set_wire_repeat(9, 1);
3333
rib->set_drive_location(5);
3434
rib->set_drive_switch(2);
35+
rib->set_drive_name("drive");
3536
rib->set_tap_locations(0,1);
37+
rib->set_tap_name("tap");
3638

3739
// Clock Spines
3840
clock_networks.emplace_back(new ClockSpine());
@@ -41,14 +43,16 @@ void ClockRRGraph::create_and_append_clock_rr_graph() {
4143
spine->set_num_instance(10);
4244
spine->set_clock_name("spine1");
4345
spine->set_metal_layer(0,0);
44-
spine->set_initial_wire_location(0,10,5);
45-
spine->set_wire_repeat(10,10);
46+
spine->set_initial_wire_location(0,9,5);
47+
spine->set_wire_repeat(10,9);
4648
spine->set_drive_location(5);
4749
spine->set_drive_switch(2);
50+
spine->set_drive_name("drive");
4851
spine->set_tap_locations(0,1);
52+
spine->set_tap_name("tap");
4953

5054
ClockRRGraph clock_graph = ClockRRGraph();
51-
clock_graph.allocate_lookup(clock_networks);
55+
// clock_graph.allocate_lookup(clock_networks);
5256
clock_graph.create_clock_networks_wires(clock_networks);
5357

5458
// std::vector<ClockConnection> clock_routing;
@@ -67,38 +71,37 @@ void ClockRRGraph::create_clock_networks_wires(
6771
}
6872
}
6973

70-
void ClockRRGraph::allocate_lookup(const std::vector<std::unique_ptr<ClockNetwork>>& clock_networks) {
71-
72-
auto& grid = g_vpr_ctx.mutable_device().grid;
73-
74-
for(auto& clock_network : clock_networks) {
75-
76-
SwitchPoints switch_points;
77-
78-
/* TODO: loop over all switchs and insert into map. */
79-
// Currently only supporting two switch points
80-
// Single Drive
81-
std::string drive_switch_name = "drive";
82-
SwitchPoint drive_switch_locations(grid.width(), grid.height());
83-
switch_points.insert_switch(drive_switch_name, drive_switch_locations);
84-
// Single Tap
85-
std::string tap_switch_name = "tap";
86-
SwitchPoint tap_switch_locations(grid.width(), grid.height());
87-
switch_points.insert_switch(tap_switch_name, tap_switch_locations);
88-
89-
clock_name_to_switch_points.emplace(clock_network->get_name(), switch_points);
90-
}
91-
}
92-
9374
void ClockRRGraph::add_switch_location(
9475
std::string clock_name,
9576
std::string switch_name,
9677
int x,
9778
int y,
9879
int node_index) {
80+
// Note use of operator[] will automatically insert clock name if it doesn't exist
9981
clock_name_to_switch_points[clock_name].insert_switch_node_idx(switch_name, x, y, node_index);
10082
}
10183

84+
void SwitchPoints::insert_switch_node_idx(std::string switch_name, int x, int y, int node_idx) {
85+
// Note use of operator[] will automatically insert switch name if it doesn't exit
86+
switch_name_to_switch_location[switch_name].insert_node_idx(x, y, node_idx);
87+
}
88+
89+
void SwitchPoint::insert_node_idx(int x, int y, int node_idx) {
90+
91+
// allocate 2d vector of grid size
92+
if (rr_node_indices.empty()) {
93+
auto& grid = g_vpr_ctx.device().grid;
94+
rr_node_indices.resize(grid.width());
95+
for (size_t i = 0; i < grid.width(); i++) {
96+
rr_node_indices[i].resize(grid.height());
97+
}
98+
}
99+
100+
// insert node_idx at location
101+
rr_node_indices[x][y].push_back(node_idx);
102+
Coordinates location = {x, y};
103+
locations.push_back(location);
104+
}
102105

103106
//void ClockRRGraph::create_star_model_network() {
104107
//

vpr/src/route/rr_graph_clock.h

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,7 @@ class SwitchPoint {
3535
std::vector<std::vector<std::vector<int>>> rr_node_indices;
3636
std::vector<Coordinates> locations;
3737
public:
38-
/*
39-
* Constructors
40-
*/
41-
SwitchPoint() {};
42-
SwitchPoint(int grid_width, int grid_height) :
43-
rr_node_indices(
44-
grid_width,
45-
std::vector<std::vector<int>>(grid_height, std::vector<int>())) {};
46-
void insert_node_idx(int x, int y, int node_idx) {
47-
rr_node_indices[x][y].push_back(node_idx);
48-
Coordinates location = {x, y};
49-
locations.push_back(location);
50-
}
38+
void insert_node_idx(int x, int y, int node_idx);
5139
};
5240

5341
class SwitchPoints {
@@ -57,13 +45,7 @@ class SwitchPoints {
5745
/** Getters **/
5846

5947
/** Setters **/
60-
void insert_switch(std::string switch_name, SwitchPoint switch_point) {
61-
// TODO make sure every switch name is unique
62-
switch_name_to_switch_location.emplace(switch_name, switch_point);
63-
}
64-
void insert_switch_node_idx(std::string switch_name, int x, int y, int node_index) {
65-
switch_name_to_switch_location[switch_name].insert_node_idx(x, y, node_index);
66-
}
48+
void insert_switch_node_idx(std::string switch_name, int x, int y, int node_idx);
6749
};
6850

6951
class ClockRRGraph {

0 commit comments

Comments
 (0)