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

« back to all changes in this revision

Viewing changes to books/centaur/vl/systest/case/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
// basic tests of case statement handling
 
32
 
 
33
module case_test (
 
34
 
 
35
src1,
 
36
src2,
 
37
src3,
 
38
 
 
39
out1,
 
40
out2,
 
41
out3,
 
42
out4,
 
43
out5
 
44
 
 
45
);
 
46
 
 
47
  parameter size = 1;
 
48
 
 
49
  input [size-1:0] src1;
 
50
  input [size-1:0] src2;
 
51
  input [size-1:0] src3;
 
52
 
 
53
  output [size-1:0] out1;
 
54
  output [size-1:0] out2;
 
55
  output [size-1:0] out3;
 
56
  output [size-1:0] out4;
 
57
  output [size-1:0] out5;
 
58
 
 
59
  reg [size-1:0]    out1, out2, out3, out4, out5;
 
60
 
 
61
  wire [2:0]        lsbs = {src1[0], src2[0], src3[0]};
 
62
 
 
63
  always @(lsbs)
 
64
    case(lsbs)
 
65
      3'b 000: out1 = 0;
 
66
      3'b 001: out1 = 1;
 
67
      3'b 010: out1 = 2;
 
68
      3'b 011: out1 = 3;
 
69
      3'b 100: out1 = 4;
 
70
      3'b 101: out1 = 5;
 
71
      3'b 110: out1 = 6;
 
72
      3'b 111: out1 = 7;
 
73
      default: out1 = {size{1'bx}};
 
74
    endcase
 
75
 
 
76
  always @(lsbs)
 
77
    case(lsbs)
 
78
      3'b 1??: out2 = 0;
 
79
      3'b 01?: out2 = 1;
 
80
      3'b 001: out2 = 2;
 
81
      3'b 000: out2 = 3;
 
82
      default: out2 = {size{1'bx}};
 
83
    endcase
 
84
 
 
85
  always @(lsbs)
 
86
    case(lsbs)
 
87
      3'b 1xx: out3 = 0;
 
88
      3'b 01x: out3 = 1;
 
89
      3'b 001: out3 = 2;
 
90
      3'b 000: out3 = 3;
 
91
      default: out3 = {size{1'bx}};
 
92
    endcase
 
93
 
 
94
  always @(lsbs)
 
95
    case(3'b110)
 
96
      {lsbs[0], lsbs[1], lsbs[2]} : out4 = 0;
 
97
      {lsbs[1], lsbs[0], lsbs[2]} : out4 = 1;
 
98
      {lsbs[1], lsbs[2], lsbs[0]} : out4 = 2;
 
99
      default:                      out4 = 3;
 
100
    endcase
 
101
 
 
102
  always @(lsbs)
 
103
    case(3'b101)
 
104
      {lsbs[0], lsbs[1], lsbs[2]} : out5 = 0;
 
105
      {lsbs[1], lsbs[0], lsbs[2]} : out5 = 1;
 
106
      {lsbs[1], lsbs[2], lsbs[0]} : out5 = 2;
 
107
      default:                      out5 = 3;
 
108
    endcase
 
109
 
 
110
 
 
111
endmodule
 
112
 
 
113
 
 
114
 
 
115
/*+VL
 
116
 
 
117
module make_tests () ;
 
118
 
 
119
 wire [7:0] w;
 
120
 
 
121
 case_test #(1) test1 (w[0:0], w[0:0], w[0:0],
 
122
                       w[0:0], w[0:0], w[0:0], w[0:0], w[0:0]);
 
123
 
 
124
 case_test #(2) test2 (w[1:0], w[1:0], w[1:0],
 
125
                       w[1:0], w[1:0], w[1:0], w[1:0], w[1:0]);
 
126
 
 
127
 case_test #(3) test3 (w[2:0], w[2:0], w[2:0],
 
128
                       w[2:0], w[2:0], w[2:0], w[2:0], w[2:0]);
 
129
 
 
130
 case_test #(4) test4 (w[3:0], w[3:0], w[3:0],
 
131
                       w[3:0], w[3:0], w[3:0], w[3:0], w[3:0]);
 
132
 
 
133
 case_test #(5) test5 (w[4:0], w[4:0], w[4:0],
 
134
                       w[4:0], w[4:0], w[4:0], w[4:0], w[4:0]);
 
135
 
 
136
 case_test #(6) test6 (w[5:0], w[5:0], w[5:0],
 
137
                       w[5:0], w[5:0], w[5:0], w[5:0], w[5:0]);
 
138
 
 
139
 case_test #(7) test7 (w[6:0], w[6:0], w[6:0],
 
140
                       w[6:0], w[6:0], w[6:0], w[6:0], w[6:0]);
 
141
 
 
142
 case_test #(8) test8 (w[7:0], w[7:0], w[7:0],
 
143
                       w[7:0], w[7:0], w[7:0], w[7:0], w[7:0]);
 
144
 
 
145
endmodule
 
146
 
 
147
*/
 
148
 
 
149