Skip to content

Commit

Permalink
merge xc2000/xc3000/xc4000/xc5200 data structures.
Browse files Browse the repository at this point in the history
  • Loading branch information
wanda-phi committed Nov 24, 2024
1 parent 9398606 commit cdaf16a
Show file tree
Hide file tree
Showing 101 changed files with 2,056 additions and 2,966 deletions.
18 changes: 2 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@ members = [
"prjcombine_int",
"prjcombine_xilinx_naming",
"prjcombine_xc2000",
"prjcombine_xc3000",
"prjcombine_xc4000",
"prjcombine_xc5200",
"prjcombine_virtex",
"prjcombine_virtex2",
"prjcombine_spartan6",
"prjcombine_virtex4",
"prjcombine_ultrascale",
"prjcombine_versal",
"prjcombine_xc4000_naming",
"prjcombine_xc5200_naming",
"prjcombine_xc2000_naming",
"prjcombine_virtex_naming",
"prjcombine_virtex2_naming",
"prjcombine_virtex4_naming",
Expand Down Expand Up @@ -64,9 +60,6 @@ members = [
"prjcombine_ise_hammer",
"prjcombine_xact_naming",
"prjcombine_xc2000_xact",
"prjcombine_xc3000_xact",
"prjcombine_xc4000_xact",
"prjcombine_xc5200_xact",
"prjcombine_xact_data",
"prjcombine_xact_dump",
"prjcombine_xact_geom",
Expand Down Expand Up @@ -97,13 +90,9 @@ prjcombine_rdgrid = { path = "prjcombine_rdgrid" }
prjcombine_rdintb = { path = "prjcombine_rdintb" }
prjcombine_rdverify = { path = "prjcombine_rdverify" }
prjcombine_xc2000 = { path = "prjcombine_xc2000" }
prjcombine_xc3000 = { path = "prjcombine_xc3000" }
prjcombine_xc4000 = { path = "prjcombine_xc4000" }
prjcombine_xc4000_naming = { path = "prjcombine_xc4000_naming" }
prjcombine_xc2000_naming = { path = "prjcombine_xc2000_naming" }
prjcombine_xc4000_rdverify = { path = "prjcombine_xc4000_rdverify" }
prjcombine_xc4000_rd2db = { path = "prjcombine_xc4000_rd2db" }
prjcombine_xc5200 = { path = "prjcombine_xc5200" }
prjcombine_xc5200_naming = { path = "prjcombine_xc5200_naming" }
prjcombine_xc5200_rdverify = { path = "prjcombine_xc5200_rdverify" }
prjcombine_xc5200_rd2db = { path = "prjcombine_xc5200_rd2db" }
prjcombine_virtex = { path = "prjcombine_virtex" }
Expand Down Expand Up @@ -143,9 +132,6 @@ prjcombine_hammer = { path = "prjcombine_hammer" }
prjcombine_collector = { path = "prjcombine_collector" }
prjcombine_xact_naming = { path = "prjcombine_xact_naming" }
prjcombine_xc2000_xact = { path = "prjcombine_xc2000_xact" }
prjcombine_xc3000_xact = { path = "prjcombine_xc3000_xact" }
prjcombine_xc4000_xact = { path = "prjcombine_xc4000_xact" }
prjcombine_xc5200_xact = { path = "prjcombine_xc5200_xact" }
prjcombine_xact_geom = { path = "prjcombine_xact_geom" }
prjcombine_xact_data = { path = "prjcombine_xact_data" }
prjcombine_vm6 = { path = "prjcombine_vm6" }
Expand Down
8 changes: 8 additions & 0 deletions prjcombine_int/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ entity_id! {
pub id ColId u16, reserve 1, delta;
pub id RowId u16, reserve 1, delta;
pub id LayerId u8;
pub id TileIobId u8;
}

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

pub type Coord = (ColId, RowId);
Expand Down
3 changes: 1 addition & 2 deletions prjcombine_ise_hammer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ prjcombine_types.workspace = true
prjcombine_int.workspace = true
prjcombine_xilinx_naming.workspace = true
prjcombine_xilinx_geom.workspace = true
prjcombine_xc4000.workspace = true
prjcombine_xc5200.workspace = true
prjcombine_xc2000.workspace = true
prjcombine_virtex.workspace = true
prjcombine_virtex2.workspace = true
prjcombine_spartan6.workspace = true
Expand Down
102 changes: 44 additions & 58 deletions prjcombine_ise_hammer/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,48 +259,25 @@ impl<'a> Backend for IseBackend<'a> {

let mut site_to_place = HashMap::new();
let bond = &self.db.bonds[self.device.bonds[combo.devbond_idx].bond];
match bond {
Bond::Xc4000(bond) => {
let ExpandedNamedDevice::Xc4000(endev) = self.endev else {
unreachable!()
};
for (k, v) in &bond.pins {
if let prjcombine_xc4000::bond::BondPin::Io(io) = v {
let name = endev.get_io_name(*io);
site_to_place.insert(name.to_string(), k.to_string());
}
}
for io in endev.edev.get_bonded_ios() {
let name = endev.get_io_name(io);
match site_to_place.entry(name.to_string()) {
hash_map::Entry::Occupied(_) => (),
hash_map::Entry::Vacant(e) => {
e.insert(format!("UNB{suf}", suf = name.strip_prefix("PAD").unwrap()));
}
}
if let Bond::Xc2000(bond) = bond {
let ExpandedNamedDevice::Xc2000(endev) = self.endev else {
unreachable!()
};
for (k, v) in &bond.pins {
if let prjcombine_xc2000::bond::BondPin::Io(io) = v {
let name = endev.get_io_name(*io);
site_to_place.insert(name.to_string(), k.to_string());
}
}
Bond::Xc5200(bond) => {
let ExpandedNamedDevice::Xc5200(endev) = self.endev else {
unreachable!()
};
for (k, v) in &bond.pins {
if let prjcombine_xc5200::bond::BondPin::Io(io) = v {
let name = endev.get_io_name(*io);
site_to_place.insert(name.to_string(), k.to_string());
}
}
for io in endev.edev.get_bonded_ios() {
let name = endev.get_io_name(io);
match site_to_place.entry(name.to_string()) {
hash_map::Entry::Occupied(_) => (),
hash_map::Entry::Vacant(e) => {
e.insert(format!("UNB{suf}", suf = name.strip_prefix("PAD").unwrap()));
}
for io in endev.edev.get_bonded_ios() {
let name = endev.get_io_name(io);
match site_to_place.entry(name.to_string()) {
hash_map::Entry::Occupied(_) => (),
hash_map::Entry::Vacant(e) => {
e.insert(format!("UNB{suf}", suf = name.strip_prefix("PAD").unwrap()));
}
}
}
_ => (),
}

// sigh. bitgen inserts nondeterministic defaults without this.
Expand Down Expand Up @@ -352,8 +329,13 @@ impl<'a> Backend for IseBackend<'a> {
}

let (dummy_inst_kind, dummy_inst_port) = match self.edev {
ExpandedDevice::Xc4000(_) => ("CLB", "K"),
ExpandedDevice::Xc5200(_) => ("LC5A", "CK"),
ExpandedDevice::Xc2000(edev) => {
if edev.grid.kind.is_xc4000() {
("CLB", "K")
} else {
("LC5A", "CK")
}
}
ExpandedDevice::Virtex(_) => ("SLICE", "CLK"),
ExpandedDevice::Virtex2(edev) => (
if edev.grid.kind.is_virtex2() {
Expand Down Expand Up @@ -511,8 +493,7 @@ impl<'a> Backend for IseBackend<'a> {
let inst_name = format!("FAKEINST__{site}__{pin}");
let (fi_kind, fi_pin, fi_cfg) = match kind {
PinFromKind::Iob => match self.edev {
ExpandedDevice::Xc4000(_) => todo!(),
ExpandedDevice::Xc5200(_) => todo!(),
ExpandedDevice::Xc2000(_) => todo!(),
ExpandedDevice::Virtex(_) => todo!(),
ExpandedDevice::Virtex2(edev) => {
let mut cfg = vec![("IMUX", "1")];
Expand Down Expand Up @@ -596,18 +577,22 @@ impl<'a> Backend for IseBackend<'a> {
}
}
let part = match self.edev {
ExpandedDevice::Xc4000(_) => format!(
"{d}{p}{s}",
d = &self.device.name[2..],
p = self.device.bonds[combo.devbond_idx].name,
s = self.device.speeds[combo.speed_idx],
),

ExpandedDevice::Xc5200(_) => format!(
"{d}{p}",
d = &self.device.name[2..],
p = self.device.bonds[combo.devbond_idx].name,
),
ExpandedDevice::Xc2000(edev) => {
if edev.grid.kind.is_xc4000() {
format!(
"{d}{p}{s}",
d = &self.device.name[2..],
p = self.device.bonds[combo.devbond_idx].name,
s = self.device.speeds[combo.speed_idx],
)
} else {
format!(
"{d}{p}",
d = &self.device.name[2..],
p = self.device.bonds[combo.devbond_idx].name,
)
}
}

_ => format!(
"{d}{s}{p}",
Expand All @@ -620,14 +605,15 @@ impl<'a> Backend for IseBackend<'a> {
name: "meow".to_string(),
part,
cfg: vec![],
version: if matches!(self.edev, ExpandedDevice::Xc5200(_)) {
"".to_string()
} else {
"v3.2".to_string()
},
version: "v3.2".to_string(),
instances: insts.into_values().collect(),
nets: nets.into_values().collect(),
};
if let ExpandedDevice::Xc2000(edev) = self.edev {
if !edev.grid.kind.is_xc4000() {
xdl.version = "".to_string();
}
}
xdl.instances.shuffle(&mut rand::thread_rng());
let vccaux = if let Some(Value::String(val)) = kv.get(&Key::VccAux) {
if val.is_empty() {
Expand Down
4 changes: 2 additions & 2 deletions prjcombine_ise_hammer/src/clb/xc4000.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
};

pub fn add_fuzzers<'a>(session: &mut Session<IseBackend<'a>>, backend: &IseBackend<'a>) {
let ExpandedDevice::Xc4000(ref edev) = backend.edev else {
let ExpandedDevice::Xc2000(ref edev) = backend.edev else {
unreachable!()
};
let kind = edev.grid.kind;
Expand Down Expand Up @@ -396,7 +396,7 @@ pub fn add_fuzzers<'a>(session: &mut Session<IseBackend<'a>>, backend: &IseBacke
}

pub fn collect_fuzzers(ctx: &mut CollectorCtx) {
let ExpandedDevice::Xc4000(ref edev) = ctx.edev else {
let ExpandedDevice::Xc2000(ref edev) = ctx.edev else {
unreachable!()
};
let kind = edev.grid.kind;
Expand Down
Loading

0 comments on commit cdaf16a

Please sign in to comment.