1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use rust_hdl::core::prelude::*;

#[derive(Clone, Debug, LogicBlock, Default)]
pub struct OutputBuffer {
    pub i: Signal<In, Bit>,
    pub o: Signal<Out, Bit>,
}

impl Logic for OutputBuffer {
    fn update(&mut self) {
        self.o.next = self.i.val();
    }
    fn connect(&mut self) {
        self.o.connect();
    }
    fn hdl(&self) -> Verilog {
        Verilog::Wrapper(Wrapper {
            code: r##"
OB inst_OB(.I(i), .O(o));
            "##
            .into(),
            cores: r##"
(* blackbox *)
module OB(input I, output O);
endmodule
            "##
            .into(),
        })
    }
}

#[test]
fn test_output_buffer_synthesizes() {
    let mut uut = OutputBuffer::default();
    uut.connect_all();
    yosys_validate("obuf", &generate_verilog(&uut)).unwrap();
}