-
Notifications
You must be signed in to change notification settings - Fork 48
/
ql-dsp-macc.pmg
50 lines (43 loc) · 1.23 KB
/
ql-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
pattern ql_dsp_macc
state <IdString> add_ba
state <IdString> mux_ab
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 add
select add->type.in($add, $sub)
choice <IdString> AB {\A, \B}
define <IdString> BA (AB == \A ? \B : \A)
index <SigSpec> port(add, AB) === port(mul, \Y)
select nusers(port(add, \Y)) <= 3
set add_nusers nusers(port(add, \Y))
set add_ba BA
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)
index <SigSpec> port(mux, BA) === port(add, \Y)
select nusers(port(mux, \Y)) <= 3
set mux_nusers nusers(port(mux, \Y))
set mux_ab AB
optional
endmatch
match ff
select ff->type.in($dff, $adff, $dffe, $adffe)
index <SigSpec> port(ff, \D) === (mux == nullptr ? port(add, \Y) : port(mux, \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