Skip to content

Commit 91f2941

Browse files
authored
Merge pull request #2805 from verilog-to-routing/fix_manual_move_cont
Fix manual move
2 parents 88e7b1e + c6c4135 commit 91f2941

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

vpr/src/draw/manual_moves.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @brief Contains the function definitions needed for manual moves feature.
66
*
77
* Includes the graphics/gtk function for manual moves. The Manual Move Generator class is defined manual_move_generator.h/cpp.
8-
* The manual move feature allows the user to select a move by choosing the block to move, x position, y position, subtile position.
8+
* The manual move feature allows the user to select a move by choosing the block to move, x position, y position, layer_position, subtile position.
99
* If the placer accepts the move, the user can accept or reject the move with respect to the delta cost,
1010
* delta timing and delta bounding box cost displayed on the UI. The manual move feature interacts with placement through
1111
* the ManualMoveGenerator class in the manual_move_generator.cpp/h files and in the place.cpp file by checking
@@ -42,11 +42,13 @@ void draw_manual_moves_window(const std::string& block_id) {
4242

4343
GtkWidget* x_position_entry = gtk_entry_new();
4444
GtkWidget* y_position_entry = gtk_entry_new();
45+
GtkWidget* layer_position_entry = gtk_entry_new();
4546
GtkWidget* subtile_position_entry = gtk_entry_new();
4647
GtkWidget* block_label = gtk_label_new("Block ID/Block Name:");
4748
GtkWidget* to_label = gtk_label_new("To Location:");
4849
GtkWidget* x = gtk_label_new("x:");
4950
GtkWidget* y = gtk_label_new("y:");
51+
GtkWidget* layer = gtk_label_new("layer:");
5052
GtkWidget* subtile = gtk_label_new("Subtile:");
5153

5254
GtkWidget* calculate_cost_button = gtk_button_new_with_label("Calculate Costs");
@@ -59,9 +61,11 @@ void draw_manual_moves_window(const std::string& block_id) {
5961
gtk_grid_attach((GtkGrid*)grid, x_position_entry, 2, 1, 1, 1);
6062
gtk_grid_attach((GtkGrid*)grid, y, 1, 2, 1, 1);
6163
gtk_grid_attach((GtkGrid*)grid, y_position_entry, 2, 2, 1, 1);
62-
gtk_grid_attach((GtkGrid*)grid, subtile, 1, 3, 1, 1);
63-
gtk_grid_attach((GtkGrid*)grid, subtile_position_entry, 2, 3, 1, 1);
64-
gtk_grid_attach((GtkGrid*)grid, calculate_cost_button, 0, 4, 3, 1); //spans three columns
64+
gtk_grid_attach((GtkGrid*)grid, layer, 1, 3, 1, 1);
65+
gtk_grid_attach((GtkGrid*)grid, layer_position_entry, 2, 3, 1, 1);
66+
gtk_grid_attach((GtkGrid*)grid, subtile, 1, 4, 1, 1);
67+
gtk_grid_attach((GtkGrid*)grid, subtile_position_entry, 2, 4, 1, 1);
68+
gtk_grid_attach((GtkGrid*)grid, calculate_cost_button, 0, 5, 3, 1); //spans three columns
6569

6670
//Set margins
6771
gtk_widget_set_margin_bottom(grid, 20);
@@ -88,6 +92,7 @@ void calculate_cost_callback(GtkWidget* /*widget*/, GtkWidget* grid) {
8892
int block_id = -1;
8993
int x_location = -1;
9094
int y_location = -1;
95+
int layer_location = -1;
9196
int subtile_location = -1;
9297
bool valid_input = true;
9398

@@ -108,26 +113,28 @@ void calculate_cost_callback(GtkWidget* /*widget*/, GtkWidget* grid) {
108113

109114
GtkWidget* x_position_entry = gtk_grid_get_child_at((GtkGrid*)grid, 2, 1);
110115
GtkWidget* y_position_entry = gtk_grid_get_child_at((GtkGrid*)grid, 2, 2);
111-
GtkWidget* subtile_position_entry = gtk_grid_get_child_at((GtkGrid*)grid, 2, 3);
116+
GtkWidget* layer_position_entry = gtk_grid_get_child_at((GtkGrid*)grid, 2, 3);
117+
GtkWidget* subtile_position_entry = gtk_grid_get_child_at((GtkGrid*)grid, 2, 4);
112118

113119
x_location = std::atoi(gtk_entry_get_text((GtkEntry*)x_position_entry));
114120
y_location = std::atoi(gtk_entry_get_text((GtkEntry*)y_position_entry));
121+
layer_location = std::atoi(gtk_entry_get_text((GtkEntry*)layer_position_entry));
115122
subtile_location = std::atoi(gtk_entry_get_text((GtkEntry*)subtile_position_entry));
116123

117-
if (std::string(gtk_entry_get_text((GtkEntry*)block_entry)).empty() || std::string(gtk_entry_get_text((GtkEntry*)x_position_entry)).empty() || std::string(gtk_entry_get_text((GtkEntry*)y_position_entry)).empty() || std::string(gtk_entry_get_text((GtkEntry*)subtile_position_entry)).empty()) {
124+
if (std::string(gtk_entry_get_text((GtkEntry*)block_entry)).empty() || std::string(gtk_entry_get_text((GtkEntry*)x_position_entry)).empty() || std::string(gtk_entry_get_text((GtkEntry*)y_position_entry)).empty() || std::string(gtk_entry_get_text((GtkEntry*)layer_position_entry)).empty() || std::string(gtk_entry_get_text((GtkEntry*)subtile_position_entry)).empty()) {
118125
invalid_breakpoint_entry_window("Not all fields are complete");
119126
valid_input = false;
120127
}
121128

122-
// TODO: When graphic is updated to support 3D, this will need to be updated
123-
t_pl_loc to = t_pl_loc(x_location, y_location, subtile_location, 0);
129+
t_pl_loc to = t_pl_loc(x_location, y_location, subtile_location, layer_location);
124130
valid_input = is_manual_move_legal(ClusterBlockId(block_id), to);
125131

126132
if (valid_input) {
127133
draw_state->manual_moves_state.manual_move_info.valid_input = true;
128134
draw_state->manual_moves_state.manual_move_info.blockID = block_id;
129135
draw_state->manual_moves_state.manual_move_info.x_pos = x_location;
130136
draw_state->manual_moves_state.manual_move_info.y_pos = y_location;
137+
draw_state->manual_moves_state.manual_move_info.layer = layer_location;
131138
draw_state->manual_moves_state.manual_move_info.subtile = subtile_location;
132139
draw_state->manual_moves_state.manual_move_info.to_location = to;
133140

vpr/src/draw/manual_moves.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct ManualMovesInfo {
5151
int x_pos = -1;
5252
int y_pos = -1;
5353
int subtile = 0;
54+
int layer = 0;
5455
double delta_cost = 0;
5556
double delta_timing = 0;
5657
double delta_bounding_box = 0;

vpr/src/place/place.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ static e_move_result try_swap(const t_annealing_state* state,
13511351
create_move_outcome = move_generator.propose_move(blocks_affected, proposed_action, rlim, placer_opts, criticalities);
13521352
}
13531353

1354-
if (proposed_action.logical_blk_type_index != -1) { //if the agent proposed the block type, then collect the block type stat
1354+
if (proposed_action.logical_blk_type_index != -1 && !manual_move_enabled) { //if the agent proposed the block type, then collect the block type stat
13551355
++move_type_stat.blk_type_moves[proposed_action.logical_blk_type_index][(int)proposed_action.move_type];
13561356
}
13571357
LOG_MOVE_STATS_PROPOSED(t, blocks_affected);
@@ -1575,7 +1575,7 @@ static e_move_result try_swap(const t_annealing_state* state,
15751575
// move generator, so we should not calculate the reward and update
15761576
// the move generators status since this outcome is not a direct
15771577
// consequence of the move generator
1578-
if (!router_block_move) {
1578+
if (!manual_move_enabled && !router_block_move) {
15791579
move_generator.calculate_reward_and_process_outcome(move_outcome_stats, delta_c, timing_bb_factor);
15801580
}
15811581

0 commit comments

Comments
 (0)