pub trait SourceFile: Element {
    fn get_file_header(&self) -> String;
    fn get_file_name(&self) -> &String;

    fn write(&self) -> Result<()> { ... }
}

Required Methods§

Provided Methods§

Examples found in repository?
examples/generate_vhdl_adder.rs (line 26)
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
fn main() -> Result< (), std::io::Error > {
    let mut entity = Entity::new( "adder" );
    entity.add_library_use( LibraryUse::new( "ieee", "numeric_std" ) );
    entity.add_generic( Generic::new_with_default( "SIZE", "positive", "32" ) );
    entity.add_port( Port::new( "a", Direction::IN, "unsigned( SIZE - 1 downto 0 )" ) );
    entity.add_port( Port::new( "b", Direction::IN, "unsigned( SIZE - 1 downto 0 )" ) );
    entity.add_port( Port::new( "c", Direction::OUT, "unsigned( SIZE - 1 downto 0 )" ) );

    let mut architecture = Architecture::new( "rtl", "adder" );
    architecture.add_signal_assignment( SignalAssignment::new_with_label( "add", "c", "a + b" ));

    let mut vhdl_file = VhdlFile::new( "examples/adder.vhd" );
    vhdl_file.add_entity( entity );
    vhdl_file.add_architecture( architecture );

    vhdl_file.write()?;
    Ok(())
}

Implementors§