-
Notifications
You must be signed in to change notification settings - Fork 4
/
rs-dsp-macc.pmg
62 lines (51 loc) · 1.55 KB
/
rs-dsp-macc.pmg
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
pattern rs_dsp_macc
state <IdString> add_ba
state <IdString> mux_ba
state <int> mul_nusers
state <int> add_nusers
state <int> mux_nusers
state <int> ff_d_nusers
state <int> ff_q_nusers
match mul
select mul->type.in($mul)
select nusers(port(mul, \Y)) <= 3
set mul_nusers nusers(port(mul, \Y))
endmatch
match neg
select neg->type.in($neg)
index <SigSpec> port(neg, \A) === port(mul, \Y)
optional
endmatch
match mux
select mux->type.in($mux)
choice <IdString> AB {\A, \B}
define <IdString> BA (AB == \A ? \B : \A)
index <SigSpec> port(mux, AB) === port(mul, \Y)
if (neg != nullptr)
index <SigSpec> port(mux, BA) === port(neg, \Y)
select nusers(port(mux, \Y)) <= 3
set mux_nusers nusers(port(mux, \Y))
set mux_ba BA
optional
endmatch
match add
select add->type.in($add, $sub)
choice <IdString> AB {\A, \B}
define <IdString> BA (AB == \A ? \B : \A)
index <SigSpec> port(add, AB) === (neg == nullptr?port(mul,\Y):mux == nullptr?port(mul,\Y):port(mux, \Y))
if (neg == nullptr)
index <SigSpec> port(add, \Y) === port(mux,mux_ba)
select nusers(port(add, \Y)) <= 3
set add_nusers nusers(port(add, \Y))
set add_ba BA
endmatch
match ff
select ff->type.in($dff, $sdff, $adff, $dffe, $adffe)
index <SigSpec> port(ff, \D) === (neg == nullptr?mux ==nullptr?port(add,\Y): port(mux, \Y):port(add,\Y))
index <SigSpec> port(ff, \Q) === port(add, add_ba)
set ff_d_nusers nusers(port(ff, \D))
set ff_q_nusers nusers(port(ff, \Q))
endmatch
code
accept;
endcode