Skip to content

Commit 90d4b91

Browse files
Merge pull request verilog-to-routing#3061 from w0lek/new-feature-show-resource-usage
add show-resource-usage mode
2 parents eb58578 + 2e04eb7 commit 90d4b91

File tree

6 files changed

+67
-0
lines changed

6 files changed

+67
-0
lines changed

doc/src/vpr/command_line_usage.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,6 +2222,16 @@ The following options are used to enable server mode in VPR.
22222222

22232223
.. seealso:: :ref:`interactive_path_analysis_client`
22242224

2225+
2226+
Show Architecture Resources
2227+
^^^^^^^^^^^^^^^^^^^^^^^^
2228+
.. option:: --show_arch_resources
2229+
2230+
Print the architecture resource report for each device layout and exit normally.
2231+
2232+
**Default:** ``off``
2233+
2234+
22252235
Command-line Auto Completion
22262236
----------------------------
22272237

vpr/src/base/read_options.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,11 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
15841584
.help("Show version information then exit")
15851585
.action(argparse::Action::VERSION);
15861586

1587+
gen_grp.add_argument<bool, ParseOnOff>(args.show_arch_resources, "--show_arch_resources")
1588+
.help("Show architecture resources then exit")
1589+
.action(argparse::Action::STORE_TRUE)
1590+
.default_value("off");
1591+
15871592
gen_grp.add_argument<std::string>(args.device_layout, "--device")
15881593
.help(
15891594
"Controls which device layout/floorplan is used from the architecture file."

vpr/src/base/read_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct t_options {
6868
/* General options */
6969
argparse::ArgValue<bool> show_help;
7070
argparse::ArgValue<bool> show_version;
71+
argparse::ArgValue<bool> show_arch_resources;
7172
argparse::ArgValue<size_t> num_workers;
7273
argparse::ArgValue<bool> timing_analysis;
7374
argparse::ArgValue<e_timing_update_type> timing_update_type;

vpr/src/base/vpr_api.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,48 @@ static void unset_port_equivalences(DeviceContext& device_ctx) {
392392
}
393393
}
394394

395+
void vpr_print_arch_resources(const t_vpr_setup& vpr_setup, const t_arch& Arch) {
396+
vtr::ScopedStartFinishTimer timer("Build Device Grid");
397+
/* Read in netlist file for placement and routing */
398+
auto& device_ctx = g_vpr_ctx.mutable_device();
399+
400+
device_ctx.arch = &Arch;
401+
402+
/*
403+
*Load the device grid
404+
*/
405+
406+
//Record the resource requirement
407+
std::map<t_logical_block_type_ptr, size_t> num_type_instances;
408+
409+
//Build the device
410+
for (const t_grid_def& l : Arch.grid_layouts) {
411+
float target_device_utilization = vpr_setup.PackerOpts.target_device_utilization;
412+
device_ctx.grid = create_device_grid(l.name, Arch.grid_layouts, num_type_instances, target_device_utilization);
413+
414+
/*
415+
*Report on the device
416+
*/
417+
size_t num_grid_tiles = count_grid_tiles(device_ctx.grid);
418+
VTR_LOG("FPGA sized to %zu x %zu: %zu grid tiles (%s)\n", device_ctx.grid.width(), device_ctx.grid.height(), num_grid_tiles, device_ctx.grid.name().c_str());
419+
420+
std::string title("\nResource usage for device layout " + l.name + "...\n");
421+
VTR_LOG(title.c_str());
422+
for (const t_logical_block_type& type : device_ctx.logical_block_types) {
423+
if (is_empty_type(&type)) continue;
424+
425+
VTR_LOG("\tArchitecture\n");
426+
for (const t_physical_tile_type_ptr equivalent_tile : type.equivalent_tiles) {
427+
//get the number of equivalent tile across all layers
428+
int num_instances = (int)device_ctx.grid.num_instances(equivalent_tile, -1);
429+
430+
VTR_LOG("\t\t%d\tblocks of type: %s\n",
431+
num_instances, equivalent_tile->name.c_str());
432+
}
433+
}
434+
}
435+
}
436+
395437
bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
396438
if (vpr_setup.exit_before_pack) {
397439
VTR_LOG_WARN("Exiting before packing as requested.\n");

vpr/src/base/vpr_api.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ void vpr_analysis(const Netlist<>& net_list,
136136
///@brief Create the device (grid + rr graph)
137137
void vpr_create_device(t_vpr_setup& vpr_setup, const t_arch& Arch);
138138

139+
/// @brief Print architecture resources
140+
void vpr_print_arch_resources(const t_vpr_setup& vpr_setup, const t_arch& Arch);
141+
139142
///@brief Create the device grid
140143
void vpr_create_device_grid(const t_vpr_setup& vpr_setup, const t_arch& Arch);
141144

vpr/src/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ int main(int argc, const char** argv) {
5858
return SUCCESS_EXIT_CODE;
5959
}
6060

61+
if (Options.show_arch_resources) {
62+
vpr_print_arch_resources(vpr_setup, Arch);
63+
vpr_free_all(Arch, vpr_setup);
64+
return SUCCESS_EXIT_CODE;
65+
}
66+
6167
bool flow_succeeded = vpr_flow(vpr_setup, Arch);
6268
if (!flow_succeeded) {
6369
VTR_LOG("VPR failed to implement circuit\n");

0 commit comments

Comments
 (0)