[−][src]Struct kaze::Register
A hardware register, created by the Module
::reg
method.
A Register
is a stateful component that behaves like a D flip-flop (more precisely as a positive-edge-triggered D flip-flop).
It always has a current value represented by the value
field (often referred to as Q
) and a next value specified by the drive_next
method (often referred to as D
).
It will hold its value
until a positive edge of its Module
's implicit clock occurs, at which point value
will be updated to reflect the next value.
Optionally, it also has a default value specified by the default_value
method. If at any time its Module
's implicit reset is driven low, the register's value
will reflect the default value.
Default values are used to provide a known register state on system power-on and reset, but are often omitted to reduce combinational logic (which ultimately is how default values are typically implemented), especially for registers on timing-critical data paths.
Examples
use kaze::*; let c = Context::new(); let m = c.module("MyModule"); let my_reg = m.reg("my_reg", 32); my_reg.default_value(0xfadebabeu32); // Optional my_reg.drive_next(!my_reg.value); m.output("my_output", my_reg.value);
Fields
value: &'a Signal<'a>
This Register
's current value.
Methods
impl<'a> Register<'a>
[src]
pub fn default_value<C: Into<Constant>>(&'a self, value: C)
[src]
Specifies the default value for this Register
.
This Register
's value
will reflect this default value when this Register
's Module
's implicit reset is asserted.
By default, a Register
does not have a default value, and it is not required to specify one. If a default value is not specified, then this Register
's value
will not change when its Module
's implicit reset is asserted.
Panics
Panics if this Register
already has a default value specified, or if the specified value
doesn't fit into this Register
's bit width.
Examples
use kaze::*; let c = Context::new(); let m = c.module("MyModule"); let my_reg = m.reg("my_reg", 32); my_reg.default_value(0xfadebabeu32); // Optional my_reg.drive_next(!my_reg.value); m.output("my_output", my_reg.value);
pub fn drive_next(&'a self, n: &'a Signal<'a>)
[src]
Specifies the next value for this Register
.
A Register
will hold its value
until a positive edge of its Module
's implicit clock occurs, at which point value
will be updated to reflect this next value.
Panics
Panics if self
and n
belong to different Module
s, if the bit widths of self
and n
aren't equal, or if this Register
's next value is already driven.
Examples
use kaze::*; let c = Context::new(); let m = c.module("MyModule"); let my_reg = m.reg("my_reg", 32); my_reg.default_value(0xfadebabeu32); // Optional my_reg.drive_next(!my_reg.value); // my_reg's value will toggle with each positive clock edge m.output("my_output", my_reg.value);
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Register<'a>
impl<'a> !Send for Register<'a>
impl<'a> !Sync for Register<'a>
impl<'a> Unpin for Register<'a>
impl<'a> !UnwindSafe for Register<'a>
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,
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, 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.
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>,