Skip to content

Commit

Permalink
add xilinx_finish.
Browse files Browse the repository at this point in the history
  • Loading branch information
wanda-phi committed Dec 3, 2024
1 parent 5cdc6ed commit 50cc390
Show file tree
Hide file tree
Showing 119 changed files with 2,624 additions and 128 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ members = [
"prjcombine_xact_geom",
"prjcombine_xact_dump",
"prjcombine_xact_hammer",
"prjcombine_xilinx_rdis",
"prjcombine_xilinx_finish",
"prjcombine_vm6",
"prjcombine_xilinx_cpld",
"prjcombine_xilinx_recpld",
"prjcombine_sdf",
"prjcombine_xc9500",
"prjcombine_xpla3",
"prjcombine_xc2c",
"prjcombine_xilinx_rdis",
]
resolver = "2"

Expand Down
1 change: 1 addition & 0 deletions databases/fpgacore.json

Large diffs are not rendered by default.

Binary file added databases/fpgacore.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/spartan3.json

Large diffs are not rendered by default.

Binary file added databases/spartan3.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/spartan6.json

Large diffs are not rendered by default.

Binary file added databases/spartan6.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/spartanxl.json

Large diffs are not rendered by default.

Binary file added databases/spartanxl.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/ultrascale.json

Large diffs are not rendered by default.

Binary file added databases/ultrascale.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/virtex.json

Large diffs are not rendered by default.

Binary file added databases/virtex.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/virtex2.json

Large diffs are not rendered by default.

Binary file added databases/virtex2.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/virtex4.json

Large diffs are not rendered by default.

Binary file added databases/virtex4.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/virtex5.json

Large diffs are not rendered by default.

Binary file added databases/virtex5.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/virtex6.json

Large diffs are not rendered by default.

Binary file added databases/virtex6.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/virtex7.json

Large diffs are not rendered by default.

Binary file added databases/virtex7.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/xc2000.json

Large diffs are not rendered by default.

Binary file added databases/xc2000.zstd
Binary file not shown.
1 change: 0 additions & 1 deletion databases/xc2k-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc2v-tiledb.json

This file was deleted.

2 changes: 1 addition & 1 deletion databases/xc3k-tiledb.json → databases/xc3000.json

Large diffs are not rendered by default.

Binary file added databases/xc3000.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/xc3000a.json

Large diffs are not rendered by default.

Binary file added databases/xc3000a.zstd
Binary file not shown.
1 change: 0 additions & 1 deletion databases/xc3ka-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc3s-tiledb.json

This file was deleted.

1 change: 1 addition & 0 deletions databases/xc4000.json

Large diffs are not rendered by default.

Binary file added databases/xc4000.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/xc4000a.json

Large diffs are not rendered by default.

Binary file added databases/xc4000a.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/xc4000e.json

Large diffs are not rendered by default.

Binary file added databases/xc4000e.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/xc4000ex.json

Large diffs are not rendered by default.

Binary file added databases/xc4000ex.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/xc4000h.json

Large diffs are not rendered by default.

Binary file added databases/xc4000h.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/xc4000xla.json

Large diffs are not rendered by default.

Binary file added databases/xc4000xla.zstd
Binary file not shown.
1 change: 1 addition & 0 deletions databases/xc4000xv.json

Large diffs are not rendered by default.

Binary file added databases/xc4000xv.zstd
Binary file not shown.
1 change: 0 additions & 1 deletion databases/xc4k-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc4ka-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc4ke-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc4kex-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc4kh-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc4kxla-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc4kxv-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc4v-tiledb.json

This file was deleted.

1 change: 1 addition & 0 deletions databases/xc5200.json

Large diffs are not rendered by default.

Binary file added databases/xc5200.zstd
Binary file not shown.
1 change: 0 additions & 1 deletion databases/xc5k-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc5kx-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc5v-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc6s-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc6v-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xc7v-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xcexf-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xcsxl-tiledb.json

This file was deleted.

1 change: 0 additions & 1 deletion databases/xcv-tiledb.json

This file was deleted.

2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ generated-xpla3: gen_xpla3.py ../databases/xpla3.json
generated-xc2c: gen_xc2c.py ../databases/xc2c.json
python gen_xc2c.py

generated-xilinx: gen_xilinx.py ../databases/xc2v-tiledb.json ../databases/xc3s-tiledb.json
generated-xilinx: gen_xilinx.py ../databases/virtex2.json ../databases/spartan3.json
python gen_xilinx.py

.PHONY: generated-xc9500 generated-xpla3 generated-xc2c generated-xilinx
35 changes: 25 additions & 10 deletions docs/gen_xilinx.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
import json

for kind in [
"xc2k",
"xc3k", "xc3ka",
"xc4k", "xc4ka","xc4kh", "xc4ke", "xc4kex", "xc4kxla", "xc4kxv", "xcsxl",
"xc5k",
"xcv",
"xc2v", "xc3s", "xcexf",
"xc6s",
"xc4v", "xc5v", "xc6v", "xc7v"
for (kind, dbname) in [
("xc2k", "xc2000"),
("xc3k", "xc3000"),
("xc3ka", "xc3000a"),
("xc4k", "xc4000"),
("xc4ka", "xc4000a"),
("xc4kh", "xc4000h"),
("xc4ke", "xc4000e"),
("xc4kex", "xc4000ex"),
("xc4kxla", "xc4000xla"),
("xc4kxv", "xc4000xv"),
("xcsxl", "spartanxl"),
("xc5k", "xc5200"),
("xcv", "virtex"),
("xc2v", "virtex2"),
("xc3s", "spartan3"),
("xcexf", "fpgacore"),
("xc6s", "spartan6"),
("xc4v", "virtex4"),
("xc5v", "virtex5"),
("xc6v", "virtex6"),
("xc7v", "virtex7"),
]:
with open(f"../databases/{kind}-tiledb.json") as dbf:
with open(f"../databases/{dbname}.json") as dbf:
db = json.load(dbf)

db = db["tiles"]

def emit_misc_table(fname, *prefixes):
items = []
for name, data in db["misc_data"].items():
Expand Down
1 change: 1 addition & 0 deletions prjcombine_int/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition.workspace = true
[dependencies]
unnamed_entity.workspace = true
serde.workspace = true
serde_json.workspace = true
enum-map.workspace = true
ndarray.workspace = true
bimap.workspace = true
Expand Down
126 changes: 126 additions & 0 deletions prjcombine_int/src/db.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use enum_map::Enum;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use unnamed_entity::{entity_id, EntityMap, EntityPartVec, EntityVec};

Expand Down Expand Up @@ -273,3 +274,128 @@ impl TermIndex {
}
}
}

impl IntDb {
pub fn to_json(&self) -> serde_json::Value {
json!({
"wires": Vec::from_iter(self.wires.iter().map(|(_, name, wire)| {
json!({
"name": name,
"kind": match wire {
WireKind::Tie0 => "TIE_0".into(),
WireKind::Tie1 => "TIE_1".into(),
WireKind::TiePullup => "TIE_PULLUP".into(),
WireKind::ClkOut(idx) => format!("CLKOUT{idx}"),
WireKind::MuxOut => "MUX_OUT".into(),
WireKind::LogicOut => "LOGIC_OUT".into(),
WireKind::TestOut => "TEST_OUT".into(),
WireKind::MultiOut => "MULTI_OUT".into(),
WireKind::PipOut => "PIP_OUT".into(),
WireKind::Buf(wire_id) => format!("BUF:{}", self.wires.key(*wire_id)),
WireKind::MultiBranch(dir) => format!("MULTI_BRANCH:{dir}"),
WireKind::PipBranch(dir) => format!("PIP_BRANCH:{dir}"),
WireKind::Branch(dir) => format!("BRANCH:{dir}"),
}
})
})),
"nodes": serde_json::Map::from_iter(self.nodes.iter().map(|(_, name, node)| {
(name.into(), json!({
"tiles": node.tiles.len(),
"muxes": serde_json::Map::from_iter(node.muxes.iter().map(|(wt, mux)| {
(
format!("{}:{}", wt.0, self.wires.key(wt.1)),
json!({
"kind": match mux.kind {
MuxKind::Plain => "PLAIN",
MuxKind::Inv => "INV",
MuxKind::OptInv => "OPTINV",
},
"ins": Vec::from_iter(mux.ins.iter().map(|wf| format!(
"{}:{}", wf.0, self.wires.key(wf.1)
))),
})
)
})),
"iris": node.iris.len(),
"intfs": serde_json::Map::from_iter(node.intfs.iter().map(|(wt, intf)| {
(
format!("{}:{}", wt.0, self.wires.key(wt.1)),
match intf {
IntfInfo::OutputTestMux(ins) => json!({
"kind": "OUTPUT_TEST_MUX",
"ins": Vec::from_iter(ins.iter().map(|wf| format!(
"{}:{}", wf.0, self.wires.key(wf.1)
))),
}),
IntfInfo::OutputTestMuxPass(ins, def) => json!({
"kind": "OUTPUT_TEST_MUX_PASS",
"ins": Vec::from_iter(ins.iter().map(|wf| format!(
"{}:{}", wf.0, self.wires.key(wf.1)
))),
"default": format!("{}:{}", def.0, self.wires.key(def.1)),
}),
IntfInfo::InputDelay => json!({
"kind": "INPUT_DELAY",
}),
IntfInfo::InputIri(iri, pin) => json!({
"kind": "INPUT_IRI",
"iri": iri,
"pin": match pin {
IriPin::Clk => "CLK".to_string(),
IriPin::Rst => "RST".to_string(),
IriPin::Ce(i) => format!("CE{i}"),
IriPin::Imux(i) => format!("IMUX{i}"),
},
}),
IntfInfo::InputIriDelay(iri, pin) => json!({
"kind": "INPUT_IRI_DELAY",
"iri": iri,
"pin": match pin {
IriPin::Clk => "CLK".to_string(),
IriPin::Rst => "RST".to_string(),
IriPin::Ce(i) => format!("CE{i}"),
IriPin::Imux(i) => format!("IMUX{i}"),
},
}),
}
)
})),
"bels": Vec::from_iter(node.bels.iter().map(|(_, name, bel)| json!({
"name": name,
"pins": serde_json::Map::from_iter(bel.pins.iter().map(|(pname, pin)| (pname.to_string(), json!({
"wires": Vec::from_iter(pin.wires.iter().map(|wf| format!(
"{}:{}", wf.0, self.wires.key(wf.1)
))),
"dir": match pin.dir {
PinDir::Input => "INPUT",
PinDir::Output => "OUTPUT",
PinDir::Inout => "INOUT",
},
"is_intf_in": pin.is_intf_in,
})))),
}))),
}))
})),
"terms": serde_json::Map::from_iter(self.terms.iter().map(|(_, name, term)| {
(name.into(), json!({
"dir": term.dir.to_string(),
"wires": serde_json::Map::from_iter(term.wires.iter().map(|(wire, ti)|
(self.wires.key(wire).to_string(), match *ti {
TermInfo::BlackHole => json!({
"kind": "BLACKHOLE",
}),
TermInfo::PassNear(wf) => json!({
"kind": "PASS_NEAR",
"wire": self.wires.key(wf),
}),
TermInfo::PassFar(wf) => json!({
"kind": "PASS_FAR",
"wire": self.wires.key(wf),
}),
})
))
}))
})),
})
}
}
6 changes: 6 additions & 0 deletions prjcombine_int/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ pub struct SimpleIoCoord {
pub iob: TileIobId,
}

impl std::fmt::Display for SimpleIoCoord {
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)
}
}

pub type Coord = (ColId, RowId);
pub type NodeLoc = (DieId, ColId, RowId, LayerId);
pub type IntWire = (DieId, Coord, WireId);
Expand Down
4 changes: 2 additions & 2 deletions prjcombine_ise_hammer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use crate::diff::CollectorCtx;
struct Args {
toolchain: PathBuf,
geomdb: PathBuf,
json: PathBuf,
tiledb: PathBuf,
parts: Vec<String>,
#[arg(long)]
skip_io: bool,
Expand Down Expand Up @@ -951,6 +951,6 @@ fn main() -> Result<(), Box<dyn Error>> {
}
}
}
std::fs::write(args.json, tiledb.to_json().to_string())?;
tiledb.to_file(&args.tiledb)?;
Ok(())
}
4 changes: 4 additions & 0 deletions prjcombine_spartan6/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ version.workspace = true
edition.workspace = true

[dependencies]
serde_json.workspace = true
zstd.workspace = true
bincode.workspace = true
unnamed_entity.workspace = true
prjcombine_int.workspace = true
prjcombine_types.workspace = true
prjcombine_virtex_bitstream.workspace = true
serde.workspace = true
enum-map.workspace = true
Expand Down
55 changes: 51 additions & 4 deletions prjcombine_spartan6/src/bond.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use prjcombine_int::grid::SimpleIoCoord;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::collections::{BTreeMap, BTreeSet};

#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum CfgPin {
Tck,
Tdi,
Expand All @@ -14,7 +15,7 @@ pub enum CfgPin {
Suspend,
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum GtPin {
TxP(u8),
TxN(u8),
Expand All @@ -30,7 +31,7 @@ pub enum GtPin {
AVttRCal,
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum BondPin {
Io(SimpleIoCoord),
Nc,
Expand All @@ -45,7 +46,7 @@ pub enum BondPin {
Gt(u32, GtPin),
}

#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct Bond {
pub pins: BTreeMap<String, BondPin>,
// device bank -> pkg bank
Expand Down Expand Up @@ -81,4 +82,50 @@ impl Bond {
gts,
}
}

pub fn to_json(&self) -> serde_json::Value {
json!({
"pins": serde_json::Map::from_iter(
self.pins.iter().map(|(pin, pad)| (pin.clone(), match pad {
BondPin::Io(io) => io.to_string(),
BondPin::Gt(bank, pad) => match pad {
GtPin::RxP(i) => format!("GT{bank}_RXP{i}"),
GtPin::RxN(i) => format!("GT{bank}_RXN{i}"),
GtPin::TxP(i) => format!("GT{bank}_TXP{i}"),
GtPin::TxN(i) => format!("GT{bank}_TXN{i}"),
GtPin::ClkP(i) => format!("GT{bank}_CLKP{i}"),
GtPin::ClkN(i) => format!("GT{bank}_CLKN{i}"),
GtPin::VtRx => format!("GT{bank}_VTRX"),
GtPin::VtTx => format!("GT{bank}_VTTX"),
GtPin::AVcc => format!("GT{bank}_AVCC"),
GtPin::AVccPll(i) => format!("GT{bank}_AVCCPLL{i}"),
GtPin::RRef => format!("GT{bank}_RREF"),
GtPin::AVttRCal => format!("GT{bank}_AVTTRCAL"),
},
BondPin::Gnd => "GND".to_string(),
BondPin::VccO(bank) => format!("VCCO{bank}"),
BondPin::Nc => "NC".to_string(),
BondPin::Cfg(cfg_pin) => match cfg_pin {
CfgPin::Done => "DONE",
CfgPin::ProgB => "PROG_B",
CfgPin::Tck => "TCK",
CfgPin::Tms => "TMS",
CfgPin::Tdi => "TDI",
CfgPin::Tdo => "TDO",
CfgPin::Suspend => "SUSPEND",
CfgPin::CmpCsB => "CMP_CS_B",
}.to_string(),
BondPin::VccInt => "VCCINT".to_string(),
BondPin::VccAux => "VCCAUX".to_string(),
BondPin::VccBatt => "VCCBATT".to_string(),
BondPin::Vfs => "VFS".to_string(),
BondPin::RFuse => "RFUSE".to_string(),
}.into()))
),
"io_banks": serde_json::Map::from_iter(self.io_banks.iter().map(|(k, v)| (
k.to_string(), (*v).into()
))),
"vref": Vec::from_iter(self.vref.iter().map(|io| io.to_string())),
})
}
}
Loading

0 comments on commit 50cc390

Please sign in to comment.