~ubuntu-branches/ubuntu/wily/acl2/wily

« back to all changes in this revision

Viewing changes to books/centaur/vl/systest/param5/spec.v

  • Committer: Package Import Robot
  • Author(s): Camm Maguire
  • Date: 2015-01-16 10:35:45 UTC
  • mfrom: (3.3.26 sid)
  • Revision ID: package-import@ubuntu.com-20150116103545-prehe9thgo79o8w8
Tags: 7.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// VL Verilog Toolkit
 
2
// Copyright (C) 2008-2014 Centaur Technology
 
3
//
 
4
// Contact:
 
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/
 
8
//
 
9
// License: (An MIT/X11-style license)
 
10
//
 
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:
 
17
//
 
18
//   The above copyright notice and this permission notice shall be included in
 
19
//   all copies or substantial portions of the Software.
 
20
//
 
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.
 
28
//
 
29
// Original author: Jared Davis <jared@centtech.com>
 
30
 
 
31
// similar to param, but using the alternate #(parameter ...) syntax which is
 
32
// supported in both Verilog and SystemVerilog.
 
33
 
 
34
`ifdef SYSTEM_VERILOG_MODE
 
35
 
 
36
module MA #(size = 4) (out, in);     // Extremely basic parameterized module
 
37
  output [size-1:0] out;
 
38
  input [size-1:0]  in;
 
39
  assign out = ~in;
 
40
endmodule
 
41
 
 
42
module MB #(inc = 1) (out, in);     // Increment unsigned by plain parameter
 
43
  output [3:0] out;
 
44
  input  [3:0] in;
 
45
  assign out = in + inc;
 
46
endmodule
 
47
 
 
48
module MC #(inc = 1, inc2 = inc + 1) (out, in);     // Increment signed by plain parameter
 
49
  output [3:0] out;
 
50
  input  [3:0] in;
 
51
  wire signed [3:0] sin = in;
 
52
  assign out = sin + inc2;
 
53
endmodule
 
54
 
 
55
module MD #(logic signed inc = 1) (out, in);     // Increment unsigned by signed parameter
 
56
  output [3:0] out;
 
57
  input  [3:0] in;
 
58
  assign out = in + inc;
 
59
endmodule
 
60
 
 
61
module ME #(logic signed inc = 1) (out, in);     // Increment signed by signed parameter
 
62
  output [3:0] out;
 
63
  input  [3:0] in;
 
64
  wire signed [3:0] sin = in;
 
65
  assign out = sin + inc;
 
66
endmodule
 
67
 
 
68
module MF #(logic [3:0] inc = 1) (out, in);     // Increment unsigned by ranged parameter
 
69
  output [3:0] out;
 
70
  input  [3:0] in;
 
71
  assign out = in + inc;
 
72
endmodule
 
73
 
 
74
module MG #(logic [3:0] inc = 1,
 
75
            parameter [3:0] inc2 = inc + 1)
 
76
  (out, in);     // Increment signed by ranged parameter
 
77
  output [3:0] out;
 
78
  input  [3:0] in;
 
79
  wire signed [3:0] sin = in;
 
80
  assign out = sin + inc2;
 
81
endmodule
 
82
 
 
83
module MH #(logic signed [3:0] inc = 1) (out, in);     // Increment unsigned by signed, ranged parameter
 
84
  output [3:0] out;
 
85
  input  [3:0] in;
 
86
  localparam signed [3:0] inc2 = inc + 1;
 
87
  assign out = in + inc2;
 
88
endmodule
 
89
 
 
90
module MI #(logic signed [3:0] inc = 1,
 
91
            parameter signed [3:0] inc2 = inc + 1)
 
92
  (out, in);     // Increment signed by signed, ranged parameter
 
93
  output [3:0] out;
 
94
  input  [3:0] in;
 
95
  wire signed [3:0] sin = in;
 
96
  assign out = sin + inc2;
 
97
endmodule
 
98
 
 
99
 
 
100
 
 
101
module dut (
 
102
 
 
103
in1, in2,
 
104
 
 
105
aout1, aout2, aout3,
 
106
bout1, bout2, bout3, bout4, bout5, bout6, bout7,
 
107
cout1, cout2, cout3, cout4, cout5, cout6, cout7,
 
108
dout1, dout2, dout3, dout4, dout5, dout6, dout7,
 
109
eout1, eout2, eout3, eout4, eout5, eout6, eout7,
 
110
fout1, fout2, fout3, fout4, fout5, fout6, fout7,
 
111
gout1, gout2, gout3, gout4, gout5, gout6, gout7,
 
112
hout1, hout2, hout3, hout4, hout5, hout6, hout7,
 
113
iout1, iout2, iout3, iout4, iout5, iout6, iout7
 
114
 
 
115
 
 
116
);
 
117
 
 
118
  parameter size = 1;
 
119
  wire [size-1:0] make_size_matter;
 
120
 
 
121
  input [3:0]      in1, in2;
 
122
 
 
123
 
 
124
  output [3:0]     aout1, aout2, aout3;
 
125
  MA ainst1 (aout1, in1);
 
126
  assign aout2[3] = in2[3];
 
127
  MA #(.size(3)) ainst2 (aout2[2:0], in1[2:0]);
 
128
  assign aout3[3:2] = in2[3:2];
 
129
  MA #(2) ainst3 (aout3[1:0], in1[1:0]);
 
130
 
 
131
  output [3:0]     bout1, bout2, bout3, bout4, bout5, bout6, bout7;
 
132
  MB binst1 (bout1, in1);
 
133
  MB #(.inc(2)) binst2 (bout2, in1);
 
134
  MB #(.inc(-1)) binst3 (bout3, in1);
 
135
  MB #(.inc(4'd3)) binst4 (bout4, in1);
 
136
  MB #(.inc(-4'd1)) binst5 (bout5, in1);
 
137
  MB #(.inc(4'sd3)) binst6 (bout6, in1);
 
138
  MB #(.inc(-4'sd1)) binst7 (bout7, in1);
 
139
 
 
140
  output [3:0]     cout1, cout2, cout3, cout4, cout5, cout6, cout7;
 
141
  MC cinst1 (cout1, in1);
 
142
  MC #(.inc(2)) cinst2 (cout2, in1);
 
143
  MC #(.inc(-1)) cinst3 (cout3, in1);
 
144
  MC #(.inc(4'd3)) cinst4 (cout4, in1);
 
145
  MC #(.inc(-4'd1)) cinst5 (cout5, in1);
 
146
  MC #(.inc(4'sd3)) cinst6 (cout6, in1);
 
147
  MC #(.inc(-4'sd1)) cinst7 (cout7, in1);
 
148
 
 
149
  output [3:0]     dout1, dout2, dout3, dout4, dout5, dout6, dout7;
 
150
  MD dinst1 (dout1, in1);
 
151
  MD #(.inc(2)) dinst2 (dout2, in1);
 
152
  MD #(.inc(-1)) dinst3 (dout3, in1);
 
153
  MD #(.inc(4'd3)) dinst4 (dout4, in1);
 
154
  MD #(.inc(-4'd1)) dinst5 (dout5, in1);
 
155
  MD #(.inc(4'sd3)) dinst6 (dout6, in1);
 
156
  MD #(.inc(-4'sd1)) dinst7 (dout7, in1);
 
157
 
 
158
  output [3:0]     eout1, eout2, eout3, eout4, eout5, eout6, eout7;
 
159
  ME einst1 (eout1, in1);
 
160
  ME #(.inc(2)) einst2 (eout2, in1);
 
161
  ME #(.inc(-1)) einst3 (eout3, in1);
 
162
  ME #(.inc(4'd3)) einst4 (eout4, in1);
 
163
  ME #(.inc(-4'd1)) einst5 (eout5, in1);
 
164
  ME #(.inc(4'sd3)) einst6 (eout6, in1);
 
165
  ME #(.inc(-4'sd1)) einst7 (eout7, in1);
 
166
 
 
167
  output [3:0]     fout1, fout2, fout3, fout4, fout5, fout6, fout7;
 
168
  MF finst1 (fout1, in1);
 
169
  MF #(.inc(2)) finst2 (fout2, in1);
 
170
  MF #(.inc(-1)) finst3 (fout3, in1);
 
171
  MF #(.inc(4'd3)) finst4 (fout4, in1);
 
172
  MF #(.inc(-4'd1)) finst5 (fout5, in1);
 
173
  MF #(.inc(4'sd3)) finst6 (fout6, in1);
 
174
  MF #(.inc(-4'sd1)) finst7 (fout7, in1);
 
175
 
 
176
  output [3:0]     gout1, gout2, gout3, gout4, gout5, gout6, gout7;
 
177
  MG ginst1 (gout1, in1);
 
178
  MG #(.inc(2)) ginst2 (gout2, in1);
 
179
  MG #(.inc(-1)) ginst3 (gout3, in1);
 
180
  MG #(.inc(4'd3)) ginst4 (gout4, in1);
 
181
  MG #(.inc(-4'd1)) ginst5 (gout5, in1);
 
182
  MG #(.inc(4'sd3)) ginst6 (gout6, in1);
 
183
  MG #(.inc(-4'sd1)) ginst7 (gout7, in1);
 
184
 
 
185
  output [3:0]     hout1, hout2, hout3, hout4, hout5, hout6, hout7;
 
186
  MH hinst1 (hout1, in1);
 
187
  MH #(.inc(2)) hinst2 (hout2, in1);
 
188
  MH #(.inc(-1)) hinst3 (hout3, in1);
 
189
  MH #(.inc(4'd3)) hinst4 (hout4, in1);
 
190
  MH #(.inc(-4'd1)) hinst5 (hout5, in1);
 
191
  MH #(.inc(4'sd3)) hinst6 (hout6, in1);
 
192
  MH #(.inc(-4'sd1)) hinst7 (hout7, in1);
 
193
 
 
194
  output [3:0]     iout1, iout2, iout3, iout4, iout5, iout6, iout7;
 
195
  MI iinst1 (iout1, in1);
 
196
  MI #(.inc(2)) iinst2 (iout2, in1);
 
197
  MI #(.inc(-1)) iinst3 (iout3, in1);
 
198
  MI #(.inc(4'd3)) iinst4 (iout4, in1);
 
199
  MI #(.inc(-4'd1)) iinst5 (iout5, in1);
 
200
  MI #(.inc(4'sd3)) iinst6 (iout6, in1);
 
201
  MI #(.inc(-4'sd1)) iinst7 (iout7, in1);
 
202
 
 
203
endmodule
 
204
 
 
205
 
 
206
/*+VL
 
207
 
 
208
module make_tests () ;
 
209
 
 
210
wire [3:0] in1, in2,
 
211
 aout1, aout2, aout3,
 
212
 bout1, bout2, bout3, bout4, bout5, bout6, bout7,
 
213
 cout1, cout2, cout3, cout4, cout5, cout6, cout7,
 
214
 dout1, dout2, dout3, dout4, dout5, dout6, dout7,
 
215
 eout1, eout2, eout3, eout4, eout5, eout6, eout7,
 
216
 fout1, fout2, fout3, fout4, fout5, fout6, fout7,
 
217
 gout1, gout2, gout3, gout4, gout5, gout6, gout7,
 
218
 hout1, hout2, hout3, hout4, hout5, hout6, hout7,
 
219
 iout1, iout2, iout3, iout4, iout5, iout6, iout7;
 
220
 
 
221
 dut #(1) dir_test_1 ( in1, in2,
 
222
 aout1, aout2, aout3,
 
223
 bout1, bout2, bout3, bout4, bout5, bout6, bout7,
 
224
 cout1, cout2, cout3, cout4, cout5, cout6, cout7,
 
225
 dout1, dout2, dout3, dout4, dout5, dout6, dout7,
 
226
 eout1, eout2, eout3, eout4, eout5, eout6, eout7,
 
227
 fout1, fout2, fout3, fout4, fout5, fout6, fout7,
 
228
 gout1, gout2, gout3, gout4, gout5, gout6, gout7,
 
229
 hout1, hout2, hout3, hout4, hout5, hout6, hout7,
 
230
 iout1, iout2, iout3, iout4, iout5, iout6, iout7
 
231
 );
 
232
 
 
233
endmodule
 
234
 
 
235
*/
 
236
 
 
237
 
 
238
`endif