x393
1.0
FPGAcodeforElphelNC393camera
dsp_ma.v
Go to the documentation of this file.
1
39
`timescale 1ns/1ps
40
41
module
dsp_ma
#(
42
parameter
B_WIDTH
=
18
,
43
parameter
A_WIDTH
=
25
,
44
parameter
P_WIDTH
=
48
)
45
(
46
input
clk
,
47
input
rst
,
48
input
signed
[
B_WIDTH
-
1
:
0
]
bin
,
49
input
ceb1
,
// load b1 register
50
input
ceb2
,
// load b2 register
51
input
selb
,
// 0 - select b1, 1 - select b2
52
input
signed
[
A_WIDTH
-
1
:
0
]
ain
,
53
input
cea1
,
54
input
cea2
,
55
input
signed
[
A_WIDTH
-
1
:
0
]
din
,
56
input
ced
,
57
input
sela
,
// 0 - select a1, 1 - select a2
58
input
seld
,
// 0 - select a1/a2, 1 - select d
59
input
neg_m
,
// 1 - negate multiplier result
60
input
accum
,
// 0 - use multiplier result, 1 add to accumulator
61
output
signed
[
P_WIDTH
-
1
:
0
]
pout
62
);
63
`ifdef
INSTANTIATE_DSP48E1
64
wire
[
4
:
0
]
inmode
= {~
selb
,
65
1'b0
,
// sub_d,
66
seld
,
67
seld
,
// ~en_a,
68
~
sela
};
69
wire
[
3
:
0
]
alumode
= {
2'b0
,
70
neg_m
,
71
neg_m
};
72
wire
[
6
:
0
]
opmode
= {
1'b0
,
73
accum
,
74
1'b0
,
75
2'b01
,
76
2'b01
};
77
DSP48E1
#(
78
.
ACASCREG
(
1
),
79
.
ADREG
(
0
),
// (1),
80
.
ALUMODEREG
(
1
),
81
.
AREG
(
1
),
// (2), // (1) - means number in series, so "2" always reads the second
82
.
AUTORESET_PATDET
(
"NO_RESET"
),
83
.
A_INPUT
(
"DIRECT"
),
84
.
BCASCREG
(
1
),
85
.
BREG
(
1
),
// (2), // (1) - means number in series, so "2" always reads the second
86
.
B_INPUT
(
"DIRECT"
),
87
.
CARRYINREG
(
1
),
88
.
CARRYINSELREG
(
1
),
89
.
CREG
(
0
),
//(1),
90
.
DREG
(
1
),
91
.
INMODEREG
(
1
),
92
.
IS_ALUMODE_INVERTED
(
4'b0
),
93
.
IS_CARRYIN_INVERTED
(
1'b0
),
94
.
IS_CLK_INVERTED
(
1'b0
),
95
.
IS_INMODE_INVERTED
(
5'b0
),
96
.
IS_OPMODE_INVERTED
(
7'b0
),
97
.
MASK
(
48'hffffffffffff
),
98
.
MREG
(
1
),
99
.
OPMODEREG
(
1
),
100
.
PATTERN
(
48'h000000000000
),
101
.
PREG
(
1
),
102
.
SEL_MASK
(
"MASK"
),
103
.
SEL_PATTERN
(
"PATTERN"
),
104
.
USE_DPORT
(
"TRUE"
),
//("FALSE"),
105
.
USE_MULT
(
"MULTIPLY"
),
106
.
USE_PATTERN_DETECT
(
"NO_PATDET"
),
107
.
USE_SIMD
(
"ONE48"
)
108
)
DSP48E1_i
(
109
.
ACOUT
(),
// output[29:0]
110
.
BCOUT
(),
// output[17:0]
111
.
CARRYCASCOUT
(),
// output
112
.
CARRYOUT
(),
// output[3:0]
113
.
MULTSIGNOUT
(),
// output
114
.
OVERFLOW
(),
// output
115
.
P
(
pout
),
// output[47:0]
116
.
PATTERNBDETECT
(),
// output
117
.
PATTERNDETECT
(),
// output
118
.
PCOUT
(),
// output[47:0]
119
.
UNDERFLOW
(),
// output
120
.
A
({{
30
-
A_WIDTH
{
ain
[
A_WIDTH
-
1
]}},
ain
}),
// input[29:0]
121
.
ACIN
(
30'b0
),
// input[29:0]
122
.
ALUMODE
(
alumode
),
// input[3:0]
123
.
B
(
bin
),
// input[17:0]
124
.
BCIN
(
18'b0
),
// input[17:0]
125
.
C
(
48'hffffffffffff
),
// input[47:0]
126
.
CARRYCASCIN
(
1'b0
),
// input
127
.
CARRYIN
(
1'b0
),
// input
128
.
CARRYINSEL
(
3'h0
),
// input[2:0] // later modify?
129
.
CEA1
(
cea1
),
// input
130
.
CEA2
(
cea2
),
// input
131
.
CEAD
(
1'b0
),
// input
132
.
CEALUMODE
(
1'b1
),
// input
133
.
CEB1
(
ceb1
),
// input
134
.
CEB2
(
ceb2
),
// input
135
.
CEC
(
1'b0
),
// input
136
.
CECARRYIN
(
1'b0
),
// input
137
.
CECTRL
(
1'b1
),
// input
138
.
CED
(
ced
),
// input
139
.
CEINMODE
(
1'b1
),
// input
140
.
CEM
(
1'b1
),
// input
141
.
CEP
(
1'b1
),
// input
142
.
CLK
(
clk
),
// input
143
.
D
(
din
),
// input[24:0]
144
.
INMODE
(
inmode
),
// input[4:0]
145
.
MULTSIGNIN
(
1'b0
),
// input
146
.
OPMODE
(
opmode
),
// input[6:0]
147
.
PCIN
(
48'b0
),
// input[47:0]
148
.
RSTA
(
rst
),
// input
149
.
RSTALLCARRYIN
(
rst
),
// input
150
.
RSTALUMODE
(
rst
),
// input
151
.
RSTB
(
rst
),
// input
152
.
RSTC
(
rst
),
// input
153
.
RSTCTRL
(
rst
),
// input
154
.
RSTD
(
rst
),
// input
155
.
RSTINMODE
(
rst
),
// input
156
.
RSTM
(
rst
),
// input
157
.
RSTP
(
rst
)
// input
158
);
159
`else
160
// Will try to make it infer DSP48e1
161
reg
signed
[B_WIDTH-1:0]
b1_reg;
162
reg
signed
[B_WIDTH-1:0]
b2_reg;
163
reg
signed
[A_WIDTH-1:0]
a1_reg;
164
reg
signed
[A_WIDTH-1:0]
a2_reg;
165
reg
signed
[A_WIDTH-1:0]
d_reg;
166
reg
signed
[P_WIDTH-1:0]
m_reg;
167
reg
signed
[P_WIDTH-1:0]
p_reg;
168
wire
signed
[A_WIDTH+B_WIDTH-1:0]
m_wire;
169
wire
signed
[B_WIDTH-1:0]
b_wire;
170
wire
signed
[A_WIDTH-1:0]
a_wire;
171
reg
selb_r;
172
reg
sela_r;
173
reg
seld_r;
174
reg
neg_m_r;
175
reg
accum_r;
176
177
wire
signed
[P_WIDTH-1:0]
m_reg_pm;
178
wire
signed
[P_WIDTH-1:0]
p_reg_cond;
179
180
181
assign
pout
=
p_reg;
182
assign
b_wire
=
selb_r
?
b2_reg
:
b1_reg;
183
assign
a_wire
=
seld_r
?
d_reg
:
(sela_r
?
a2_reg
:
a1_reg);
184
assign
m_wire
=
a_wire
*
b_wire;
185
186
assign
m_reg_pm
=
neg_m_r
?
-
m_reg
:
m_reg;
187
assign
p_reg_cond
=
accum_r
?
p_reg
:
0;
188
189
always
@
(posedge
clk)
begin
190
if
(rst)
b1_reg
<=
0;
191
else
if
(ceb1)
b1_reg
<=
bin;
192
193
if
(rst)
b2_reg
<=
0;
194
else
if
(ceb2)
b2_reg
<=
bin;
195
196
if
(rst)
a1_reg
<=
0;
197
else
if
(cea1)
a1_reg
<=
ain;
198
199
if
(rst)
a2_reg
<=
0;
200
else
if
(cea2)
a2_reg
<=
ain;
201
202
if
(rst)
d_reg
<=
0;
203
else
if
(ced)
d_reg
<=
din;
204
205
selb_r
<=
selb;
206
sela_r
<=
sela;
207
seld_r
<=
seld;
208
neg_m_r
<=
neg_m;
209
accum_r
<=
accum;
210
211
m_reg
<=
{{P_WIDTH
-
A_WIDTH
-
B_WIDTH{1'b0}},
m_wire};
212
213
p_reg
<=
p_reg_cond
+
m_reg_pm;
214
215
end
216
`endif
217
endmodule
218
219
dsp_ma.3375inmode
3375inmodewire[4:0]
Definition:
dsp_ma.v:64
dsp_ma.3362ceb1
3362ceb1
Definition:
dsp_ma.v:49
dsp_ma.3372neg_m
3372neg_m
Definition:
dsp_ma.v:59
dsp_ma.3368din
signed [A_WIDTH-1:0] 3368din
Definition:
dsp_ma.v:55
dsp_ma.3366cea1
3366cea1
Definition:
dsp_ma.v:53
dsp_ma.3367cea2
3367cea2
Definition:
dsp_ma.v:54
dsp_ma
Definition:
dsp_ma.v:41
dsp_ma.3360rst
3360rst
Definition:
dsp_ma.v:47
dsp_ma.3376alumode
3376alumodewire[3:0]
Definition:
dsp_ma.v:69
dsp_ma.3370sela
3370sela
Definition:
dsp_ma.v:57
dsp_ma.3361bin
signed [B_WIDTH-1:0] 3361bin
Definition:
dsp_ma.v:48
dsp_ma.3365ain
signed [A_WIDTH-1:0] 3365ain
Definition:
dsp_ma.v:52
dsp_ma.3358P_WIDTH
3358P_WIDTH48
Definition:
dsp_ma.v:44
dsp_ma.3359clk
3359clk
Definition:
dsp_ma.v:46
dsp_ma.3356B_WIDTH
3356B_WIDTH18
Definition:
dsp_ma.v:42
dsp_ma.3357A_WIDTH
3357A_WIDTH25
Definition:
dsp_ma.v:43
dsp_ma.3371seld
3371seld
Definition:
dsp_ma.v:58
dsp_ma.3364selb
3364selb
Definition:
dsp_ma.v:51
dsp_ma.DSP48E1
DSP48E1_i DSP48E1
Definition:
dsp_ma.v:77
dsp_ma.3374pout
signed [P_WIDTH-1:0] 3374pout
Definition:
dsp_ma.v:61
dsp_ma.3363ceb2
3363ceb2
Definition:
dsp_ma.v:50
dsp_ma.3369ced
3369ced
Definition:
dsp_ma.v:56
dsp_ma.3373accum
3373accum
Definition:
dsp_ma.v:60
dsp_ma.3377opmode
3377opmodewire[6:0]
Definition:
dsp_ma.v:72
dsp
dsp_ma.v
Generated by
1.8.12