Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreSinger authored Sep 17, 2024
2 parents a25b7ec + 7844044 commit 734d54a
Show file tree
Hide file tree
Showing 97 changed files with 53,745 additions and 4,556 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ jobs:
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on',
suite: 'vtr_reg_basic'
},
{
name: 'Basic with highest assertion level',
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=4 -DWITH_BLIFEXPLORER=on',
suite: 'vtr_reg_basic'
},
{
name: 'Basic_odin',
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DWITH_PARMYS=OFF -DWITH_ODIN=on',
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ tags
#
.vscode
.history
.cache
#eclipse project
.project

Expand All @@ -153,4 +154,4 @@ tags
.idea
cmake-build-debug
cmake-build-release
/.metadata/
/.metadata/
101 changes: 71 additions & 30 deletions libs/libarchfpga/src/parse_switchblocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ static void parse_comma_separated_wire_points(const char* ch, std::vector<t_wire
/* Parses the number of connections type */
static void parse_num_conns(std::string num_conns, t_wireconn_inf& wireconn);

/* Set connection from_side and to_side for custom switch block pattern*/
static void set_switch_func_type(SB_Side_Connection& conn, const char* func_type);

/* parse switch_override in wireconn */
static void parse_switch_override(const char* switch_override, t_wireconn_inf& wireconn, const t_arch_switch_inf* switches, int num_switches);

Expand Down Expand Up @@ -269,6 +272,70 @@ static void parse_num_conns(std::string num_conns, t_wireconn_inf& wireconn) {
wireconn.num_conns_formula = num_conns;
}

//set sides for a specific conn for custom switch block pattern
static void set_switch_func_type(SB_Side_Connection& conn, const char* func_type) {
if (0 == strcmp(func_type, "lt")) {
conn.set_sides(LEFT, TOP);
} else if (0 == strcmp(func_type, "lr")) {
conn.set_sides(LEFT, RIGHT);
} else if (0 == strcmp(func_type, "lb")) {
conn.set_sides(LEFT, BOTTOM);
} else if (0 == strcmp(func_type, "la")) {
conn.set_sides(LEFT, ABOVE);
} else if (0 == strcmp(func_type, "lu")) {
conn.set_sides(LEFT, UNDER);
} else if (0 == strcmp(func_type, "tl")) {
conn.set_sides(TOP, LEFT);
} else if (0 == strcmp(func_type, "tb")) {
conn.set_sides(TOP, BOTTOM);
} else if (0 == strcmp(func_type, "tr")) {
conn.set_sides(TOP, RIGHT);
} else if (0 == strcmp(func_type, "ta")) {
conn.set_sides(TOP, ABOVE);
} else if (0 == strcmp(func_type, "tu")) {
conn.set_sides(TOP, UNDER);
} else if (0 == strcmp(func_type, "rt")) {
conn.set_sides(RIGHT, TOP);
} else if (0 == strcmp(func_type, "rl")) {
conn.set_sides(RIGHT, LEFT);
} else if (0 == strcmp(func_type, "rb")) {
conn.set_sides(RIGHT, BOTTOM);
} else if (0 == strcmp(func_type, "ra")) {
conn.set_sides(RIGHT, ABOVE);
} else if (0 == strcmp(func_type, "ru")) {
conn.set_sides(RIGHT, UNDER);
} else if (0 == strcmp(func_type, "bl")) {
conn.set_sides(BOTTOM, LEFT);
} else if (0 == strcmp(func_type, "bt")) {
conn.set_sides(BOTTOM, TOP);
} else if (0 == strcmp(func_type, "br")) {
conn.set_sides(BOTTOM, RIGHT);
} else if (0 == strcmp(func_type, "ba")) {
conn.set_sides(BOTTOM, ABOVE);
} else if (0 == strcmp(func_type, "bu")) {
conn.set_sides(BOTTOM, UNDER);
} else if (0 == strcmp(func_type, "al")) {
conn.set_sides(ABOVE, LEFT);
} else if (0 == strcmp(func_type, "at")) {
conn.set_sides(ABOVE, TOP);
} else if (0 == strcmp(func_type, "ar")) {
conn.set_sides(ABOVE, RIGHT);
} else if (0 == strcmp(func_type, "ab")) {
conn.set_sides(ABOVE, BOTTOM);
} else if (0 == strcmp(func_type, "ul")) {
conn.set_sides(UNDER, LEFT);
} else if (0 == strcmp(func_type, "ut")) {
conn.set_sides(UNDER, TOP);
} else if (0 == strcmp(func_type, "ur")) {
conn.set_sides(UNDER, RIGHT);
} else if (0 == strcmp(func_type, "ub")) {
conn.set_sides(UNDER, BOTTOM);
} else {
/* unknown permutation function */
archfpga_throw(__FILE__, __LINE__, "Unknown permutation function specified: %s\n", func_type);
}
}

/* Loads permutation funcs specified under Node into t_switchblock_inf. Node should be
* <switchfuncs> */
void read_sb_switchfuncs(pugi::xml_node Node, t_switchblock_inf* sb, const pugiutil::loc_data& loc_data) {
Expand Down Expand Up @@ -300,34 +367,8 @@ void read_sb_switchfuncs(pugi::xml_node Node, t_switchblock_inf* sb, const pugiu
func_formula = get_attribute(SubElem, "formula", loc_data).as_string(nullptr);

/* go through all the possible cases of func_type */
if (0 == strcmp(func_type, "lt")) {
conn.set_sides(LEFT, TOP);
} else if (0 == strcmp(func_type, "lr")) {
conn.set_sides(LEFT, RIGHT);
} else if (0 == strcmp(func_type, "lb")) {
conn.set_sides(LEFT, BOTTOM);
} else if (0 == strcmp(func_type, "tl")) {
conn.set_sides(TOP, LEFT);
} else if (0 == strcmp(func_type, "tb")) {
conn.set_sides(TOP, BOTTOM);
} else if (0 == strcmp(func_type, "tr")) {
conn.set_sides(TOP, RIGHT);
} else if (0 == strcmp(func_type, "rt")) {
conn.set_sides(RIGHT, TOP);
} else if (0 == strcmp(func_type, "rl")) {
conn.set_sides(RIGHT, LEFT);
} else if (0 == strcmp(func_type, "rb")) {
conn.set_sides(RIGHT, BOTTOM);
} else if (0 == strcmp(func_type, "bl")) {
conn.set_sides(BOTTOM, LEFT);
} else if (0 == strcmp(func_type, "bt")) {
conn.set_sides(BOTTOM, TOP);
} else if (0 == strcmp(func_type, "br")) {
conn.set_sides(BOTTOM, RIGHT);
} else {
/* unknown permutation function */
archfpga_throw(__FILE__, __LINE__, "Unknown permutation function specified: %s\n", func_type);
}
set_switch_func_type(conn, func_type);

func_ptr = &(sb->permutation_map[conn]);

/* Here we load the specified switch function(s) */
Expand Down Expand Up @@ -404,8 +445,8 @@ static void check_bidir_switchblock(const t_permutation_map* permutation_map) {
SB_Side_Connection conn;

/* iterate over all combinations of from_side -> to side */
for (e_side from_side : {TOP, RIGHT, BOTTOM, LEFT}) {
for (e_side to_side : {TOP, RIGHT, BOTTOM, LEFT}) {
for (e_side from_side : TOTAL_2D_SIDES) {
for (e_side to_side : TOTAL_2D_SIDES) {
/* can't connect a switchblock side to itself */
if (from_side == to_side) {
continue;
Expand Down
13 changes: 10 additions & 3 deletions libs/libarchfpga/src/physical_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,17 @@ enum e_side : unsigned char {
RIGHT = 1,
BOTTOM = 2,
LEFT = 3,
NUM_SIDES
NUM_2D_SIDES = 4,
ABOVE = 5,
UNDER = 7,
NUM_3D_SIDES = 6,
};
constexpr std::array<e_side, NUM_SIDES> SIDES = {{TOP, RIGHT, BOTTOM, LEFT}}; //Set of all side orientations
constexpr std::array<const char*, NUM_SIDES> SIDE_STRING = {{"TOP", "RIGHT", "BOTTOM", "LEFT"}}; //String versions of side orientations

constexpr std::array<e_side, NUM_2D_SIDES> TOTAL_2D_SIDES = {{TOP, RIGHT, BOTTOM, LEFT}}; //Set of all side orientations
constexpr std::array<const char*, NUM_2D_SIDES> TOTAL_2D_SIDE_STRINGS = {{"TOP", "RIGHT", "BOTTOM", "LEFT"}}; //String versions of side orientations

constexpr std::array<e_side, NUM_3D_SIDES> TOTAL_3D_SIDES = {{TOP, RIGHT, BOTTOM, LEFT, ABOVE, UNDER}}; //Set of all side orientations including different layers
constexpr std::array<const char*, NUM_3D_SIDES> TOTAL_3D_SIDE_STRINGS = {{"TOP", "RIGHT", "BOTTOM", "LEFT", "ABOVE", "UNDER"}}; //String versions of side orientations including different layers

/* pin location distributions */
enum class e_pin_location_distr {
Expand Down
2 changes: 1 addition & 1 deletion libs/libarchfpga/src/read_fpga_interchange_arch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ struct ArchReader {
type.pin_height_offset.resize(type.num_pins, 0);

type.pinloc.resize({1, 1, 4}, std::vector<bool>(type.num_pins, false));
for (e_side side : {TOP, RIGHT, BOTTOM, LEFT}) {
for (e_side side : TOTAL_2D_SIDES) {
for (int pin = 0; pin < type.num_pins; pin++) {
type.pinloc[0][0][side][pin] = true;
type.pin_width_offset[pin] = 0;
Expand Down
22 changes: 11 additions & 11 deletions libs/libarchfpga/src/read_xml_arch_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ static void LoadPinLoc(pugi::xml_node Locations,
int num_sides = 4 * (type->width * type->height);
int side_index = 0;
int count = 0;
for (e_side side : {TOP, RIGHT, BOTTOM, LEFT}) {
for (e_side side : TOTAL_2D_SIDES) {
for (int width = 0; width < type->width; ++width) {
for (int height = 0; height < type->height; ++height) {
for (int pin_offset = 0; pin_offset < (type->num_pins / num_sides) + 1; ++pin_offset) {
Expand All @@ -604,7 +604,7 @@ static void LoadPinLoc(pugi::xml_node Locations,
while (ipin < type->num_pins) {
for (int width = 0; width < type->width; ++width) {
for (int height = 0; height < type->height; ++height) {
for (e_side side : {TOP, RIGHT, BOTTOM, LEFT}) {
for (e_side side : TOTAL_2D_SIDES) {
if (((width == 0 && side == LEFT)
|| (height == type->height - 1 && side == TOP)
|| (width == type->width - 1 && side == RIGHT)
Expand Down Expand Up @@ -645,7 +645,7 @@ static void LoadPinLoc(pugi::xml_node Locations,
while (ipin < input_pins.size()) {
for (int width = 0; width < type->width; ++width) {
for (int height = 0; height < type->height; ++height) {
for (e_side side : {TOP, RIGHT, BOTTOM, LEFT}) {
for (e_side side : TOTAL_2D_SIDES) {
if (ipin < input_pins.size()) {
//Pins still to allocate

Expand All @@ -668,7 +668,7 @@ static void LoadPinLoc(pugi::xml_node Locations,
while (ipin < output_pins.size()) {
for (int width = 0; width < type->width; ++width) {
for (int height = 0; height < type->height; ++height) {
for (e_side side : {TOP, RIGHT, BOTTOM, LEFT}) {
for (e_side side : TOTAL_2D_SIDES) {
if (((width == 0 && side == LEFT)
|| (height == type->height - 1 && side == TOP)
|| (width == type->width - 1 && side == RIGHT)
Expand Down Expand Up @@ -699,8 +699,8 @@ static void LoadPinLoc(pugi::xml_node Locations,
for (int layer = 0; layer < num_of_avail_layer; ++layer) {
for (int width = 0; width < type->width; ++width) {
for (int height = 0; height < type->height; ++height) {
for (e_side side : {TOP, RIGHT, BOTTOM, LEFT}) {
for (const auto& token : pin_locs->assignments[sub_tile_index][width][height][layer][side]) {
for (e_side side : TOTAL_2D_SIDES) {
for (auto token : pin_locs->assignments[sub_tile_index][width][height][layer][side]) {
auto pin_range = ProcessPinString<t_sub_tile*>(Locations,
&sub_tile,
token.c_str(),
Expand Down Expand Up @@ -3393,9 +3393,9 @@ static void ProcessPinLocations(pugi::xml_node Locations,
for (int l = 0; l < num_of_avail_layer; ++l) {
for (int w = 0; w < PhysicalTileType->width; ++w) {
for (int h = 0; h < PhysicalTileType->height; ++h) {
for (e_side side : {TOP, RIGHT, BOTTOM, LEFT}) {
for (const auto& token : pin_locs->assignments[sub_tile_index][w][h][l][side]) {
InstPort inst_port(token);
for (e_side side : TOTAL_2D_SIDES) {
for (auto token : pin_locs->assignments[sub_tile_index][w][h][l][side]) {
InstPort inst_port(token.c_str());

//A pin specification should contain only the block name, and not any instance count information
if (inst_port.instance_low_index() != InstPort::UNSPECIFIED || inst_port.instance_high_index() != InstPort::UNSPECIFIED) {
Expand Down Expand Up @@ -4766,9 +4766,9 @@ static int find_switch_by_name(const t_arch& arch, const std::string& switch_nam
}

static e_side string_to_side(const std::string& side_str) {
e_side side = NUM_SIDES;
e_side side = NUM_2D_SIDES;
if (side_str.empty()) {
side = NUM_SIDES;
side = NUM_2D_SIDES;
} else if (side_str == "left") {
side = LEFT;
} else if (side_str == "right") {
Expand Down
14 changes: 9 additions & 5 deletions libs/librrgraph/src/base/check_rr_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,12 @@ void check_rr_graph(const RRGraphView& rr_graph,
rr_graph.node_layer(rr_node)});
std::string pin_name = block_type_pin_index_to_name(block_type, rr_graph.node_pin_num(rr_node), is_flat);
/* Print error messages for all the sides that a node may appear */
for (const e_side& node_side : SIDES) {
for (const e_side& node_side : TOTAL_2D_SIDES) {
if (!rr_graph.is_node_on_specific_side(rr_node, node_side)) {
continue;
}
VTR_LOG_ERROR("in check_rr_graph: node %d (%s) at (%d,%d) block=%s side=%s pin=%s has no fanin.\n",
inode, rr_graph.node_type_string(rr_node), rr_graph.node_xlow(rr_node), rr_graph.node_ylow(rr_node), block_type->name, SIDE_STRING[node_side], pin_name.c_str());
inode, rr_graph.node_type_string(rr_node), rr_graph.node_xlow(rr_node), rr_graph.node_ylow(rr_node), block_type->name, TOTAL_2D_SIDE_STRINGS[node_side], pin_name.c_str());
}
}
} else {
Expand Down Expand Up @@ -498,9 +498,13 @@ void check_rr_node(const RRGraphView& rr_graph,
tracks_per_node = ((rr_type == CHANX) ? chan_width.x_list[ylow] : chan_width.y_list[xlow]);
}

if (ptc_num >= nodes_per_chan) {
VPR_ERROR(VPR_ERROR_ROUTE,
"in check_rr_node: inode %d (type %d) has a ptc_num of %d.\n", inode, rr_type, ptc_num);
//if a chanx/chany has length 0, it means it is used to connect different dice together
//hence, the ptc number can be larger than nodes_per_chan
if(xlow != xhigh || ylow != yhigh) {
if (ptc_num >= nodes_per_chan) {
VPR_ERROR(VPR_ERROR_ROUTE,
"in check_rr_node: inode %d (type %d) has a ptc_num of %d.\n", inode, rr_type, ptc_num);
}
}

if (capacity != tracks_per_node) {
Expand Down
6 changes: 3 additions & 3 deletions libs/librrgraph/src/base/rr_graph_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ void RRGraphBuilder::add_node_to_all_locs(RRNodeId node) {
case SOURCE:
case SINK:
case CHANY:
node_lookup_.add_node(node,node_layer, ix, iy, node_type, node_ptc_num, SIDES[0]);
node_lookup_.add_node(node, node_layer, ix, iy, node_type, node_ptc_num, TOTAL_2D_SIDES[0]);
break;
case CHANX:
/* Currently need to swap x and y for CHANX because of chan, seg convention
* TODO: Once the builders is reworked for use consistent (x, y) convention,
* the following swapping can be removed
*/
node_lookup_.add_node(node,node_layer, iy, ix, node_type, node_ptc_num, SIDES[0]);
node_lookup_.add_node(node, node_layer, iy, ix, node_type, node_ptc_num, TOTAL_2D_SIDES[0]);
break;
case OPIN:
case IPIN:
for (const e_side& side : SIDES) {
for (const e_side& side : TOTAL_2D_SIDES) {
if (node_storage_.is_node_on_specific_side(node, side)) {
node_lookup_.add_node(node,node_layer, ix, iy, node_type, node_ptc_num, side);
}
Expand Down
4 changes: 2 additions & 2 deletions libs/librrgraph/src/base/rr_graph_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ RRNodeId RRGraph::create_node(const t_rr_type& type) {
node_ptc_nums_.push_back(-1);
node_cost_indices_.push_back(-1);
node_directions_.push_back(Direction::NONE);
node_sides_.push_back(NUM_SIDES);
node_sides_.push_back(NUM_2D_SIDES);
node_Rs_.push_back(0.);
node_Cs_.push_back(0.);

Expand Down Expand Up @@ -1133,7 +1133,7 @@ void RRGraph::build_fast_node_lookup() const {
if (node_type(node) == OPIN || node_type(node) == IPIN) {
iside = node_side(node);
} else {
iside = NUM_SIDES;
iside = NUM_2D_SIDES;
}

if (iside >= node_lookup_[x][y][itype][ptc].size()) {
Expand Down
4 changes: 2 additions & 2 deletions libs/librrgraph/src/base/rr_graph_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class RRGraph {
/* Find the edges connecting two nodes */
std::vector<RREdgeId> find_edges(const RRNodeId& src_node, const RRNodeId& sink_node) const;
/* Find a node with given features from internal fast look-up */
RRNodeId find_node(const short& x, const short& y, const t_rr_type& type, const int& ptc, const e_side& side = NUM_SIDES) const;
RRNodeId find_node(const short& x, const short& y, const t_rr_type& type, const int& ptc, const e_side& side = NUM_2D_SIDES) const;
/* Find the number of routing tracks in a routing channel with a given coordinate */
short chan_num_tracks(const short& x, const short& y, const t_rr_type& type) const;

Expand Down Expand Up @@ -828,7 +828,7 @@ class RRGraph {
bool dirty_ = false;

/* Fast look-up to search a node by its type, coordinator and ptc_num
* Indexing of fast look-up: [0..xmax][0..ymax][0..NUM_TYPES-1][0..ptc_max][0..NUM_SIDES-1]
* Indexing of fast look-up: [0..xmax][0..ymax][0..NUM_TYPES-1][0..ptc_max][0..NUM_2D_SIDES-1]
*/
typedef std::vector<std::vector<std::vector<std::vector<std::vector<RRNodeId>>>>> NodeLookup;
mutable NodeLookup node_lookup_;
Expand Down
10 changes: 5 additions & 5 deletions libs/librrgraph/src/base/rr_graph_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,13 @@ const std::string& t_rr_graph_storage::node_direction_string(RRNodeId id) const
}

const char* t_rr_graph_storage::node_side_string(RRNodeId id) const {
for (const e_side& side : SIDES) {
for (const e_side& side : TOTAL_2D_SIDES) {
if (is_node_on_specific_side(id, side)) {
return SIDE_STRING[side];
return TOTAL_2D_SIDE_STRINGS[side];
}
}
/* Not found, return an invalid string*/
return SIDE_STRING[NUM_SIDES];
return TOTAL_2D_SIDE_STRINGS[NUM_2D_SIDES];
}

void t_rr_graph_storage::set_node_layer(RRNodeId id, short layer) {
Expand Down Expand Up @@ -771,10 +771,10 @@ void t_rr_graph_storage::add_node_side(RRNodeId id, e_side new_side) {
if (node_type(id) != IPIN && node_type(id) != OPIN) {
VTR_LOG_ERROR("Attempted to set RR node 'side' for non-channel type '%s'", node_type_string(id));
}
std::bitset<NUM_SIDES> side_bits = node_storage_[id].dir_side_.sides;
std::bitset<NUM_2D_SIDES> side_bits = node_storage_[id].dir_side_.sides;
side_bits[size_t(new_side)] = true;
if (side_bits.to_ulong() > CHAR_MAX) {
VTR_LOG_ERROR("Invalid side '%s' to be added to rr node %u", SIDE_STRING[new_side], size_t(id));
VTR_LOG_ERROR("Invalid side '%s' to be added to rr node %u", TOTAL_2D_SIDE_STRINGS[new_side], size_t(id));
}
node_storage_[id].dir_side_.sides = static_cast<unsigned char>(side_bits.to_ulong());
}
Expand Down
Loading

0 comments on commit 734d54a

Please sign in to comment.