Struct source_generator::vhdl::port::Port
source · pub struct Port { /* private fields */ }Implementations§
source§impl Port
impl Port
sourcepub fn new(name: &str, direction: Direction, data_type: &str) -> Port
pub fn new(name: &str, direction: Direction, data_type: &str) -> Port
Examples found in repository?
examples/generate_vhdl_adder.rs (line 15)
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(())
}