Skip to content

Commit

Permalink
add Grid/Bond display impls
Browse files Browse the repository at this point in the history
  • Loading branch information
wanda-phi committed Dec 4, 2024
1 parent e058cb3 commit 489c7a5
Show file tree
Hide file tree
Showing 26 changed files with 1,388 additions and 1,367 deletions.
4 changes: 2 additions & 2 deletions prjcombine_int/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,13 @@ impl IntDb {
},
"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)|
"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",
Expand Down
8 changes: 7 additions & 1 deletion prjcombine_int/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ pub struct SimpleIoCoord {

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)
write!(
f,
"IOB_X{x}Y{y}B{b}",
x = self.col,
y = self.row,
b = self.iob
)
}
}

Expand Down
42 changes: 35 additions & 7 deletions prjcombine_rawdump/src/bin/rd2html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2368,8 +2368,16 @@ const ULTRASCALEPLUS_TILES: &[TileInfo] = &[
),
TileInfo("AMS_M12BUF_SYSMON_BOT_L_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo("AMS_M12BUF_SYSMON_TOP_L_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo("AMS_M12BUF_AMS_LASSEN_TERM_BOT_L_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo("AMS_M12BUF_AMS_LASSEN_TERM_TOP_L_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo(
"AMS_M12BUF_AMS_LASSEN_TERM_BOT_L_FT",
(0, 0, 29, 0),
&["sysmon"],
),
TileInfo(
"AMS_M12BUF_AMS_LASSEN_TERM_TOP_L_FT",
(0, 0, 29, 0),
&["sysmon"],
),
TileInfo("CFG_M12BUF", (0, 0, 29, 0), &[]),
TileInfo("CFG_M12BUF_TERM_L", (0, 0, 29, 0), &[]),
TileInfo("CFG_M12BUF_CFG_BOT_L_FT", (0, 0, 29, 0), &[]),
Expand Down Expand Up @@ -2423,7 +2431,11 @@ const ULTRASCALEPLUS_TILES: &[TileInfo] = &[
TileInfo("CFG_M12BUF_IO_CFG_ALTO_TOP_L_FT", (0, 0, 29, 0), &[]),
// specials for left HDIOLC
TileInfo("CFRM_CBRK_HDIOL_L_FT", (0, 0, 29, 0), &["vbrk"]),
TileInfo("RCLK_RCLK_CBRK_HDIOL_M12BUF_L_FT", (1, 0, 0, 0), &["clk-row"]),
TileInfo(
"RCLK_RCLK_CBRK_HDIOL_M12BUF_L_FT",
(1, 0, 0, 0),
&["clk-row"],
),
TileInfo("CFG_M12BUF_HDIOL_L_FT", (0, 0, 29, 0), &[]),
// specials for left of cfg col
TileInfo("CFRM_CBRK_CTR_RIGHT_L_FT", (0, 0, 29, 0), &["vbrk"]),
Expand Down Expand Up @@ -2452,8 +2464,16 @@ const ULTRASCALEPLUS_TILES: &[TileInfo] = &[
TileInfo("AMS_M12BUF_CTR_RIGHT_TOP_L_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo("AMS_M12BUF_CTR_RIGHT_BOT_R_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo("AMS_M12BUF_CTR_RIGHT_TOP_R_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo("AMS_M12BUF_AMS_LASSEN_IO_BOT_L_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo("AMS_M12BUF_AMS_LASSEN_IO_TOP_L_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo(
"AMS_M12BUF_AMS_LASSEN_IO_BOT_L_FT",
(0, 0, 29, 0),
&["sysmon"],
),
TileInfo(
"AMS_M12BUF_AMS_LASSEN_IO_TOP_L_FT",
(0, 0, 29, 0),
&["sysmon"],
),
TileInfo("CFG_M12BUF_CTR_RIGHT_FT", (0, 0, 29, 0), &[]),
TileInfo("CFG_M12BUF_CTR_RIGHT_CFG_OLY_BOT_L_FT", (0, 0, 29, 0), &[]),
TileInfo("CFG_M12BUF_CTR_RIGHT_CFG_OLY_TOP_L_FT", (0, 0, 29, 0), &[]),
Expand Down Expand Up @@ -2524,8 +2544,16 @@ const ULTRASCALEPLUS_TILES: &[TileInfo] = &[
TileInfo("AMS_M12BUF_TOP_R_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo("AMS_M12BUF_AMS_BOT_R_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo("AMS_M12BUF_AMS_TOP_R_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo("AMS_M12BUF_AMS_LASSEN_IO_BOT_R_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo("AMS_M12BUF_AMS_LASSEN_IO_TOP_R_FT", (0, 0, 29, 0), &["sysmon"]),
TileInfo(
"AMS_M12BUF_AMS_LASSEN_IO_BOT_R_FT",
(0, 0, 29, 0),
&["sysmon"],
),
TileInfo(
"AMS_M12BUF_AMS_LASSEN_IO_TOP_R_FT",
(0, 0, 29, 0),
&["sysmon"],
),
TileInfo("CFG_M12BUF_CFG_BOT_R", (0, 0, 29, 0), &[]),
TileInfo("CFG_M12BUF_CFG_TOP_R", (0, 0, 29, 0), &[]),
TileInfo("CFG_M12BUF_CFG_BOT_R_FT", (0, 0, 29, 0), &[]),
Expand Down
1 change: 1 addition & 0 deletions prjcombine_spartan6/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version.workspace = true
edition.workspace = true

[dependencies]
itertools.workspace = true
serde_json.workspace = true
zstd.workspace = true
bincode.workspace = true
Expand Down
61 changes: 61 additions & 0 deletions prjcombine_spartan6/src/bond.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use itertools::Itertools;
use prjcombine_int::grid::SimpleIoCoord;
use serde::{Deserialize, Serialize};
use serde_json::json;
Expand Down Expand Up @@ -129,3 +130,63 @@ impl Bond {
})
}
}

fn pad_sort_key(name: &str) -> (usize, &str, u32) {
let pos = name.find(|x: char| x.is_ascii_digit()).unwrap();
(pos, &name[..pos], name[pos..].parse().unwrap())
}

impl std::fmt::Display for Bond {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "\tBANKS:")?;
for (k, v) in &self.io_banks {
writeln!(f, "\t\t{k}: {v}")?;
}
writeln!(f, "\tPINS:")?;
for (pin, pad) in self.pins.iter().sorted_by_key(|(k, _)| pad_sort_key(k)) {
write!(f, "\t\t{pin:4}: ")?;
match pad {
BondPin::Io(io) => write!(f, "{io}")?,
BondPin::Gt(bank, gtpin) => {
write!(f, "GT{bank}.")?;
match gtpin {
GtPin::RxP(idx) => write!(f, "RXP{idx}")?,
GtPin::RxN(idx) => write!(f, "RXN{idx}")?,
GtPin::TxP(idx) => write!(f, "TXP{idx}")?,
GtPin::TxN(idx) => write!(f, "TXN{idx}")?,
GtPin::VtRx => write!(f, "VTRX")?,
GtPin::VtTx => write!(f, "VTTX")?,
GtPin::ClkP(idx) => write!(f, "CLKP{idx}")?,
GtPin::ClkN(idx) => write!(f, "CLKN{idx}")?,
GtPin::AVcc => write!(f, "AVCC")?,
GtPin::AVccPll(idx) => write!(f, "AVCCPLL{idx}")?,
GtPin::RRef => write!(f, "RREF")?,
GtPin::AVttRCal => write!(f, "AVTTRCAL")?,
}
}
BondPin::Nc => write!(f, "NC")?,
BondPin::Gnd => write!(f, "GND")?,
BondPin::VccInt => write!(f, "VCCINT")?,
BondPin::VccAux => write!(f, "VCCAUX")?,
BondPin::VccO(bank) => write!(f, "VCCO{bank}")?,
BondPin::VccBatt => write!(f, "VCC_BATT")?,
BondPin::Cfg(CfgPin::Done) => write!(f, "DONE")?,
BondPin::Cfg(CfgPin::ProgB) => write!(f, "PROG_B")?,
BondPin::Cfg(CfgPin::Tck) => write!(f, "TCK")?,
BondPin::Cfg(CfgPin::Tms) => write!(f, "TMS")?,
BondPin::Cfg(CfgPin::Tdi) => write!(f, "TDI")?,
BondPin::Cfg(CfgPin::Tdo) => write!(f, "TDO")?,
BondPin::Cfg(CfgPin::Suspend) => write!(f, "SUSPEND")?,
BondPin::Cfg(CfgPin::CmpCsB) => write!(f, "CMPCS_B")?,
BondPin::Vfs => write!(f, "VFS")?,
BondPin::RFuse => write!(f, "RFUSE")?,
}
writeln!(f)?;
}
writeln!(f, "\tVREF:")?;
for v in &self.vref {
writeln!(f, "\t\t{v}")?;
}
Ok(())
}
}
165 changes: 165 additions & 0 deletions prjcombine_spartan6/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,168 @@ impl Grid {
})
}
}

impl std::fmt::Display for Grid {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "\tKIND: Spartan6")?;
writeln!(f, "\tCOLS:")?;
for (col, cd) in &self.columns {
write!(f, "\t\tX{col}: ")?;
match cd.kind {
ColumnKind::Io => write!(f, "IO")?,
ColumnKind::CleXL => write!(f, "CLEXL")?,
ColumnKind::CleXM => write!(f, "CLEXM")?,
ColumnKind::CleClk => write!(f, "CLEXL+CLK")?,
ColumnKind::Bram => write!(f, "BRAM")?,
ColumnKind::Dsp => write!(f, "DSP")?,
ColumnKind::DspPlus => write!(f, "DSP*")?,
}
match cd.bio {
ColumnIoKind::None => (),
ColumnIoKind::Inner => write!(f, " BIO: I-")?,
ColumnIoKind::Outer => write!(f, " BIO: -O")?,
ColumnIoKind::Both => write!(f, " BIO: IO")?,
}
match cd.tio {
ColumnIoKind::None => (),
ColumnIoKind::Inner => write!(f, " TIO: I-")?,
ColumnIoKind::Outer => write!(f, " TIO: -O")?,
ColumnIoKind::Both => write!(f, " TIO: IO")?,
}
if let Some((cl, cr)) = self.cols_clk_fold {
if col == cl || col == cr {
write!(f, " FOLD")?;
}
}
if col == self.cols_reg_buf.0 || col == self.cols_reg_buf.1 {
write!(f, " REGBUF")?;
}
if let Gts::Single(cl) | Gts::Double(cl, _) | Gts::Quad(cl, _) = self.gts {
if col == cl {
write!(f, " LGT")?;
}
}
if let Gts::Double(_, cr) | Gts::Quad(_, cr) = self.gts {
if col == cr {
write!(f, " RGT")?;
}
}
writeln!(f,)?;
}
writeln!(f, "\tROWS:")?;
for (row, rd) in &self.rows {
if row.to_idx() != 0 && row.to_idx() % 16 == 0 {
writeln!(f, "\t\t--- clock break")?;
}
if row.to_idx() % 16 == 8 {
writeln!(f, "\t\t--- clock row")?;
}
if row == self.row_clk() {
writeln!(f, "\t\t--- spine row")?;
}
if let Some((rl, rr)) = self.rows_bank_split {
if row == rl {
writeln!(f, "\t\t--- left bank split")?;
}
if row == rr {
writeln!(f, "\t\t--- right bank split")?;
}
}
if Some(row) == self.row_mcb_split {
writeln!(f, "\t\t--- MCB split")?;
}
write!(f, "\t\tY{r}: ", r = row.to_idx())?;
if rd.lio {
write!(f, " LIO")?;
}
if rd.rio {
write!(f, " RIO")?;
}
if row == self.rows_midbuf.0 || row == self.rows_midbuf.1 {
write!(f, " MIDBUF")?;
}
if row == self.rows_hclkbuf.0 || row == self.rows_hclkbuf.1 {
write!(f, " HCLKBUF")?;
}
for (i, mcb) in self.mcbs.iter().enumerate() {
if row == mcb.row_mcb {
write!(f, " MCB{i}.MCB")?;
}
for (j, &r) in mcb.row_mui.iter().enumerate() {
if row == r {
write!(f, " MCB{i}.MUI{j}")?;
}
}
for (j, &r) in mcb.iop_dq.iter().enumerate() {
if row == r {
write!(f, " MCB{i}.DQ({jj0},{jj1})", jj0 = j * 2, jj1 = j * 2 + 1)?;
}
}
for (j, &r) in mcb.iop_dqs.iter().enumerate() {
if row == r {
write!(f, " MCB{i}.DQS{j}")?;
}
}
if row == mcb.iop_clk {
write!(f, " MCB{i}.CLK")?;
}
let mut pins: [Option<&'static str>; 2] = [None, None];
for (pin, io) in [
("DM0", mcb.io_dm[0]),
("DM1", mcb.io_dm[1]),
("A0", mcb.io_addr[0]),
("A1", mcb.io_addr[1]),
("A2", mcb.io_addr[2]),
("A3", mcb.io_addr[3]),
("A4", mcb.io_addr[4]),
("A5", mcb.io_addr[5]),
("A6", mcb.io_addr[6]),
("A7", mcb.io_addr[7]),
("A8", mcb.io_addr[8]),
("A9", mcb.io_addr[9]),
("A10", mcb.io_addr[10]),
("A11", mcb.io_addr[11]),
("A12", mcb.io_addr[12]),
("A13", mcb.io_addr[13]),
("A14", mcb.io_addr[14]),
("BA0", mcb.io_ba[0]),
("BA1", mcb.io_ba[1]),
("BA2", mcb.io_ba[2]),
("RAS", mcb.io_ras),
("CAS", mcb.io_cas),
("WE", mcb.io_we),
("ODT", mcb.io_odt),
("CKE", mcb.io_cke),
("RST", mcb.io_reset),
] {
if row == io.row {
pins[io.iob.to_idx()] = Some(pin);
}
}
if pins.iter().any(|x| x.is_some()) {
write!(
f,
" MCB{i}.({p0},{p1})",
p0 = pins[0].unwrap(),
p1 = pins[1].unwrap()
)?;
}
}
writeln!(f)?;
}
match self.gts {
Gts::None => (),
Gts::Single(..) => writeln!(f, "\tGTS: SINGLE")?,
Gts::Double(..) => writeln!(f, "\tGTS: DOUBLE")?,
Gts::Quad(..) => writeln!(f, "\tGTS: QUAD")?,
}
writeln!(f, "\tCFG PINS:")?;
for (k, v) in &self.cfg_io {
writeln!(f, "\t\t{k:?}: {v}")?;
}
if self.has_encrypt {
writeln!(f, "\tHAS ENCRYPT")?;
}
Ok(())
}
}
7 changes: 6 additions & 1 deletion prjcombine_types/src/tiledb.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use core::fmt::Debug;
use std::{collections::{btree_map, BTreeMap}, error::Error, fs::File, path::Path};
use std::{
collections::{btree_map, BTreeMap},
error::Error,
fs::File,
path::Path,
};

use bitvec::vec::BitVec;
use itertools::*;
Expand Down
1 change: 1 addition & 0 deletions prjcombine_ultrascale/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version.workspace = true
edition.workspace = true

[dependencies]
itertools.workspace = true
serde_json.workspace = true
zstd.workspace = true
bincode.workspace = true
Expand Down
Loading

0 comments on commit 489c7a5

Please sign in to comment.