Skip to content

Cleaned up RRGraph Drawing Code - #3206

Merged
vaughnbetz merged 13 commits into
masterfrom
rr_drawing_update
Aug 7, 2025
Merged

Cleaned up RRGraph Drawing Code#3206
vaughnbetz merged 13 commits into
masterfrom
rr_drawing_update

Conversation

@SamuelHo10

Copy link
Copy Markdown
Contributor

Edges for each side are now drawn between inter-cluster and intra-cluster nodes. I’ve simplified the RRGraph drawing code by introducing reusable helper functions draw_rr_edge and draw_rr_node, while preserving all existing functionality and color schemes. I’ve also disabled the code that was drawing sources and sinks, as it didn’t seem to render correctly to begin with. Would it make sense to reimplement source/sink visualization, or is it something we want to leave out for now? In the next PR, I will probably hook up the new buttons to RRGraph drawing, so I left the toggle_RR variable unchanged for now.

@github-actions github-actions Bot added VPR VPR FPGA Placement & Routing Tool lang-cpp C/C++ code labels Jul 22, 2025
@vaughnbetz

vaughnbetz commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

It's probably good to add SOURCE and SINK viewing, probably with another checkbox to control clutter.

You'd probably draw sources and sinks in some visually distinct way (circle for one and ellipse for the other?) with edges to pins where they connect. Physically they are inside the block, so in the interior of cluster-level blocks makes sense. For primitive level they would ideally be drawn in the primitive they belong to. But you'll have to figure out which primitive that is ... the net_rr_terminals data structure loader also figures that out so you could look at it.

@vaughnbetz vaughnbetz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup!
Some comments embedded.
Biggest one: check the highlighting of rr_nodes works properly; you can simplify the code or change how it works, but we should be able to highlight nodes by (right) clicking on them and we should see their fanin and fanout edges highlighted too.
Future-proofing / next: @amin1377 has added support for a new MUX type. After this PR is in, you should test with an openFPGA tileable rr-graph on a small device to ensure it draws properly, and you should add MUX support. MUXes are like 0-length wires; we can draw them as points in a switch block I think but we'll have to allocate space for them etc. so it is probably a reasonable amount of work.
Future proofing 2: @soheilshahrouz has added support for CHANZ nodes. You should make sure those draw too in a future PR. At least we shouldn't crash, and most code that checks for CHANX and CHANY should have a CHANZ case too.

Comment thread vpr/src/draw/draw_rr.cpp
Comment thread vpr/src/draw/draw_rr.cpp Outdated
Comment thread vpr/src/draw/draw_rr.cpp Outdated
Comment thread vpr/src/draw/draw_rr.cpp Outdated
if (to_type == e_rr_type::IPIN) {
color = blk_LIGHTSKYBLUE;
if (draw_state->draw_rr_node[to_node].node_highlighted && draw_state->draw_rr_node[inode].color == DEFAULT_RR_NODE_COLOR) {
// If the IPIN is clicked on, draw connection to all the CHANX

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the overall highlighting code needs to be tested and this comment needs to be hoisted higher and updated.
I believe you can right click on an rr-node, and its fanin and fanout will be highlighted in certain colours. The highlighted node itself is drawn in magenta. You should test exactly what happens now, and see if you like it. I think the code can be simplified (which you've done) but you need to test we're doing some reasonable highlighting (idea: right click highlights and rr-node and its fan-in edges and fan-out edges).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the highlighting can be simplified to something that just looks at the state of the prior and current rr-nodes (without paying attention to their type) and decides if an edge should be highlighted or not. I suspect we're being overly complex with the code that checks the node types (CHANX etc.). If we can simplify, we could just move it to a helper function to find the colour.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked that the RRNode highlighting works. I think currently we have a global variable vtr::vector<RRNodeID, t_draw_rr_node> draw_rr_node; which stores information on whether the RRNode is highlighted or not.

Comment thread vpr/src/draw/draw_rr_edges.cpp
Comment thread vpr/src/draw/draw_rr_edges.cpp Outdated
Comment thread vpr/src/draw/draw_rr_edges.cpp Outdated
Comment thread vpr/src/draw/draw_rr_edges.cpp Outdated
Comment thread vpr/src/draw/draw_rr_edges.cpp Outdated
Comment thread vpr/src/draw/draw_rr.cpp Outdated
@SamuelHo10

Copy link
Copy Markdown
Contributor Author

I've verified that the RR graph colors and highlighting are still functioning correctly. I changed the color of the input pins from light blue to purple since the original color blended in with the CLB background. I also added the drawing of intra-cluster edges and nodes. Is there an effective way to verify whether the intra-cluster edges are being drawn correctly? I tried the write_rr_graph command line option, but it did not seem to output the intra-cluster nodes.

rr_graph_all rr_graph1

Intracluster Pins and Edges:
rr_graph_intra_cluster_edges
rr_graph_intra_cluster_pins

Highlighting:
rr_graph_highlight1
rr_graph_highlight2

I'm still unsure of the best way to determine the locations of sources and sinks. I might ask Amin the next time I see him. The previous implementation distributed sources and sinks throughout the CLB without accounting for the positions of the internal blocks.

As for drawing MUXes and CHANX/CHANY nodes, I think it would be best to handle that in a separate pull request.

@vaughnbetz

Copy link
Copy Markdown
Contributor

Thanks. Let's merge this and fine-tune any rough edges after.
For intra-cluster rr-graph dumping: @amin1377 is there an echo file for that? We should make one if not I think. I think it's intentionally that you don't write it to the rr-graph.xml file, as the nodes are design specific after you have optimized the rr-graph I think.
@SamuelHo10 : how are you drawing intracluster pins? blue for inputs, pink for outputs, across the top of each sub-block? Can you click on those rr-nodes too to highlight them and their fan-in and fan-out (that would be very useful!).
For the fle[0]n2_lut5 sub-block, it appears to have only one input, but there would be more in the .arch file. Are its rr-nodes rendering correctly?

image

@vaughnbetz vaughnbetz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vaughnbetz
vaughnbetz merged commit 770be34 into master Aug 7, 2025
30 checks passed
@vaughnbetz
vaughnbetz deleted the rr_drawing_update branch August 7, 2025 04:05
@amin1377

amin1377 commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

@vaughnbetz: Sorry for the late reply, I’m not sure how I missed your comment. You’re right: we don’t write out the RR Graph with intra-cluster resources because it’s design-specific, and we don’t have an echo file for that. It would be very helpful to have one, so I’ve created an issue for it and assigned it to myself.

@amin1377

amin1377 commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

@vaughnbetz: Currently, the GUI does not provide an option to display only intra-cluster routing or only inter-cluster routing (when the flat router is used). Do you think it would be useful to add such an option?

@SamuelHo10

Copy link
Copy Markdown
Contributor Author

@vaughnbetz: Currently, the GUI does not provide an option to display only intra-cluster routing or only inter-cluster routing (when the flat router is used). Do you think it would be useful to add such an option?

I've added that option. See #3236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang-cpp C/C++ code VPR VPR FPGA Placement & Routing Tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants