calyx_ir

Enum Guard

Source
pub enum Guard<T> {
    Or(Box<Guard<T>>, Box<Guard<T>>),
    And(Box<Guard<T>>, Box<Guard<T>>),
    Not(Box<Guard<T>>),
    True,
    CompOp(PortComp, RRC<Port>, RRC<Port>),
    Port(RRC<Port>),
    Info(T),
}
Expand description

An assignment guard which has pointers to the various ports from which it reads.

Variants§

§

Or(Box<Guard<T>>, Box<Guard<T>>)

Represents c1 || c2.

§

And(Box<Guard<T>>, Box<Guard<T>>)

Represents c1 && c2.

§

Not(Box<Guard<T>>)

Represents !c1

§

True

The constant true

§

CompOp(PortComp, RRC<Port>, RRC<Port>)

Comparison operator.

§

Port(RRC<Port>)

Uses the value on a port as the condition. Same as p1 == true

§

Info(T)

Other types of information.

Implementations§

Source§

impl<T> Guard<T>

Source

pub fn is_true(&self) -> bool

Returns true definitely Guard::True. Returning false does not mean that the guard is not true.

Source

pub fn is_false(&self) -> bool

Checks if the guard is always false. Returning false does not mean that the guard is not false.

Source

pub fn is_not_done(&self, cell_name: &Id) -> bool

returns true if the self is !cell_name, false otherwise.

Source

pub fn update<F>(&mut self, upd: F)
where F: FnOnce(Guard<T>) -> Guard<T>,

Update the guard in place. Replaces this guard with upd(self). Uses std::mem::take for the in-place update.

Source

pub fn op_str(&self) -> String

Return the string corresponding to the guard operation.

Source

pub fn port(p: RRC<Port>) -> Self

Source

pub fn and(self, rhs: Guard<T>) -> Self
where T: Eq,

Source

pub fn or(self, rhs: Guard<T>) -> Self
where T: Eq,

Source

pub fn eq(self, other: Guard<T>) -> Self
where T: Debug + Eq + ToString,

Source

pub fn neq(self, other: Guard<T>) -> Self
where T: Debug + Eq + ToString,

Source

pub fn le(self, other: Guard<T>) -> Self
where T: Debug + Eq + ToString,

Source

pub fn lt(self, other: Guard<T>) -> Self
where T: Debug + Eq + ToString,

Source

pub fn ge(self, other: Guard<T>) -> Self
where T: Debug + Eq + ToString,

Source

pub fn gt(self, other: Guard<T>) -> Self
where T: Debug + Eq + ToString,

Source

pub fn all_ports(&self) -> Vec<RRC<Port>>

Returns all the ports used by this guard.

Source§

impl<T> Guard<T>

Helper functions for the guard.

Source

pub fn for_each<F>(&mut self, f: &mut F)
where F: FnMut(RRC<Port>) -> Option<Guard<T>>,

Mutates a guard by calling f on every leaf in the guard tree and replacing the leaf with the guard that f returns.

Source

pub fn for_each_info<F>(&mut self, f: &mut F)
where F: FnMut(&mut T) -> Option<Guard<T>>,

runs f(info) on each Guard::Info in guard. if f(info) = Some(result)replaces interval with result. iff(info) = None does nothing.

Source

pub fn check_for_each_info<F>(&self, f: &mut F) -> Result<(), Error>
where F: Fn(&T) -> Result<(), Error>,

runs f(info) on each info in guard. f should return Result<(), Error>, meaning that it essentially does nothing if the f returns OK(()), but returns an appropraite error otherwise

Source§

impl Guard<StaticTiming>

Source

pub fn add_interval(&mut self, timing_interval: StaticTiming)

updates self -> self & interval

Trait Implementations§

Source§

impl<T> BitAnd for Guard<T>
where T: Eq,

Construct a Guard::And:

let and_guard = g1 & g2;
Source§

type Output = Guard<T>

The resulting type after applying the & operator.
Source§

fn bitand(self, other: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl<T> BitAndAssign for Guard<T>
where T: Eq,

Update a Guard with Or.

g1 &= g2;
Source§

fn bitand_assign(&mut self, other: Self)

Performs the &= operation. Read more
Source§

impl<T> BitOr for Guard<T>
where T: Eq,

Construct a Guard::Or:

let or_guard = g1 | g2;
Source§

type Output = Guard<T>

The resulting type after applying the | operator.
Source§

fn bitor(self, other: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl<T> BitOrAssign for Guard<T>
where T: Eq,

Update a Guard with Or.

g1 |= g2;
Source§

fn bitor_assign(&mut self, other: Self)

Performs the |= operation. Read more
Source§

impl<T: Clone> Clone for Guard<T>

Source§

fn clone(&self) -> Guard<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Guard<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Guard<T>

Source§

fn default() -> Guard<T>

Returns the “default value” for a type. Read more
Source§

impl From<Guard<Nothing>> for Guard<StaticTiming>

Source§

fn from(g: Guard<Nothing>) -> Self

Turns a normal guard into a static guard

Source§

impl<T> From<Rc<RefCell<Port>>> for Guard<T>

Construct guards from ports

Source§

fn from(port: RRC<Port>) -> Self

Converts to this type from the input type.
Source§

impl<T> Hash for Guard<T>
where T: ToString,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> Not for Guard<T>

Construct a Guard::Or:

let not_guard = !g1;
Source§

type Output = Guard<T>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self

Performs the unary ! operation. Read more
Source§

impl<T> Ord for Guard<T>
where T: Eq,

Define an ordering on the precedence of guards. Guards are considered equal when they have the same precedence.

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T> PartialEq for Guard<T>
where T: Eq,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> PartialOrd for Guard<T>
where T: Eq,

Define order on guards

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> Eq for Guard<T>
where T: Eq,

Auto Trait Implementations§

§

impl<T> Freeze for Guard<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for Guard<T>

§

impl<T> !Send for Guard<T>

§

impl<T> !Sync for Guard<T>

§

impl<T> Unpin for Guard<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Guard<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for T
where T: Hash + ?Sized,

§

fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.