use kstring::KString;
use std::{
collections::HashMap,
fmt::Write,
};
pub mod fpg;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct Register {
pub addr: u32,
pub size: u32,
}
#[derive(Debug, PartialEq, Eq)]
pub struct Device {
pub kind: String,
pub register: Option<Register>,
pub metadata: HashMap<KString, String>,
}
impl Device {
fn add_meta(&mut self, k: KString, v: String) {
self.metadata.insert(k, v);
}
}
pub type Devices = HashMap<KString, Device>;
pub type Registers = HashMap<KString, Register>;
pub trait FpgaDesign {
fn bitstream(&self) -> &Vec<u8>;
fn md5(&self) -> &[u8; 16];
fn md5_string(&self) -> String {
self.md5().iter().fold(String::new(), |mut output, v| {
let _ = write!(output, "{v:x}");
output
})
}
fn devices(&self) -> &Devices;
fn registers(&self) -> &Registers;
}