1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
//! Memory.
/// Memory operation function (load or store)
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MemOpFcn {
/// Load
Load,
/// Store
Store,
}
/// Memory operation type.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MemOpTyp {
/// Byte
B = 1,
/// Half
H = 2,
/// Word
W = 3,
/// Double
D = 4,
/// Byte unsigned
BU = 5,
/// Half unsigned
HU = 6,
/// word unsigned
WU = 7,
}
/// Memory request.
#[derive(Debug, Clone, Copy)]
pub struct MemReq {
/// address
pub addr: u32,
/// data
pub data: u32,
/// Memory Function Code
pub fcn: MemOpFcn,
/// Memory Type
pub typ: MemOpTyp,
}
impl MemReq {
/// Creates a new load request.
#[inline]
pub fn load(addr: u32, typ: MemOpTyp) -> Self {
Self { addr, data: 0, fcn: MemOpFcn::Load, typ }
}
/// Creates a new store request.
#[inline]
pub fn store(addr: u32, data: u32, typ: MemOpTyp) -> Self {
Self { addr, data, fcn: MemOpFcn::Store, typ }
}
}
/// Memory Response.
#[derive(Debug, Clone, Copy)]
pub struct MemRespWithAddr {
/// data
pub data: u32,
/// address
pub addr: u32,
}