Skip to content

Commit 162ca07

Browse files
committed
libs: arch: add is_empty function to phys/log types
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 821bff9 commit 162ca07

File tree

7 files changed

+30
-17
lines changed

7 files changed

+30
-17
lines changed

libs/libarchfpga/src/arch_util.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,9 @@ t_port* findPortByName(const char* name, t_pb_type* pb_type, int* high_index, in
555555
return port;
556556
}
557557

558-
t_physical_tile_type get_empty_physical_type(std::string name) {
558+
t_physical_tile_type get_empty_physical_type(const char* name) {
559559
t_physical_tile_type type;
560-
type.name = vtr::strdup(name.c_str());
560+
type.name = vtr::strdup(name);
561561
type.num_pins = 0;
562562
type.width = 1;
563563
type.height = 1;
@@ -569,16 +569,14 @@ t_physical_tile_type get_empty_physical_type(std::string name) {
569569
type.switchblock_switch_overrides = vtr::Matrix<int>({{size_t(type.width), size_t(type.height)}}, DEFAULT_SWITCH);
570570
type.is_input_type = false;
571571
type.is_output_type = false;
572-
type.is_empty = true;
573572

574573
return type;
575574
}
576575

577-
t_logical_block_type get_empty_logical_type(std::string name) {
576+
t_logical_block_type get_empty_logical_type(const char* name) {
578577
t_logical_block_type type;
579-
type.name = vtr::strdup(name.c_str());
578+
type.name = vtr::strdup(name);
580579
type.pb_type = nullptr;
581-
type.is_empty = true;
582580

583581
return type;
584582
}

libs/libarchfpga/src/arch_util.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void set_arch_file_name(const char* arch);
1515
*/
1616
const char* get_arch_file_name();
1717

18-
const std::string EMPTY_BLOCK_NAME("EMPTY");
18+
constexpr const char* EMPTY_BLOCK_NAME = "EMPTY";
1919

2020
class InstPort {
2121
public:
@@ -65,12 +65,12 @@ t_port* findPortByName(const char* name, t_pb_type* pb_type, int* high_index, in
6565
/** @brief Returns and empty physical tile type, assigned with the given name argument.
6666
* The default empty string is assigned if no name is provided
6767
*/
68-
t_physical_tile_type get_empty_physical_type(std::string name = EMPTY_BLOCK_NAME);
68+
t_physical_tile_type get_empty_physical_type(const char* name = EMPTY_BLOCK_NAME);
6969

7070
/** @brief Returns and empty logical block type, assigned with the given name argument.
7171
* The default empty string is assigned if no name is provided
7272
*/
73-
t_logical_block_type get_empty_logical_type(std::string name = EMPTY_BLOCK_NAME);
73+
t_logical_block_type get_empty_logical_type(const char* name = EMPTY_BLOCK_NAME);
7474

7575
std::unordered_set<t_logical_block_type_ptr> get_equivalent_sites_set(t_physical_tile_type_ptr type);
7676

libs/libarchfpga/src/physical_types.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include "physical_types.h"
22
#include "vtr_math.h"
33
#include "vtr_util.h"
4+
#include "vtr_log.h"
5+
6+
#include "arch_util.h"
47

58
static bool switch_type_is_buffered(SwitchType type);
69
static bool switch_type_is_configurable(SwitchType type);
@@ -129,6 +132,18 @@ int t_physical_tile_type::get_sub_tile_loc_from_pin(int pin_num) const {
129132
return OPEN;
130133
}
131134

135+
bool t_physical_tile_type::is_empty() const {
136+
return std::string(name) == std::string(EMPTY_BLOCK_NAME);
137+
}
138+
139+
/*
140+
* t_logical_block_type
141+
*/
142+
143+
bool t_logical_block_type::is_empty() const {
144+
return std::string(name) == std::string(EMPTY_BLOCK_NAME);
145+
}
146+
132147
/**
133148
* t_pb_graph_node
134149
*/

libs/libarchfpga/src/physical_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ struct t_physical_tile_type {
655655
bool is_output_type = false;
656656

657657
// Is this t_physical_tile_type an empty type?
658-
bool is_empty = false;
658+
bool is_empty() const;
659659
};
660660

661661
/* Holds the capacity range of a certain sub_tile block within the parent physical tile type.
@@ -833,7 +833,7 @@ struct t_logical_block_type {
833833
///>place this type of netlist block.
834834

835835
// Is this t_logical_block_type empty?
836-
bool is_empty = false;
836+
bool is_empty() const;
837837
};
838838

839839
/*************************************************************************************************

libs/libarchfpga/src/read_fpga_interchange_arch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ struct ArchReader {
969969

970970
int index = 0;
971971
// TODO: Make this dynamic depending on data from the interchange
972-
auto EMPTY = get_empty_logical_type(std::string("NULL"));
972+
auto EMPTY = get_empty_logical_type();
973973
EMPTY.index = index;
974974
ltypes_.push_back(EMPTY);
975975

@@ -1857,7 +1857,7 @@ struct ArchReader {
18571857

18581858
// Physical Tiles
18591859
void process_tiles() {
1860-
auto EMPTY = get_empty_physical_type(std::string("NULL"));
1860+
auto EMPTY = get_empty_physical_type();
18611861
int index = 0;
18621862
EMPTY.index = index;
18631863
ptypes_.push_back(EMPTY);

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,7 +2780,7 @@ static void ProcessTiles(pugi::xml_node Node,
27802780
/* Alloc the type list. Need one additional t_type_desctiptors:
27812781
* 1: empty psuedo-type
27822782
*/
2783-
t_physical_tile_type EMPTY_PHYSICAL_TILE_TYPE = get_empty_physical_type(std::string("EMPTY"));
2783+
t_physical_tile_type EMPTY_PHYSICAL_TILE_TYPE = get_empty_physical_type();
27842784
EMPTY_PHYSICAL_TILE_TYPE.index = 0;
27852785
PhysicalTileTypes.push_back(EMPTY_PHYSICAL_TILE_TYPE);
27862786

@@ -3453,7 +3453,7 @@ static void ProcessComplexBlocks(vtr::string_internment* strings, pugi::xml_node
34533453
/* Alloc the type list. Need one additional t_type_desctiptors:
34543454
* 1: empty psuedo-type
34553455
*/
3456-
t_logical_block_type EMPTY_LOGICAL_BLOCK_TYPE = get_empty_logical_type(std::string("EMPTY"));
3456+
t_logical_block_type EMPTY_LOGICAL_BLOCK_TYPE = get_empty_logical_type();
34573457
EMPTY_LOGICAL_BLOCK_TYPE.index = 0;
34583458
LogicalBlockTypes.push_back(EMPTY_LOGICAL_BLOCK_TYPE);
34593459

vpr/src/base/SetupVPR.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void SetupVPR(const t_options* Options,
139139
int num_inputs = 0;
140140
int num_outputs = 0;
141141
for (auto& type : device_ctx.physical_tile_types) {
142-
if (type.is_empty) {
142+
if (type.is_empty()) {
143143
VTR_ASSERT(device_ctx.EMPTY_PHYSICAL_TILE_TYPE == nullptr);
144144
VTR_ASSERT(type.num_pins == 0);
145145
device_ctx.EMPTY_PHYSICAL_TILE_TYPE = &type;
@@ -157,7 +157,7 @@ void SetupVPR(const t_options* Options,
157157
device_ctx.EMPTY_LOGICAL_BLOCK_TYPE = nullptr;
158158
int max_equivalent_tiles = 0;
159159
for (const auto& type : device_ctx.logical_block_types) {
160-
if (type.is_empty) {
160+
if (type.is_empty()) {
161161
VTR_ASSERT(device_ctx.EMPTY_LOGICAL_BLOCK_TYPE == nullptr);
162162
VTR_ASSERT(type.pb_type == nullptr);
163163
device_ctx.EMPTY_LOGICAL_BLOCK_TYPE = &type;

0 commit comments

Comments
 (0)