[−][src]Struct kaze::Module
A self-contained and potentially-reusable hardware design unit, created by the Context::module method.
Once a Module is specified, it can be instantiated in another Module to form a hierarchy, or it can be used to generate Rust simulator code or a Verilog module.
All Modules in kaze have an implicit reset and clock. These are only visible in generated code. It's assumed that all kaze modules operate in the same clock domain.
Examples
use kaze::*; let c = Context::new(); let m = c.module("MyModule"); m.output("out", m.input("in", 1));
Implementations
impl<'a> Module<'a>[src]
pub fn lit<C: Into<Constant>>(&'a self, value: C, bit_width: u32) -> &Signal<'a>[src]
Creates a Signal that represents the constant literal specified by value with bit_width bits.
The bit width of the type provided by value doesn't need to match bit_width, but the value represented by value must fit into bit_width bits.
Panics
Panics if bit_width is less than MIN_SIGNAL_BIT_WIDTH or greater than MAX_SIGNAL_BIT_WIDTH, respectively, or if the specified value doesn't fit into bit_width bits.
Examples
use kaze::*; let c = Context::new(); let m = c.module("MyModule"); let eight_bit_const = m.lit(0xffu32, 8); let one_bit_const = m.lit(0u32, 1); let twenty_seven_bit_const = m.lit(true, 27);
pub fn low(&'a self) -> &Signal<'a>[src]
Convenience method to create a Signal that represents a single 0 bit.
Examples
use kaze::*; let c = Context::new(); let m = c.module("MyModule"); // The following two signals are semantically equivalent: let low1 = m.low(); let low2 = m.lit(false, 1);
pub fn high(&'a self) -> &Signal<'a>[src]
Convenience method to create a Signal that represents a single 1 bit.
Examples
use kaze::*; let c = Context::new(); let m = c.module("MyModule"); // The following two signals are semantically equivalent: let high1 = m.high(); let high2 = m.lit(true, 1);
pub fn input<S: Into<String>>(&'a self, name: S, bit_width: u32) -> &Signal<'a>[src]
Creates an input for this Module called name with bit_width bits, and returns a Signal that represents the value of this input.
Panics
Panics if bit_width is less than MIN_SIGNAL_BIT_WIDTH or greater than MAX_SIGNAL_BIT_WIDTH, respectively.
Examples
use kaze::*; let c = Context::new(); let m = c.module("MyModule"); let my_input = m.input("my_input", 80);
pub fn output<S: Into<String>>(&'a self, name: S, source: &'a Signal<'a>)[src]
Creates an output for this Module called name with the same number of bits as source, and drives this output with source.
Panics
Panics of source doesn't belong to this Module.
Examples
use kaze::*; let c = Context::new(); let m = c.module("MyModule"); let some_signal = m.high(); m.output("my_output", some_signal);
pub fn reg<S: Into<String>>(&'a self, name: S, bit_width: u32) -> &Register<'a>[src]
Creates a Register in this Module called name with bit_width bits.
Panics
Panics if bit_width is less than MIN_SIGNAL_BIT_WIDTH or greater than MAX_SIGNAL_BIT_WIDTH, respectively.
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 mux(
&'a self,
cond: &'a Signal<'a>,
when_true: &'a Signal<'a>,
when_false: &'a Signal<'a>
) -> &Signal<'a>[src]
&'a self,
cond: &'a Signal<'a>,
when_true: &'a Signal<'a>,
when_false: &'a Signal<'a>
) -> &Signal<'a>
Creates a 2:1 multiplexer that represents when_true's value when cond is high, and when_false's value when cond is low.
Panics
Panics if cond, when_true, or when_false belong to a different Module than self, if cond's bit width is not 1, or if the bit widths of when_true and when_false aren't equal.
Examples
use kaze::*; let c = Context::new(); let m = c.module("MyModule"); let cond = m.input("cond", 1); let a = m.input("a", 8); let b = m.input("b", 8); m.output("my_output", m.mux(cond, a, b)); // Outputs a when cond is high, b otherwise
pub fn instance<S: Into<String>>(
&'a self,
instance_name: S,
module_name: &str
) -> &Instance<'a>[src]
&'a self,
instance_name: S,
module_name: &str
) -> &Instance<'a>
Creates an Instance called instance_name of the Module identified by module_name in this Context inside this Module definition.
Panics
Panics if a Module identified by module_name doesn't exist in this Context.
Examples
use kaze::*; let c = Context::new(); // Inner module (simple pass-through) let inner = c.module("Inner"); inner.output("o", inner.input("i", 32)); // Outer module (wraps a single `inner` instance) let outer = c.module("Outer"); let inner_inst = outer.instance("inner_inst", "Inner"); inner_inst.drive_input("i", outer.input("i", 32)); outer.output("o", inner_inst.output("o"));
pub fn mem<S: Into<String>>(
&'a self,
name: S,
address_bit_width: u32,
element_bit_width: u32
) -> &Mem<'a>[src]
&'a self,
name: S,
address_bit_width: u32,
element_bit_width: u32
) -> &Mem<'a>
Creates a Mem in this Module called name with address_bit_width address bits and element_bit_width element bits.
The size of this memory will be 1 << address_bit_width elements, each element_bit_width bits wide.
Panics
Panics if address_bit_width or element_bit_width is less than MIN_SIGNAL_BIT_WIDTH or greater than MAX_SIGNAL_BIT_WIDTH, respectively.
Examples
use kaze::*; let c = Context::new(); let m = c.module("MyModule"); let my_mem = m.mem("my_mem", 1, 32); // Optional, unless no write port is specified my_mem.initial_contents(&[0xfadebabeu32, 0xdeadbeefu32]); // Optional, unless no initial contents are specified my_mem.write_port(m.high(), m.lit(0xabad1deau32, 32), m.high()); m.output("my_output", my_mem.read_port(m.high(), m.high()));
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Module<'a>[src]
impl<'a> !Send for Module<'a>[src]
impl<'a> !Sync for Module<'a>[src]
impl<'a> Unpin for Module<'a>[src]
impl<'a> !UnwindSafe for Module<'a>[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, 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>,