[−][src]Struct riscy::Addr
A struct to representing an address value.
Addresses in rv32i are 32-bits wide. We usually write them out in hexadecimal.
Addr
s are used in the interface of the Memory
trait.
An Addr
is used to name the location of a specific byte in the memory space.
An important operation for operating for working with Addr
s is adding or
subtracting an offset. Several RISC-V instructions take a register together with
a small immediate value (for example, lw
, load word, and jalr
, jump-and-link return).
The value in the register becomes the base address, but the instruction then operates on
memory on a small distance away from the base address. And so, several integer types,
(including u32
, i32
, and RegVal
can be added to an Addr
.
When using offsets, the order must be: Addr + offset
.
It doesn't make sense to add an Addr
to another Addr
, so this operation is not provided.
Addr
s may be converted to RegVal
s and vice versa:
let value = RegVal::from_u32(0x2000_0000); let addr: Addr = value.into(); let new_value = (addr + 0x0a).into();
Addr
s can also be compared with <
, <=
, etc. This is useful for certain implementations of
Memory
which would like to store Addr
s in
BTreeMap
s.
While Addr
(together with the Memory
interface) give every byte
in memory a unique address, physical hardware often operates with memory on the level of words.
That is, it is common that memory might only operate on groups of four bytes. Because of this,
some operations will only work when the Addr
has a proper alignment.
No restrictions on alignment are given in this version of riscy
, but this is subject
(and likely) to change in future versions.
Implementations
impl Addr
[src]
Trait Implementations
impl Add<RegVal> for Addr
[src]
type Output = Addr
The resulting type after applying the +
operator.
pub fn add(self, offset: RegVal) -> Self
[src]
impl Add<i32> for Addr
[src]
type Output = Addr
The resulting type after applying the +
operator.
pub fn add(self, offset: i32) -> Self
[src]
impl Add<u32> for Addr
[src]
type Output = Addr
The resulting type after applying the +
operator.
pub fn add(self, offset: u32) -> Self
[src]
impl Add<usize> for Addr
[src]
type Output = Addr
The resulting type after applying the +
operator.
pub fn add(self, offset: usize) -> Self
[src]
impl AddAssign<RegVal> for Addr
[src]
pub fn add_assign(&mut self, offset: RegVal)
[src]
impl AddAssign<i32> for Addr
[src]
pub fn add_assign(&mut self, offset: i32)
[src]
impl AddAssign<u32> for Addr
[src]
pub fn add_assign(&mut self, offset: u32)
[src]
impl AddAssign<usize> for Addr
[src]
pub fn add_assign(&mut self, offset: usize)
[src]
impl Clone for Addr
[src]
impl Copy for Addr
[src]
impl Debug for Addr
[src]
impl Display for Addr
[src]
impl Eq for Addr
[src]
impl From<Addr> for u32
[src]
impl From<Addr> for usize
[src]
impl From<Addr> for RegVal
[src]
impl From<RegVal> for Addr
[src]
impl Hash for Addr
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Addr
[src]
pub fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<Addr> for Addr
[src]
impl PartialOrd<Addr> for Addr
[src]
pub fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for Addr
[src]
impl StructuralPartialEq for Addr
[src]
Auto Trait Implementations
impl RefUnwindSafe for Addr
[src]
impl Send for Addr
[src]
impl Sync for Addr
[src]
impl Unpin for Addr
[src]
impl UnwindSafe for Addr
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,