Skip to content

Commit

Permalink
new EdgeIoCoord struct.
Browse files Browse the repository at this point in the history
  • Loading branch information
wanda-phi committed Dec 18, 2024
1 parent f623daf commit 00b41c7
Show file tree
Hide file tree
Showing 75 changed files with 1,117 additions and 1,244 deletions.
2 changes: 1 addition & 1 deletion databases/fpgacore.json

Large diffs are not rendered by default.

Binary file modified databases/fpgacore.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/spartan3.json

Large diffs are not rendered by default.

Binary file modified databases/spartan3.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/spartan6.json

Large diffs are not rendered by default.

Binary file modified databases/spartan6.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/spartanxl.json

Large diffs are not rendered by default.

Binary file modified databases/spartanxl.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/virtex.json

Large diffs are not rendered by default.

Binary file modified databases/virtex.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/virtex2.json

Large diffs are not rendered by default.

Binary file modified databases/virtex2.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/xc2000.json

Large diffs are not rendered by default.

Binary file modified databases/xc2000.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/xc3000.json

Large diffs are not rendered by default.

Binary file modified databases/xc3000.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/xc3000a.json

Large diffs are not rendered by default.

Binary file modified databases/xc3000a.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/xc4000.json

Large diffs are not rendered by default.

Binary file modified databases/xc4000.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/xc4000a.json

Large diffs are not rendered by default.

Binary file modified databases/xc4000a.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/xc4000e.json

Large diffs are not rendered by default.

Binary file modified databases/xc4000e.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/xc4000ex.json

Large diffs are not rendered by default.

Binary file modified databases/xc4000ex.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/xc4000h.json

Large diffs are not rendered by default.

Binary file modified databases/xc4000h.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/xc4000xla.json

Large diffs are not rendered by default.

Binary file modified databases/xc4000xla.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/xc4000xv.json

Large diffs are not rendered by default.

Binary file modified databases/xc4000xv.zstd
Binary file not shown.
2 changes: 1 addition & 1 deletion databases/xc5200.json

Large diffs are not rendered by default.

Binary file modified databases/xc5200.zstd
Binary file not shown.
35 changes: 23 additions & 12 deletions prjcombine_int/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,32 @@ entity_id! {
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd, Serialize, Deserialize)]
pub struct SimpleIoCoord {
pub col: ColId,
pub row: RowId,
pub iob: TileIobId,
pub enum EdgeIoCoord {
T(ColId, TileIobId),
R(RowId, TileIobId),
B(ColId, TileIobId),
L(RowId, TileIobId),
}

impl std::fmt::Display for SimpleIoCoord {
impl EdgeIoCoord {
pub fn with_iob(self, iob: TileIobId) -> Self {
match self {
EdgeIoCoord::T(col, _) => EdgeIoCoord::T(col, iob),
EdgeIoCoord::R(row, _) => EdgeIoCoord::R(row, iob),
EdgeIoCoord::B(col, _) => EdgeIoCoord::B(col, iob),
EdgeIoCoord::L(row, _) => EdgeIoCoord::L(row, iob),
}
}
}

impl std::fmt::Display for EdgeIoCoord {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"IOB_X{x}Y{y}B{b}",
x = self.col,
y = self.row,
b = self.iob
)
match self {
EdgeIoCoord::T(col, iob) => write!(f, "IOB_T{col}_{iob}"),
EdgeIoCoord::R(row, iob) => write!(f, "IOB_R{row}_{iob}"),
EdgeIoCoord::B(col, iob) => write!(f, "IOB_B{col}_{iob}"),
EdgeIoCoord::L(row, iob) => write!(f, "IOB_L{row}_{iob}"),
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion prjcombine_ise_hammer/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl<'a> Backend for IseBackend<'a> {
site_to_place.insert(name.to_string(), k.to_string());
}
}
for io in endev.edev.get_bonded_ios() {
for io in endev.grid.get_bonded_ios() {
let name = endev.get_io_name(io);
match site_to_place.entry(name.to_string()) {
hash_map::Entry::Occupied(_) => (),
Expand Down
111 changes: 40 additions & 71 deletions prjcombine_ise_hammer/src/fgen.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use prjcombine_collector::{FeatureId, State};
use prjcombine_int::{
db::{BelId, Dir, NodeKindId, NodeTileId, NodeWireId},
grid::{ColId, DieId, IntWire, LayerId, NodeLoc, RowId, SimpleIoCoord, TileIobId},
grid::{ColId, DieId, IntWire, LayerId, NodeLoc, RowId, TileIobId},
};
use prjcombine_virtex2::iob::IobKind;
use prjcombine_virtex_bitstream::{BitTile, Reg};
Expand Down Expand Up @@ -3234,22 +3234,20 @@ impl<'a> BelKV {
};
match &backend.ebonds[pkg] {
ExpandedBond::Virtex(ebond) => {
let crd = SimpleIoCoord {
col: loc.1,
row: loc.2,
iob: TileIobId::from_idx(bel.to_idx()),
let ExpandedNamedDevice::Virtex(endev) = backend.endev else {
unreachable!()
};
let crd = endev.grid.get_io_crd(loc.1, loc.2, bel);
if !ebond.ios.contains_key(&crd) {
return None;
}
fuzzer
}
ExpandedBond::Spartan6(ebond) => {
let crd = SimpleIoCoord {
col: loc.1,
row: loc.2,
iob: TileIobId::from_idx(bel.to_idx()),
let ExpandedNamedDevice::Spartan6(endev) = backend.endev else {
unreachable!()
};
let crd = endev.grid.get_io_crd(loc.1, loc.2, bel);
if !ebond.ios.contains_key(&crd) {
return None;
}
Expand Down Expand Up @@ -3282,12 +3280,8 @@ impl<'a> BelKV {
}
BelKV::IsBank(bank) => match backend.edev {
ExpandedDevice::Spartan6(edev) => {
let crd = SimpleIoCoord {
col: loc.1,
row: loc.2,
iob: TileIobId::from_idx(bel.to_idx()),
};
if edev.get_io_bank(crd) != *bank {
let crd = edev.grid.get_io_crd(loc.1, loc.2, bel);
if edev.grid.get_io_bank(crd) != *bank {
return None;
}
fuzzer
Expand All @@ -3300,11 +3294,10 @@ impl<'a> BelKV {
};
match &backend.ebonds[pkg] {
ExpandedBond::Virtex(ebond) => {
let crd = SimpleIoCoord {
col: loc.1,
row: loc.2,
iob: TileIobId::from_idx(bel.to_idx()),
let ExpandedNamedDevice::Virtex(endev) = backend.endev else {
unreachable!()
};
let crd = endev.grid.get_io_crd(loc.1, loc.2, bel);
if !ebond.bond.diffp.contains(&crd) && !ebond.bond.diffn.contains(&crd) {
return None;
}
Expand All @@ -3319,33 +3312,30 @@ impl<'a> BelKV {
};
match &backend.ebonds[pkg] {
ExpandedBond::Virtex(ebond) => {
let crd = SimpleIoCoord {
col: loc.1,
row: loc.2,
iob: TileIobId::from_idx(bel.to_idx()),
let ExpandedNamedDevice::Virtex(endev) = backend.endev else {
unreachable!()
};
let crd = endev.grid.get_io_crd(loc.1, loc.2, bel);
if !ebond.bond.vref.contains(&crd) {
return None;
}
fuzzer
}
ExpandedBond::Virtex2(ebond) => {
let crd = SimpleIoCoord {
col: loc.1,
row: loc.2,
iob: TileIobId::from_idx(bel.to_idx()),
let ExpandedNamedDevice::Virtex2(endev) = backend.endev else {
unreachable!()
};
let crd = endev.grid.get_io_crd(loc.1, loc.2, bel);
if !ebond.bond.vref.contains(&crd) {
return None;
}
fuzzer
}
ExpandedBond::Spartan6(ebond) => {
let crd = SimpleIoCoord {
col: loc.1,
row: loc.2,
iob: TileIobId::from_idx(bel.to_idx()),
let ExpandedNamedDevice::Spartan6(endev) = backend.endev else {
unreachable!()
};
let crd = endev.grid.get_io_crd(loc.1, loc.2, bel);
if !ebond.bond.vref.contains(&crd) {
return None;
}
Expand Down Expand Up @@ -3384,11 +3374,7 @@ impl<'a> BelKV {
let ExpandedBond::Virtex2(ref ebond) = backend.ebonds[pkg] else {
unreachable!()
};
let crd = SimpleIoCoord {
col: loc.1,
row: loc.2,
iob: TileIobId::from_idx(bel.to_idx()),
};
let crd = edev.grid.get_io_crd(loc.1, loc.2, bel);
let mut is_vr = false;
for (bank, vr) in &edev.grid.dci_io {
if vr.0 == crd || vr.1 == crd {
Expand Down Expand Up @@ -3925,12 +3911,8 @@ impl<'a> BelKV {
};
let bel_key = backend.egrid.db.nodes[node.kind].bels.key(bel);
let (crd, orig_bank) = if bel_key.starts_with("IOB") {
let crd = SimpleIoCoord {
col: loc.1,
row: loc.2,
iob: TileIobId::from_idx(bel.to_idx()),
};
(Some(crd), edev.get_io_bank(crd))
let crd = edev.grid.get_io_crd(loc.1, loc.2, bel);
(Some(crd), edev.grid.get_io_bank(crd))
} else {
(
None,
Expand All @@ -3949,8 +3931,8 @@ impl<'a> BelKV {
},
)
};
for io in edev.get_bonded_ios() {
let bank = edev.get_io_bank(io);
for io in edev.grid.get_bonded_ios() {
let bank = edev.grid.get_io_bank(io);
if Some(io) != crd && bank == orig_bank && ebond.ios.contains_key(&io) {
let site = endev.get_io_name(io);

Expand All @@ -3977,20 +3959,15 @@ impl<'a> BelKV {
let ExpandedNamedDevice::Virtex2(ref endev) = backend.endev else {
unreachable!()
};
let crd = SimpleIoCoord {
col: loc.1,
row: loc.2,
iob: TileIobId::from_idx(bel.to_idx()),
};
let orig_io_info = edev.get_io_info(crd);
for io in edev.get_bonded_ios() {
let io_info = edev.get_io_info(io);
let crd = endev.grid.get_io_crd(loc.1, loc.2, bel);
let orig_io_info = edev.grid.get_io_info(crd);
for io in edev.grid.get_bonded_ios() {
let io_info = edev.grid.get_io_info(io);
if io != crd
&& orig_io_info.bank == io_info.bank
&& io_info.pad_kind != Some(IobKind::Clk)
&& (!is_diff
|| io_info.diff
!= prjcombine_virtex2::expanded::IoDiffKind::None)
|| io_info.diff != prjcombine_virtex2::grid::IoDiffKind::None)
&& ebond.ios.contains_key(&io)
{
let site = endev.get_io_name(io);
Expand All @@ -3999,7 +3976,7 @@ impl<'a> BelKV {
Key::SiteMode(site),
if is_diff {
match io_info.diff {
prjcombine_virtex2::expanded::IoDiffKind::P(_) => {
prjcombine_virtex2::grid::IoDiffKind::P(_) => {
if edev.grid.kind.is_spartan3a() {
"DIFFMI_NDT"
} else if edev.grid.kind.is_spartan3ea() {
Expand All @@ -4008,7 +3985,7 @@ impl<'a> BelKV {
"DIFFM"
}
}
prjcombine_virtex2::expanded::IoDiffKind::N(_) => {
prjcombine_virtex2::grid::IoDiffKind::N(_) => {
if edev.grid.kind.is_spartan3a() {
"DIFFSI_NDT"
} else if edev.grid.kind.is_spartan3ea() {
Expand All @@ -4017,7 +3994,7 @@ impl<'a> BelKV {
"DIFFS"
}
}
prjcombine_virtex2::expanded::IoDiffKind::None => {
prjcombine_virtex2::grid::IoDiffKind::None => {
unreachable!()
}
}
Expand Down Expand Up @@ -4072,19 +4049,15 @@ impl<'a> BelKV {
let ExpandedNamedDevice::Virtex2(ref endev) = backend.endev else {
unreachable!()
};
let crd = SimpleIoCoord {
col: loc.1,
row: loc.2,
iob: TileIobId::from_idx(bel.to_idx()),
};
let crd = edev.grid.get_io_crd(loc.1, loc.2, bel);
let stds = if let Some(stdb) = stdb {
&[stda, stdb][..]
} else {
&[stda][..]
};
let bank = edev.get_io_info(crd).bank;
let bank = edev.grid.get_io_info(crd).bank;
let mut done = 0;
let mut ios = edev.get_bonded_ios();
let mut ios = edev.grid.get_bonded_ios();
if edev.grid.kind != prjcombine_virtex2::grid::GridKind::Spartan3ADsp {
ios.reverse();
}
Expand All @@ -4097,23 +4070,19 @@ impl<'a> BelKV {
continue;
}
}
let io_info = edev.get_io_info(io);
let io_info = edev.grid.get_io_info(io);
if !ebond.ios.contains_key(&io)
|| io_info.bank != bank
|| io_info.pad_kind != Some(IobKind::Iob)
{
continue;
}
let prjcombine_virtex2::expanded::IoDiffKind::P(other_iob) =
io_info.diff
let prjcombine_virtex2::grid::IoDiffKind::P(other_iob) = io_info.diff
else {
continue;
};
// okay, got a pair.
let other_io = SimpleIoCoord {
iob: other_iob,
..io
};
let other_io = io.with_iob(other_iob);
let site_p = endev.get_io_name(io);
let site_n = endev.get_io_name(other_io);
let std = stds[done];
Expand Down
11 changes: 2 additions & 9 deletions prjcombine_ise_hammer/src/io/virtex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ use std::collections::{HashMap, HashSet};
use bitvec::vec::BitVec;
use prjcombine_collector::{xlat_bit, xlat_bitvec, xlat_bool, xlat_enum, Diff};
use prjcombine_hammer::Session;
use prjcombine_int::{
db::BelId,
grid::{SimpleIoCoord, TileIobId},
};
use prjcombine_int::db::BelId;
use prjcombine_types::tiledb::{TileBit, TileItem, TileItemKind};
use prjcombine_virtex::grid::GridKind;
use prjcombine_xilinx_geom::{Bond, Device, ExpandedDevice, GeomDb};
Expand Down Expand Up @@ -39,11 +36,7 @@ fn has_any_vref<'a>(
}
}
for &(_, col, row, _) in &edev.egrid.node_index[node_kind] {
let crd = SimpleIoCoord {
col,
row,
iob: TileIobId::from_idx(bel.to_idx()),
};
let crd = edev.grid.get_io_crd(col, row, bel);
if let Some(&pkg) = bonded_ios.get(&crd) {
return Some(pkg);
}
Expand Down
17 changes: 3 additions & 14 deletions prjcombine_ise_hammer/src/io/virtex2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use prjcombine_collector::{
xlat_item_tile_fwd, Diff, OcdMode,
};
use prjcombine_hammer::Session;
use prjcombine_int::{
db::BelId,
grid::{SimpleIoCoord, TileIobId},
};
use prjcombine_int::db::BelId;
use prjcombine_types::tiledb::{TileBit, TileItem, TileItemKind};
use prjcombine_virtex2::grid::GridKind;
use prjcombine_xilinx_geom::{Bond, Device, ExpandedDevice, GeomDb};
Expand Down Expand Up @@ -311,11 +308,7 @@ fn has_any_vref<'a>(
} else {
col += ioi_tile
}
let crd = SimpleIoCoord {
col,
row,
iob: TileIobId::from_idx(ioi_bel.to_idx()),
};
let crd = edev.grid.get_io_crd(col, row, ioi_bel);
if let Some(&pkg) = bonded_ios.get(&crd) {
return Some(pkg);
}
Expand Down Expand Up @@ -352,11 +345,7 @@ fn has_any_vr<'a>(
} else {
col += ioi_tile
}
let crd = SimpleIoCoord {
col,
row,
iob: TileIobId::from_idx(ioi_bel.to_idx()),
};
let crd = edev.grid.get_io_crd(col, row, ioi_bel);
if let Some(&pkg) = bonded_ios.get(&crd) {
for bank in 0..8 {
if let Some(alt_vr) = edev.grid.dci_io_alt.get(&bank) {
Expand Down
Loading

0 comments on commit 00b41c7

Please sign in to comment.