Skip to content

Commit

Permalink
Merge pull request YosysHQ#694 from YosysHQ/gatecat/interchange-glbroute
Browse files Browse the repository at this point in the history
interchange: Initial global routing implementation
  • Loading branch information
gatecat authored May 7, 2021
2 parents 3144e83 + 51949d9 commit 432b9d8
Show file tree
Hide file tree
Showing 5 changed files with 337 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/interchange_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
env:
RAPIDWRIGHT_PATH: ${{ github.workspace }}/RapidWright
PYTHON_INTERCHANGE_PATH: ${{ github.workspace }}/python-fpga-interchange
PYTHON_INTERCHANGE_TAG: v0.0.11
PYTHON_INTERCHANGE_TAG: v0.0.12
PRJOXIDE_REVISION: b5d88c3491770559c3c10cccb1651db65ab061b1
DEVICE: ${{ matrix.device }}
run: |
Expand Down
30 changes: 30 additions & 0 deletions fpga_interchange/arch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,32 @@ IdString Arch::getWireType(WireId wire) const
return IdString(chip_info->wire_types[wire_type].name);
}

bool Arch::is_site_wire(WireId wire) const
{
if (wire.tile == -1)
return false;
const auto &tile_type = loc_info(chip_info, wire);
return tile_type.wire_data[wire.index].site != -1;
}

WireCategory Arch::get_wire_category(WireId wire) const
{
int tile = wire.tile, index = wire.index;
if (tile == -1) {
// Nodal wire
const TileWireRefPOD &wr = chip_info->nodes[wire.index].tile_wires[0];
tile = wr.tile;
index = wr.index;
}
auto &w2t = chip_info->tiles[tile].tile_wire_to_type;
if (index >= w2t.ssize())
return WIRE_CAT_GENERAL;
int wire_type = w2t[index];
if (wire_type == -1)
return WIRE_CAT_GENERAL;
return WireCategory(chip_info->wire_types[wire_type].category);
}

std::vector<std::pair<IdString, std::string>> Arch::getWireAttrs(WireId wire) const { return {}; }

// -----------------------------------------------------------------------
Expand Down Expand Up @@ -773,6 +799,8 @@ bool Arch::place()
getCtx()->check();
#endif

place_globals();

std::string placer = str_or_default(settings, id("placer"), defaultPlacer);
if (placer == "heap") {
PlacerHeapCfg cfg(getCtx());
Expand Down Expand Up @@ -895,6 +923,8 @@ bool Arch::route()
// terminate at a BEL pin.
disallow_site_routing = true;

route_globals();

bool result;
if (router == "router1") {
result = router1(getCtx(), Router1Cfg(getCtx()));
Expand Down
8 changes: 8 additions & 0 deletions fpga_interchange/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ struct Arch : ArchAPI<ArchRanges>
return range;
}

bool is_site_wire(WireId wire) const;
WireCategory get_wire_category(WireId wire) const;

// -------------------------------------------------

PipId getPipByName(IdStringList name) const final;
Expand Down Expand Up @@ -686,6 +689,11 @@ struct Arch : ArchAPI<ArchRanges>
std::unordered_set<CellInfo *> *placed_cells);
void pack_ports();
void decode_lut_cells();

const GlobalCellPOD *global_cell_info(IdString cell_type) const;
void place_globals();
void route_globals();

bool pack() final;
bool place() final;
bool route() final;
Expand Down
15 changes: 14 additions & 1 deletion fpga_interchange/chipdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ NEXTPNR_NAMESPACE_BEGIN
* kExpectedChipInfoVersion
*/

static constexpr int32_t kExpectedChipInfoVersion = 8;
static constexpr int32_t kExpectedChipInfoVersion = 9;

// Flattened site indexing.
//
Expand Down Expand Up @@ -320,6 +320,18 @@ NPNR_PACKED_STRUCT(struct WireTypePOD {
int32_t category; // WireCategory
});

NPNR_PACKED_STRUCT(struct GlobalCellPinPOD {
int32_t name; // constid
int16_t max_hops; // max routing hops to try
int8_t guide_placement;
int8_t force_routing;
});

NPNR_PACKED_STRUCT(struct GlobalCellPOD {
int32_t cell_type;
RelSlice<GlobalCellPinPOD> pins;
});

NPNR_PACKED_STRUCT(struct ChipInfoPOD {
RelPtr<char> name;
RelPtr<char> generator;
Expand All @@ -333,6 +345,7 @@ NPNR_PACKED_STRUCT(struct ChipInfoPOD {
RelSlice<NodeInfoPOD> nodes;
RelSlice<PackagePOD> packages;
RelSlice<WireTypePOD> wire_types;
RelSlice<GlobalCellPOD> global_cells;

// BEL bucket constids.
RelSlice<int32_t> bel_buckets;
Expand Down
Loading

0 comments on commit 432b9d8

Please sign in to comment.