Skip to content

Commit c1b4cac

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix_mult
2 parents 5725a22 + 0c2672e commit c1b4cac

File tree

12 files changed

+81
-81
lines changed

12 files changed

+81
-81
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. *

libs/librrgraph/src/base/rr_graph_storage.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ class edge_sort_iterator {
173173
return &this->swapper_;
174174
}
175175

176+
edge_swapper& operator[](ssize_t n) const {
177+
return *(*this + n);
178+
}
179+
176180
edge_sort_iterator& operator+=(ssize_t n) {
177181
swapper_.idx_ += n;
178182
return *this;

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: 8 additions & 8 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);
@@ -78,11 +79,10 @@ ezgl::rectangle draw_mux(ezgl::point2d origin, e_side orientation, float height,
7879
*/
7980
void draw_mux_with_size(ezgl::point2d origin, e_side orientation, float height, int size, int transparency_factor, ezgl::renderer* g) {
8081
g->set_color(ezgl::YELLOW, transparency_factor);
81-
auto bounds = draw_mux(origin, orientation, height, g);
82+
ezgl::rectangle bounds = draw_mux(origin, orientation, height, g);
8283

8384
g->set_color(ezgl::BLACK, transparency_factor);
84-
g->draw_text(bounds.center(), std::to_string(size), bounds.width(),
85-
bounds.height());
85+
g->draw_text(bounds.center(), std::to_string(size), bounds.width(), bounds.height());
8686
}
8787

8888
#endif

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: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,32 @@ void draw_rr(ezgl::renderer* g) {
5151

5252
g->set_line_dash(ezgl::line_dash::none);
5353

54+
// Node colors by types
55+
// colors for Source, Sink, IPIN, OPIN, CHANX, CHANY, MUX, CHANZ
56+
constexpr vtr::array<e_rr_type, ezgl::color, (size_t)e_rr_type::NUM_RR_TYPES> node_colors{DEFAULT_RR_NODE_COLOR,
57+
DEFAULT_RR_NODE_COLOR,
58+
ezgl::PURPLE,
59+
ezgl::PINK,
60+
DEFAULT_RR_NODE_COLOR,
61+
DEFAULT_RR_NODE_COLOR,
62+
DEFAULT_RR_NODE_COLOR,
63+
DEFAULT_RR_NODE_COLOR};
64+
65+
// Draw edges first, then nodes, so that nodes (and their muxes) are rendered on top of edges.
5466
for (const RRNodeId inode : device_ctx.rr_graph.nodes()) {
67+
draw_rr_edges(inode, g);
68+
}
5569

70+
for (const RRNodeId inode : device_ctx.rr_graph.nodes()) {
5671
e_rr_type node_type = rr_graph.node_type(inode);
5772
bool inter_cluster_node = is_inter_cluster_node(rr_graph, inode);
5873
bool node_highlighted = draw_state->draw_rr_node[inode].node_highlighted;
5974

60-
// Node colors by types
61-
// colors for Source, Sink, IPIN, OPIN, CHANX, CHANY, MUX, CHANZ
62-
constexpr vtr::array<e_rr_type, ezgl::color, (size_t)e_rr_type::NUM_RR_TYPES> node_colors{DEFAULT_RR_NODE_COLOR, DEFAULT_RR_NODE_COLOR, ezgl::PURPLE, ezgl::PINK, DEFAULT_RR_NODE_COLOR, DEFAULT_RR_NODE_COLOR, DEFAULT_RR_NODE_COLOR, DEFAULT_RR_NODE_COLOR};
63-
6475
// Apply color to the node if it is not highlighted
6576
if (!node_highlighted) {
6677
draw_state->draw_rr_node[inode].color = node_colors.at(node_type);
6778
}
6879

69-
draw_rr_edges(inode, g);
70-
7180
if (!node_highlighted) {
7281
// Draw channel nodes if enabled
7382
if ((node_type == e_rr_type::CHANX || node_type == e_rr_type::CHANY) && !draw_state->draw_channel_nodes) {
@@ -233,14 +242,11 @@ void draw_rr_chan(RRNodeId inode, const ezgl::color color, ezgl::renderer* g) {
233242
g->set_color(color, transparency_factor); //Ensure color is still set correctly if we drew any arrows/text
234243
}
235244

236-
/* Draws all the edges that the user wants shown between inode and what it
237-
* connects to. inode is assumed to be a CHANX, CHANY, or IPIN. */
238245
void draw_rr_edges(RRNodeId inode, ezgl::renderer* g) {
239246
t_draw_state* draw_state = get_draw_state_vars();
240247
const DeviceContext& device_ctx = g_vpr_ctx.device();
241248
const RRGraphView& rr_graph = device_ctx.rr_graph;
242249

243-
e_rr_type to_type;
244250
e_rr_type from_type = rr_graph.node_type(inode);
245251

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

251257
for (t_edge_size iedge = 0, l = rr_graph.num_edges(inode); iedge < l; iedge++) {
252258
RRNodeId to_node = rr_graph.edge_sink_node(inode, iedge);
253-
to_type = rr_graph.node_type(to_node);
259+
e_rr_type to_type = rr_graph.node_type(to_node);
254260
bool edge_configurable = rr_graph.edge_is_configurable(inode, iedge);
255261

256262
// Currently don't visualize source or sinks.
257263
if (to_type == e_rr_type::SOURCE || to_type == e_rr_type::SINK) {
258264
continue;
259265
}
260266

261-
ezgl::color color = DEFAULT_RR_NODE_COLOR;
262-
e_edge_type edge_type;
263267
bool draw_edge = true;
264268
bool inode_inter_cluster = is_inter_cluster_node(rr_graph, inode);
265269
bool to_node_inter_cluster = is_inter_cluster_node(rr_graph, to_node);
266270

267-
// Color map for edges based on {from_type, to_type}
268-
const std::map<std::pair<e_rr_type, e_rr_type>, e_edge_type> edge_type_map = {
269-
// Pin to pin connections
270-
{{e_rr_type::IPIN, e_rr_type::IPIN}, e_edge_type::PIN_TO_IPIN},
271-
{{e_rr_type::OPIN, e_rr_type::IPIN}, e_edge_type::PIN_TO_IPIN},
272-
{{e_rr_type::OPIN, e_rr_type::OPIN}, e_edge_type::PIN_TO_OPIN},
273-
{{e_rr_type::IPIN, e_rr_type::OPIN}, e_edge_type::PIN_TO_OPIN},
274-
275-
// Channel to pin connections
276-
{{e_rr_type::OPIN, e_rr_type::CHANX}, e_edge_type::OPIN_TO_CHAN},
277-
{{e_rr_type::OPIN, e_rr_type::CHANY}, e_edge_type::OPIN_TO_CHAN},
278-
{{e_rr_type::CHANX, e_rr_type::IPIN}, e_edge_type::CHAN_TO_IPIN},
279-
{{e_rr_type::CHANY, e_rr_type::IPIN}, e_edge_type::CHAN_TO_IPIN},
280-
281-
// Channel to channel connections
282-
{{e_rr_type::CHANX, e_rr_type::CHANX}, e_edge_type::CHAN_TO_CHAN},
283-
{{e_rr_type::CHANX, e_rr_type::CHANY}, e_edge_type::CHAN_TO_CHAN},
284-
{{e_rr_type::CHANY, e_rr_type::CHANY}, e_edge_type::CHAN_TO_CHAN},
285-
{{e_rr_type::CHANY, e_rr_type::CHANX}, e_edge_type::CHAN_TO_CHAN},
286-
};
287-
288-
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()) {
289272
continue; // Unsupported edge type
290273
}
291-
edge_type = edge_type_map.at({from_type, to_type});
274+
e_edge_type edge_type = EDGE_TYPE_MAP.at({from_type, to_type});
292275

293276
// Determine whether to draw the edge based on user options
294277

@@ -309,17 +292,11 @@ void draw_rr_edges(RRNodeId inode, ezgl::renderer* g) {
309292
draw_edge = draw_state->draw_connection_box_edges;
310293
}
311294

312-
// Select edge colors
313-
const std::map<e_edge_type, ezgl::color> edge_color_map = {
314-
{e_edge_type::PIN_TO_OPIN, ezgl::LIGHT_PINK},
315-
{e_edge_type::PIN_TO_IPIN, ezgl::MEDIUM_PURPLE},
316-
{e_edge_type::OPIN_TO_CHAN, ezgl::PINK},
317-
{e_edge_type::CHAN_TO_IPIN, ezgl::PURPLE},
318-
{e_edge_type::CHAN_TO_CHAN, blk_DARKGREEN}};
295+
ezgl::color color = EDGE_COLOR_MAP.at(edge_type);
319296

320-
color = edge_color_map.at(edge_type);
321-
322-
if (!edge_configurable) color = blk_DARKGREY;
297+
if (!edge_configurable) {
298+
color = blk_DARKGREY;
299+
}
323300

324301
if ((from_type == e_rr_type::CHANX || from_type == e_rr_type::CHANY)
325302
&& (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
*/

0 commit comments

Comments
 (0)