-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
122 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use std::{error::Error, path::PathBuf}; | ||
|
||
use clap::Parser; | ||
use prjcombine_xilinx_recpld::fuzzdb::FuzzDb; | ||
|
||
#[derive(Parser)] | ||
struct Args { | ||
fdb: PathBuf, | ||
} | ||
|
||
pub fn main() -> Result<(), Box<dyn Error>> { | ||
let args = Args::parse(); | ||
let db = FuzzDb::from_file(args.fdb)?; | ||
for part in db.parts { | ||
println!("DEV {d} {p}", d = part.dev_name, p = part.pkg_name); | ||
part.bits.print(&mut std::io::stdout())?; | ||
let known_bits = part.bits.known_bits(); | ||
println!("BS LEN {}", part.map.main.len()); | ||
for (i, b) in part.blank.iter().enumerate() { | ||
let (r, c) = part.map.main[i]; | ||
if let Some(s) = known_bits.get(&i) { | ||
println!("BIT L{i} ({r}, {c}): {s}"); | ||
} else { | ||
println!("BIT L{i} ({r}, {c}): UNK{v}", v = if *b { 1 } else { 0 }); | ||
} | ||
} | ||
if let Some(uc) = part.map.usercode { | ||
for (i, (r, c)) in uc.into_iter().enumerate() { | ||
println!(" USERCODE {i} -> ({r}, {c})"); | ||
} | ||
} | ||
if let Some(uc) = part.map.ues { | ||
for (i, (r, c)) in uc.into_iter().enumerate() { | ||
println!(" UES {i} -> ({r}, {c})"); | ||
} | ||
} | ||
if let Some((r, c)) = part.map.done { | ||
println!(" DONE -> ({r}, {c})"); | ||
} | ||
|
||
for (r, c) in part.map.rprot { | ||
println!(" READ PROT -> ({r}, {c})"); | ||
} | ||
for (r, c) in part.map.wprot { | ||
println!(" WRITE PROT -> ({r}, {c})"); | ||
} | ||
|
||
if let Some((c, r, a)) = part.map.dims { | ||
println!(" DIMS {c}×{r}, {a}"); | ||
} | ||
for x in part.map.transfer { | ||
println!(" TRANSFER {x}"); | ||
} | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use std::{error::Error, fs::File, path::Path}; | ||
|
||
use bitvec::vec::BitVec; | ||
use prjcombine_xilinx_cpld::bits::{Bits, BitstreamMap}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] | ||
pub struct FuzzDbPart { | ||
pub dev_name: String, | ||
pub pkg_name: String, | ||
pub bits: Bits, | ||
pub map: BitstreamMap, | ||
pub blank: BitVec, | ||
} | ||
|
||
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] | ||
pub struct FuzzDb { | ||
pub parts: Vec<FuzzDbPart>, | ||
} | ||
|
||
impl FuzzDb { | ||
pub fn to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), Box<dyn Error>> { | ||
let f = File::create(path)?; | ||
let mut cf = zstd::stream::Encoder::new(f, 9)?; | ||
bincode::serialize_into(&mut cf, self)?; | ||
cf.finish()?; | ||
Ok(()) | ||
} | ||
|
||
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn Error>> { | ||
let f = File::open(path)?; | ||
let cf = zstd::stream::Decoder::new(f)?; | ||
Ok(bincode::deserialize_from(cf)?) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod bitstream; | ||
pub mod db; | ||
pub mod fuzzdb; | ||
pub mod hprep6; | ||
pub mod impact; | ||
pub mod partgen; | ||
|