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
38
39
40
41
42
43
44
45
46
47
48
use crate::ast::{Verilog, VerilogLink};
pub trait Logic {
fn update(&mut self);
fn connect(&mut self) {}
fn hdl(&self) -> Verilog {
Verilog::Empty
}
}
pub fn logic_connect_fn<L: Logic>(x: &mut L) {
x.connect();
}
impl<L: Logic, const P: usize> Logic for [L; P] {
fn update(&mut self) {}
}
pub trait LogicLink {
fn link(&mut self, other: &mut Self);
fn link_hdl(&self, my_name: &str, this: &str, that: &str) -> Vec<VerilogLink>;
fn link_connect_source(&mut self);
fn link_connect_dest(&mut self);
}
pub fn logic_connect_link_fn<L: LogicLink>(source: &mut L, dest: &mut L) {
source.link_connect_source();
dest.link_connect_dest();
}