Skip to content

Commit 493ffcf

Browse files
Merge branch 'master' into temp_draw_nodes_on_edges
2 parents 946ff29 + 42ccf87 commit 493ffcf

File tree

11 files changed

+60
-72
lines changed

11 files changed

+60
-72
lines changed

libs/libarchfpga/src/physical_types.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,11 +1543,11 @@ enum class e_stat {
15431543
/// @note If detailed routing is performed, only a uniform (all channels in a given direction are the same width)
15441544
/// distribution is supported.
15451545
struct t_chan {
1546-
e_stat type; ///< Distribution type
1547-
float peak; ///< Peak value. For a UNIFORM distribution, this is the value for all channels (in a given direction).
1548-
float width; ///< Standard deviation (Gaussian)
1549-
float xpeak; ///< Peak location (Gaussian)
1550-
float dc; ///< DC offset (Gaussian, pulse)
1546+
e_stat type; ///< Distribution type
1547+
float peak; ///< Peak value. For a UNIFORM distribution, this is the value for all channels (in a given direction).
1548+
float width; ///< Standard deviation (Gaussian)
1549+
float xpeak; ///< Peak location (Gaussian)
1550+
float dc; ///< DC offset (Gaussian, pulse)
15511551
};
15521552

15531553
/* chan_x_dist: Describes the x-directed channel width distribution. *

vpr/src/base/read_blif.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ struct BlifAllocCallback : public blifparse::Callback {
244244
VTR_ASSERT(ports.size() == nets.size());
245245

246246
LogicalModelId blk_model_id = models_.get_model_by_name(subckt_model);
247-
if(!blk_model_id.is_valid()) {
247+
if (!blk_model_id.is_valid()) {
248248
vpr_throw(VPR_ERROR_BLIF_F, filename_.c_str(), lineno_,
249-
"Subckt instantiates model '%s', but no such model exists in the architecture file.",
250-
subckt_model.c_str());
249+
"Subckt instantiates model '%s', but no such model exists in the architecture file.",
250+
subckt_model.c_str());
251251
}
252252
const t_model& blk_model = models_.get_model(blk_model_id);
253253

vpr/src/draw/draw_basic.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,7 @@ void drawplace(ezgl::renderer* g) {
165165
if (draw_state->draw_block_text) {
166166
/* Draw text if the space has parts of the netlist */
167167
if (bnum) {
168-
std::string name = cluster_ctx.clb_nlist.block_name(
169-
bnum)
170-
+ vtr::string_fmt(" (#%zu)", size_t(bnum));
168+
std::string name = cluster_ctx.clb_nlist.block_name(bnum) + vtr::string_fmt(" (#%zu)", size_t(bnum));
171169

172170
g->draw_text(center, name.c_str(), abs_clb_bbox.width(),
173171
abs_clb_bbox.height());

vpr/src/draw/draw_debug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ bool valid_expression(std::string exp) {
772772
vtr::t_formula_data dummy;
773773
try {
774774
int result = fp.parse_formula(exp, dummy, true);
775-
(void)result;
775+
(void)result;
776776
} catch (const vtr::VtrError& e) {
777777
return false;
778778
}

vpr/src/draw/draw_mux.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,32 @@
1919
//Draws a mux, height/width define the bounding box, scale [0.,1.] controls the slope of the muxes sides
2020
ezgl::rectangle draw_mux(ezgl::point2d origin, e_side orientation, float height, float width, float scale, ezgl::renderer* g) {
2121
std::vector<ezgl::point2d> mux_polygon;
22+
mux_polygon.reserve(4);
2223

2324
switch (orientation) {
2425
case TOP:
25-
//Clock-wise from bottom left
26+
// Clock-wise from bottom left
2627
mux_polygon.emplace_back(origin.x - height / 2, origin.y - width / 2);
2728
mux_polygon.emplace_back(origin.x - (scale * height) / 2, origin.y + width / 2);
2829
mux_polygon.emplace_back(origin.x + (scale * height) / 2, origin.y + width / 2);
2930
mux_polygon.emplace_back(origin.x + height / 2, origin.y - width / 2);
3031
break;
3132
case BOTTOM:
32-
//Clock-wise from bottom left
33+
// Clock-wise from bottom left
3334
mux_polygon.emplace_back(origin.x - (scale * height) / 2, origin.y - width / 2);
3435
mux_polygon.emplace_back(origin.x - height / 2, origin.y + width / 2);
3536
mux_polygon.emplace_back(origin.x + height / 2, origin.y + width / 2);
3637
mux_polygon.emplace_back(origin.x + (scale * height) / 2, origin.y - width / 2);
3738
break;
3839
case LEFT:
39-
//Clock-wise from bottom left
40+
// Clock-wise from bottom left
4041
mux_polygon.emplace_back(origin.x - width / 2, origin.y - (scale * height) / 2);
4142
mux_polygon.emplace_back(origin.x - width / 2, origin.y + (scale * height) / 2);
4243
mux_polygon.emplace_back(origin.x + width / 2, origin.y + height / 2);
4344
mux_polygon.emplace_back(origin.x + width / 2, origin.y - height / 2);
4445
break;
4546
case RIGHT:
46-
//Clock-wise from bottom left
47+
// Clock-wise from bottom left
4748
mux_polygon.emplace_back(origin.x - width / 2, origin.y - height / 2);
4849
mux_polygon.emplace_back(origin.x - width / 2, origin.y + height / 2);
4950
mux_polygon.emplace_back(origin.x + width / 2, origin.y + (scale * height) / 2);
@@ -57,7 +58,7 @@ ezgl::rectangle draw_mux(ezgl::point2d origin, e_side orientation, float height,
5758

5859
ezgl::point2d min((float)mux_polygon[0].x, (float)mux_polygon[0].y);
5960
ezgl::point2d max((float)mux_polygon[0].x, (float)mux_polygon[0].y);
60-
for (const auto& point : mux_polygon) {
61+
for (const ezgl::point2d& point : mux_polygon) {
6162
min.x = std::min((float)min.x, (float)point.x);
6263
min.y = std::min((float)min.y, (float)point.y);
6364
max.x = std::max((float)max.x, (float)point.x);

vpr/src/draw/draw_mux.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77

88
#ifndef NO_GRAPHICS
99

10-
#include <cstdio>
11-
#include <cfloat>
12-
#include <cstring>
13-
#include <cmath>
14-
1510
#include "ezgl/point.hpp"
1611
#include "ezgl/graphics.hpp"
1712
#include "physical_types.h"

vpr/src/draw/draw_rr.cpp

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,11 @@ void draw_rr_chan(RRNodeId inode, const ezgl::color color, ezgl::renderer* g) {
242242
g->set_color(color, transparency_factor); //Ensure color is still set correctly if we drew any arrows/text
243243
}
244244

245-
/* Draws all the edges that the user wants shown between inode and what it
246-
* connects to. inode is assumed to be a CHANX, CHANY, or IPIN. */
247245
void draw_rr_edges(RRNodeId inode, ezgl::renderer* g) {
248246
t_draw_state* draw_state = get_draw_state_vars();
249247
const DeviceContext& device_ctx = g_vpr_ctx.device();
250248
const RRGraphView& rr_graph = device_ctx.rr_graph;
251249

252-
e_rr_type to_type;
253250
e_rr_type from_type = rr_graph.node_type(inode);
254251

255252
// Currently don't visualize source or sinks.
@@ -259,45 +256,22 @@ void draw_rr_edges(RRNodeId inode, ezgl::renderer* g) {
259256

260257
for (t_edge_size iedge = 0, l = rr_graph.num_edges(inode); iedge < l; iedge++) {
261258
RRNodeId to_node = rr_graph.edge_sink_node(inode, iedge);
262-
to_type = rr_graph.node_type(to_node);
259+
e_rr_type to_type = rr_graph.node_type(to_node);
263260
bool edge_configurable = rr_graph.edge_is_configurable(inode, iedge);
264261

265262
// Currently don't visualize source or sinks.
266263
if (to_type == e_rr_type::SOURCE || to_type == e_rr_type::SINK) {
267264
continue;
268265
}
269266

270-
ezgl::color color = DEFAULT_RR_NODE_COLOR;
271-
e_edge_type edge_type;
272267
bool draw_edge = true;
273268
bool inode_inter_cluster = is_inter_cluster_node(rr_graph, inode);
274269
bool to_node_inter_cluster = is_inter_cluster_node(rr_graph, to_node);
275270

276-
// Color map for edges based on {from_type, to_type}
277-
const std::map<std::pair<e_rr_type, e_rr_type>, e_edge_type> edge_type_map = {
278-
// Pin to pin connections
279-
{{e_rr_type::IPIN, e_rr_type::IPIN}, e_edge_type::PIN_TO_IPIN},
280-
{{e_rr_type::OPIN, e_rr_type::IPIN}, e_edge_type::PIN_TO_IPIN},
281-
{{e_rr_type::OPIN, e_rr_type::OPIN}, e_edge_type::PIN_TO_OPIN},
282-
{{e_rr_type::IPIN, e_rr_type::OPIN}, e_edge_type::PIN_TO_OPIN},
283-
284-
// Channel to pin connections
285-
{{e_rr_type::OPIN, e_rr_type::CHANX}, e_edge_type::OPIN_TO_CHAN},
286-
{{e_rr_type::OPIN, e_rr_type::CHANY}, e_edge_type::OPIN_TO_CHAN},
287-
{{e_rr_type::CHANX, e_rr_type::IPIN}, e_edge_type::CHAN_TO_IPIN},
288-
{{e_rr_type::CHANY, e_rr_type::IPIN}, e_edge_type::CHAN_TO_IPIN},
289-
290-
// Channel to channel connections
291-
{{e_rr_type::CHANX, e_rr_type::CHANX}, e_edge_type::CHAN_TO_CHAN},
292-
{{e_rr_type::CHANX, e_rr_type::CHANY}, e_edge_type::CHAN_TO_CHAN},
293-
{{e_rr_type::CHANY, e_rr_type::CHANY}, e_edge_type::CHAN_TO_CHAN},
294-
{{e_rr_type::CHANY, e_rr_type::CHANX}, e_edge_type::CHAN_TO_CHAN},
295-
};
296-
297-
if (edge_type_map.find({from_type, to_type}) == edge_type_map.end()) {
271+
if (EDGE_TYPE_MAP.find({from_type, to_type}) == EDGE_TYPE_MAP.end()) {
298272
continue; // Unsupported edge type
299273
}
300-
edge_type = edge_type_map.at({from_type, to_type});
274+
e_edge_type edge_type = EDGE_TYPE_MAP.at({from_type, to_type});
301275

302276
// Determine whether to draw the edge based on user options
303277

@@ -318,17 +292,11 @@ void draw_rr_edges(RRNodeId inode, ezgl::renderer* g) {
318292
draw_edge = draw_state->draw_connection_box_edges;
319293
}
320294

321-
// Select edge colors
322-
const std::map<e_edge_type, ezgl::color> edge_color_map = {
323-
{e_edge_type::PIN_TO_OPIN, ezgl::LIGHT_PINK},
324-
{e_edge_type::PIN_TO_IPIN, ezgl::MEDIUM_PURPLE},
325-
{e_edge_type::OPIN_TO_CHAN, ezgl::PINK},
326-
{e_edge_type::CHAN_TO_IPIN, ezgl::PURPLE},
327-
{e_edge_type::CHAN_TO_CHAN, blk_DARKGREEN}};
295+
ezgl::color color = EDGE_COLOR_MAP.at(edge_type);
328296

329-
color = edge_color_map.at(edge_type);
330-
331-
if (!edge_configurable) color = blk_DARKGREY;
297+
if (!edge_configurable) {
298+
color = blk_DARKGREY;
299+
}
332300

333301
if ((from_type == e_rr_type::CHANX || from_type == e_rr_type::CHANY)
334302
&& (to_type == e_rr_type::IPIN)

vpr/src/draw/draw_rr.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,29 @@
2323
*/
2424
void draw_rr(ezgl::renderer* g);
2525

26-
/* Draws all the edges that the user wants shown between inode and what it
27-
* connects to. inode is assumed to be a CHANX, CHANY, or IPIN. */
26+
/// @brief Draws all the edges that the user wants shown between @p from_node and what it
27+
/// connects to. @p from_node is assumed to be a CHANX, CHANY, or IPIN.
2828
void draw_rr_edges(RRNodeId from_node, ezgl::renderer* g);
2929

30+
/// Maps (from_type, to_type) pairs to an edge type used for drawing or classification.
31+
inline const std::map<std::pair<e_rr_type, e_rr_type>, e_edge_type> EDGE_TYPE_MAP = {
32+
// Pin to pin connections
33+
{{e_rr_type::IPIN, e_rr_type::IPIN}, e_edge_type::PIN_TO_IPIN},
34+
{{e_rr_type::OPIN, e_rr_type::IPIN}, e_edge_type::PIN_TO_IPIN},
35+
{{e_rr_type::OPIN, e_rr_type::OPIN}, e_edge_type::PIN_TO_OPIN},
36+
{{e_rr_type::IPIN, e_rr_type::OPIN}, e_edge_type::PIN_TO_OPIN},
37+
// Channel to pin connections
38+
{{e_rr_type::OPIN, e_rr_type::CHANX}, e_edge_type::OPIN_TO_CHAN},
39+
{{e_rr_type::OPIN, e_rr_type::CHANY}, e_edge_type::OPIN_TO_CHAN},
40+
{{e_rr_type::CHANX, e_rr_type::IPIN}, e_edge_type::CHAN_TO_IPIN},
41+
{{e_rr_type::CHANY, e_rr_type::IPIN}, e_edge_type::CHAN_TO_IPIN},
42+
// Channel to channel connections
43+
{{e_rr_type::CHANX, e_rr_type::CHANX}, e_edge_type::CHAN_TO_CHAN},
44+
{{e_rr_type::CHANX, e_rr_type::CHANY}, e_edge_type::CHAN_TO_CHAN},
45+
{{e_rr_type::CHANY, e_rr_type::CHANY}, e_edge_type::CHAN_TO_CHAN},
46+
{{e_rr_type::CHANY, e_rr_type::CHANX}, e_edge_type::CHAN_TO_CHAN},
47+
};
48+
3049
void draw_rr_chan(RRNodeId inode, const ezgl::color color, ezgl::renderer* g);
3150

3251
/**

vpr/src/draw/draw_types.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "ezgl/rectangle.hpp"
3232
#include "ezgl/color.hpp"
3333
#include "ezgl/application.hpp"
34+
#include "draw_color.h"
3435

3536
/// @brief Whether to draw routed nets or flylines (direct lines between sources and sinks).
3637
enum e_draw_nets {
@@ -124,6 +125,14 @@ enum class e_edge_type {
124125
NUM_EDGE_TYPES
125126
};
126127

128+
/// Maps edge types to the color with which they are visualized
129+
inline const vtr::array<e_edge_type, ezgl::color, (size_t)e_edge_type::NUM_EDGE_TYPES> EDGE_COLOR_MAP{
130+
ezgl::LIGHT_PINK,
131+
ezgl::MEDIUM_PURPLE,
132+
ezgl::PINK,
133+
ezgl::PURPLE,
134+
blk_DARKGREEN};
135+
127136
/**
128137
* @brief Structure used to hold data passed into the toggle checkbox callback function.
129138
*/

vpr/src/route/rr_graph_generation/build_scatter_gathers.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,11 @@ std::vector<t_bottleneck_link> alloc_and_load_scatter_gather_connections(const s
210210
scatter_loc.y = gather_loc.y + sg_link.y_offset;
211211
scatter_loc.layer_num = gather_loc.layer_num + sg_link.z_offset;
212212

213-
const std::vector<t_segment_inf>& segment_inf = (sg_link.x_offset != 0) ? segment_inf_x :
214-
(sg_link.y_offset != 0) ? segment_inf_y : segment_inf_z;
215-
216-
const e_rr_type chan_type = (sg_link.x_offset != 0) ? e_rr_type::CHANX :
217-
(sg_link.y_offset != 0) ? e_rr_type::CHANY : e_rr_type::CHANZ;
213+
const std::vector<t_segment_inf>& segment_inf = (sg_link.x_offset != 0) ? segment_inf_x : (sg_link.y_offset != 0) ? segment_inf_y
214+
: segment_inf_z;
218215

216+
const e_rr_type chan_type = (sg_link.x_offset != 0) ? e_rr_type::CHANX : (sg_link.y_offset != 0) ? e_rr_type::CHANY
217+
: e_rr_type::CHANZ;
219218

220219
auto seg_it = std::ranges::find_if(segment_inf,
221220
[&](const t_segment_inf& seg) noexcept {
@@ -225,7 +224,6 @@ std::vector<t_bottleneck_link> alloc_and_load_scatter_gather_connections(const s
225224
VTR_ASSERT(seg_it != segment_inf.end());
226225
const t_segment_inf& wire_segment = *seg_it;
227226

228-
229227
index_to_correct_sg_channels(sg_pattern.gather_pattern, gather_loc, chan_details_x, chan_details_y, gather_channels);
230228
index_to_correct_sg_channels(sg_pattern.scatter_pattern, scatter_loc, chan_details_x, chan_details_y, scatter_channels);
231229

0 commit comments

Comments
 (0)