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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use crate::core::ast::{Verilog, VerilogLink};
use crate::core::timing::TimingInfo;
pub trait Logic {
fn update(&mut self);
fn connect(&mut self) {}
fn hdl(&self) -> Verilog {
Verilog::Empty
}
fn timing(&self) -> Vec<TimingInfo> {
vec![]
}
}
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) {}
}
impl<L: Logic> Logic for Vec<L> {
fn update(&mut self) {}
}
pub trait LogicLink {
fn link(&mut self, other: &mut Self);
fn link_hdl(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();
}
pub trait LogicJoin {
fn join_connect(&mut self) {}
fn join_hdl(_my_name: &str, _this: &str, _that: &str) -> Vec<VerilogLink> {
vec![]
}
}
pub fn logic_connect_join_fn<L: LogicJoin, K: LogicJoin>(source: &mut L, dest: &mut K) {
source.join_connect();
dest.join_connect();
}