2
// Copyright (C) 2008-2014 Centaur Technology
5
// Centaur Technology Formal Verification Group
6
// 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA.
7
// http://www.centtech.com/
9
// License: (An MIT/X11-style license)
11
// Permission is hereby granted, free of charge, to any person obtaining a
12
// copy of this software and associated documentation files (the "Software"),
13
// to deal in the Software without restriction, including without limitation
14
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
15
// and/or sell copies of the Software, and to permit persons to whom the
16
// Software is furnished to do so, subject to the following conditions:
18
// The above copyright notice and this permission notice shall be included in
19
// all copies or substantial portions of the Software.
21
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
// DEALINGS IN THE SOFTWARE.
29
// Original author: Jared Davis <jared@centtech.com>
31
// more tests of parameter handling
34
parameter integer size = 4;
35
output [size-1:0] out;
40
module MB (out, in); // Increment unsigned by integer parameter
41
parameter integer inc = 1;
44
assign out = in + inc;
47
module MC (out, in); // Increment signed by integer parameter
48
parameter integer inc = 1;
51
wire signed [3:0] sin = in;
52
assign out = sin + inc;
55
`ifdef SYSTEM_VERILOG_MODE
57
module MD (out, in); // Increment unsigned by unsigned integer parameter
58
parameter integer unsigned inc = 1;
61
assign out = in + inc;
64
module ME (out, in); // Increment signed by unsigned integer parameter
65
parameter integer unsigned inc = 1;
68
wire signed [3:0] sin = in;
69
assign out = sin + inc;
75
parameter signed inc = 1;
78
assign out = in + inc;
82
parameter signed inc = 1;
85
wire signed [3:0] sin = in;
86
assign out = sin + inc;
92
// These are the same as the corresponding modules from param/, except
93
// that I've made the parameter size smaller.
96
parameter [2:0] inc = 1;
99
assign out = in + inc;
103
parameter [2:0] inc = 1;
106
wire signed [3:0] sin = in;
107
assign out = sin + inc;
111
parameter signed [2:0] inc = 1;
114
assign out = in + inc;
118
parameter signed [2:0] inc = 1;
121
wire signed [3:0] sin = in;
122
assign out = sin + inc;
132
bout1, bout2, bout3, bout4, bout5, bout6, bout7,
133
cout1, cout2, cout3, cout4, cout5, cout6, cout7,
134
dout1, dout2, dout3, dout4, dout5, dout6, dout7,
135
eout1, eout2, eout3, eout4, eout5, eout6, eout7,
136
fout1, fout2, fout3, fout4, fout5, fout6, fout7,
137
gout1, gout2, gout3, gout4, gout5, gout6, gout7,
138
hout1, hout2, hout3, hout4, hout5, hout6, hout7,
139
iout1, iout2, iout3, iout4, iout5, iout6, iout7
145
wire [size-1:0] make_size_matter;
147
input [3:0] in1, in2;
150
output [3:0] aout1, aout2, aout3;
151
MA ainst1 (aout1, in1);
152
assign aout2[3] = in2[3];
153
MA #(.size(3)) ainst2 (aout2[2:0], in1[2:0]);
154
assign aout3[3:2] = in2[3:2];
155
MA #(2) ainst3 (aout3[1:0], in1[1:0]);
157
output [3:0] bout1, bout2, bout3, bout4, bout5, bout6, bout7;
158
MB binst1 (bout1, in1);
159
MB #(.inc(2)) binst2 (bout2, in1);
160
MB #(.inc(-1)) binst3 (bout3, in1);
161
MB #(.inc(4'd3)) binst4 (bout4, in1);
162
MB #(.inc(-4'd1)) binst5 (bout5, in1);
163
MB #(.inc(4'sd3)) binst6 (bout6, in1);
164
MB #(.inc(-4'sd1)) binst7 (bout7, in1);
166
output [3:0] cout1, cout2, cout3, cout4, cout5, cout6, cout7;
167
MC cinst1 (cout1, in1);
168
MC #(.inc(2)) cinst2 (cout2, in1);
169
MC #(.inc(-1)) cinst3 (cout3, in1);
170
MC #(.inc(4'd3)) cinst4 (cout4, in1);
171
MC #(.inc(-4'd1)) cinst5 (cout5, in1);
172
MC #(.inc(4'sd3)) cinst6 (cout6, in1);
173
MC #(.inc(-4'sd1)) cinst7 (cout7, in1);
175
output [3:0] dout1, dout2, dout3, dout4, dout5, dout6, dout7;
176
MD dinst1 (dout1, in1);
177
MD #(.inc(2)) dinst2 (dout2, in1);
178
MD #(.inc(-1)) dinst3 (dout3, in1);
179
MD #(.inc(4'd3)) dinst4 (dout4, in1);
180
MD #(.inc(-4'd1)) dinst5 (dout5, in1);
181
MD #(.inc(4'sd3)) dinst6 (dout6, in1);
182
MD #(.inc(-4'sd1)) dinst7 (dout7, in1);
184
output [3:0] eout1, eout2, eout3, eout4, eout5, eout6, eout7;
185
ME einst1 (eout1, in1);
186
ME #(.inc(2)) einst2 (eout2, in1);
187
ME #(.inc(-1)) einst3 (eout3, in1);
188
ME #(.inc(4'd3)) einst4 (eout4, in1);
189
ME #(.inc(-4'd1)) einst5 (eout5, in1);
190
ME #(.inc(4'sd3)) einst6 (eout6, in1);
191
ME #(.inc(-4'sd1)) einst7 (eout7, in1);
193
output [3:0] fout1, fout2, fout3, fout4, fout5, fout6, fout7;
194
MF finst1 (fout1, in1);
195
MF #(.inc(2)) finst2 (fout2, in1);
196
MF #(.inc(-1)) finst3 (fout3, in1);
197
MF #(.inc(4'd3)) finst4 (fout4, in1);
198
MF #(.inc(-4'd1)) finst5 (fout5, in1);
199
MF #(.inc(4'sd3)) finst6 (fout6, in1);
200
MF #(.inc(-4'sd1)) finst7 (fout7, in1);
202
output [3:0] gout1, gout2, gout3, gout4, gout5, gout6, gout7;
203
MG ginst1 (gout1, in1);
204
MG #(.inc(2)) ginst2 (gout2, in1);
205
MG #(.inc(-1)) ginst3 (gout3, in1);
206
MG #(.inc(4'd3)) ginst4 (gout4, in1);
207
MG #(.inc(-4'd1)) ginst5 (gout5, in1);
208
MG #(.inc(4'sd3)) ginst6 (gout6, in1);
209
MG #(.inc(-4'sd1)) ginst7 (gout7, in1);
211
output [3:0] hout1, hout2, hout3, hout4, hout5, hout6, hout7;
212
MH hinst1 (hout1, in1);
213
MH #(.inc(2)) hinst2 (hout2, in1);
214
MH #(.inc(-1)) hinst3 (hout3, in1);
215
MH #(.inc(4'd3)) hinst4 (hout4, in1);
216
MH #(.inc(-4'd1)) hinst5 (hout5, in1);
217
MH #(.inc(4'sd3)) hinst6 (hout6, in1);
218
MH #(.inc(-4'sd1)) hinst7 (hout7, in1);
220
output [3:0] iout1, iout2, iout3, iout4, iout5, iout6, iout7;
221
MI iinst1 (iout1, in1);
222
MI #(.inc(2)) iinst2 (iout2, in1);
223
MI #(.inc(-1)) iinst3 (iout3, in1);
224
MI #(.inc(4'd3)) iinst4 (iout4, in1);
225
MI #(.inc(-4'd1)) iinst5 (iout5, in1);
226
MI #(.inc(4'sd3)) iinst6 (iout6, in1);
227
MI #(.inc(-4'sd1)) iinst7 (iout7, in1);
234
module make_tests () ;
238
bout1, bout2, bout3, bout4, bout5, bout6, bout7,
239
cout1, cout2, cout3, cout4, cout5, cout6, cout7,
240
dout1, dout2, dout3, dout4, dout5, dout6, dout7,
241
eout1, eout2, eout3, eout4, eout5, eout6, eout7,
242
fout1, fout2, fout3, fout4, fout5, fout6, fout7,
243
gout1, gout2, gout3, gout4, gout5, gout6, gout7,
244
hout1, hout2, hout3, hout4, hout5, hout6, hout7,
245
iout1, iout2, iout3, iout4, iout5, iout6, iout7;
247
dut #(1) dir_test_1 ( in1, in2,
249
bout1, bout2, bout3, bout4, bout5, bout6, bout7,
250
cout1, cout2, cout3, cout4, cout5, cout6, cout7,
251
dout1, dout2, dout3, dout4, dout5, dout6, dout7,
252
eout1, eout2, eout3, eout4, eout5, eout6, eout7,
253
fout1, fout2, fout3, fout4, fout5, fout6, fout7,
254
gout1, gout2, gout3, gout4, gout5, gout6, gout7,
255
hout1, hout2, hout3, hout4, hout5, hout6, hout7,
256
iout1, iout2, iout3, iout4, iout5, iout6, iout7