endcap-sl-software-ri-gener.../src/types.rs

153 lines
3.1 KiB
Rust

//! Register type definition.
#[derive(Debug)]
pub struct Module {
pub name: String,
pub addr: u32,
pub size: u32,
pub amod: Option<AmodValues>,
pub r#type: Option<DataType>,
pub desc: Option<String>,
pub elements_bitstring: Vec<BitString>,
pub elements_other: Vec<ModuleBlockElements>,
pub xmlhash: [u8; 32],
}
#[derive(Debug)]
pub enum ModuleBlockElements {
Block(Block),
Register(Register),
Memory(Memory),
Fifo(Fifo),
}
#[derive(Debug)]
pub struct BitString {
pub name: String,
pub size: Option<u32>,
pub mask: Option<u32>,
pub modf: Option<RwSpecifier>,
pub desc: Option<String>,
pub elements_field: Vec<Field>,
}
#[derive(Debug)]
pub struct Block {
pub name: String,
/// Fill this with proper calc.
pub addr: u32,
/// Fill this with proper calc.
pub r#type: Option<DataType>,
/// Fill this with proper calc.
pub modf: Option<RwSpecifier>,
// TODO: should this be expanded?
pub multiple: Option<MultipleParams>,
// TODO
pub decoder: String,
pub size: u32,
pub desc: Option<String>,
pub elements: Vec<ModuleBlockElements>,
}
#[derive(Debug)]
pub struct Register {
pub name: String,
/// Fill this with proper calc.
pub addr: u32,
/// Fill this with proper calc.
pub r#type: DataType,
pub mask: Option<u32>,
/// Fill this with proper calc.
pub modf: RwSpecifier,
pub multiple: Option<MultipleParams>,
pub default: Option<u32>,
pub desc: Option<String>,
// BitString?
pub elements: Vec<Field>,
}
#[derive(Debug)]
pub struct Memory {
pub name: String,
/// Fill this with proper calc.
pub addr: u32,
pub mask: Option<u32>,
/// Fill this with proper calc
pub modf: RwSpecifier,
pub dma: Option<bool>,
pub multiple: Option<MultipleParams>,
// BitString?
pub desc: Option<String>,
pub elements: Vec<Field>,
}
#[derive(Debug)]
pub struct Fifo {
pub name: String,
/// Fill this with proper calc.
pub addr: u32,
pub size: u32,
pub mask: Option<u32>,
/// Fill this with proper calc.
pub modf: RwSpecifier,
pub interface: Option<FieldFifoInterface>,
pub multiple: Option<MultipleParams>,
// BitString?
pub desc: String,
pub elements: Vec<Field>,
}
#[derive(Debug)]
pub struct Field {
pub name: String,
pub mask: u32,
pub interface: Option<FieldFifoInterface>,
pub multiple: Option<MultipleParams>,
pub default: Option<u32>,
// TODO
pub sclr: Option<bool>,
pub desc: Option<String>,
pub elements: Vec<Value>,
}
#[derive(Debug)]
pub struct Value {
pub name: String,
pub data: u32,
pub desc: Option<String>,
}
#[derive(Debug, PartialEq)]
pub enum AmodValues {
A16,
A24,
A32,
CRCSR,
USER1,
USER2,
}
#[derive(Debug, Clone, Copy)]
pub enum DataType {
D32,
}
#[derive(Debug)]
pub enum RwSpecifier {
R,
W,
RW,
}
#[derive(Debug)]
pub struct MultipleParams {
pub multiple: u32,
pub offset: u32,
}
#[derive(Debug)]
pub enum FieldFifoInterface {
Vector,
Block,
Both,
}