~ubuntu-branches/ubuntu/wily/verilator/wily-proposed

« back to all changes in this revision

Viewing changes to test_regress/t/t_sv_enum_type_methods.v

  • Committer: Package Import Robot
  • Author(s): أحمد المحمودي (Ahmed El-Mahmoudy)
  • Date: 2015-04-26 16:20:52 UTC
  • mfrom: (4.1.5 experimental)
  • Revision ID: package-import@ubuntu.com-20150426162052-69yjwh512m0adl2k
Tags: 3.872-2
* Upload to unstable.
* debian/patches/*: Added DEP-3 patch headers.
* Remove debian/gbp.conf, not needed in master branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// DESCRIPTION: Verilator: System Verilog test of enumerated type methods
2
 
//
3
 
// This code exercises the various enumeration methods
4
 
//
5
 
// This file ONLY is placed into the Public Domain, for any use, without
6
 
// warranty.
7
 
 
8
 
// Contributed 2012 by M W Lund, Atmel Corporation and Jeremy Bennett, Embecosm.
9
 
 
10
 
 
11
 
 
12
 
// **** Pin Identifiers ****
13
 
typedef enum int
14
 
{
15
 
 PINID_A0 = 32'd0,                    // MUST BE ZERO!
16
 
 // - Standard Ports -
17
 
           PINID_A1, PINID_A2, PINID_A3, PINID_A4, PINID_A5, PINID_A6, PINID_A7,
18
 
 PINID_B0, PINID_B1, PINID_B2, PINID_B3, PINID_B4, PINID_B5, PINID_B6, PINID_B7,
19
 
 PINID_C0, PINID_C1, PINID_C2, PINID_C3, PINID_C4, PINID_C5, PINID_C6, PINID_C7,
20
 
 PINID_D0, PINID_D1, PINID_D2, PINID_D3, PINID_D4, PINID_D5, PINID_D6, PINID_D7,
21
 
 PINID_E0, PINID_E1, PINID_E2, PINID_E3, PINID_E4, PINID_E5, PINID_E6, PINID_E7,
22
 
 PINID_F0, PINID_F1, PINID_F2, PINID_F3, PINID_F4, PINID_F5, PINID_F6, PINID_F7,
23
 
 PINID_G0, PINID_G1, PINID_G2, PINID_G3, PINID_G4, PINID_G5, PINID_G6, PINID_G7,
24
 
 PINID_H0, PINID_H1, PINID_H2, PINID_H3, PINID_H4, PINID_H5, PINID_H6, PINID_H7,
25
 
// PINID_I0, PINID_I1, PINID_I2, PINID_I3, PINID_I4, PINID_I5, PINID_I6, PINID_I7,-> DO NOT USE!!!! I == 1
26
 
 PINID_J0, PINID_J1, PINID_J2, PINID_J3, PINID_J4, PINID_J5, PINID_J6, PINID_J7,
27
 
 PINID_K0, PINID_K1, PINID_K2, PINID_K3, PINID_K4, PINID_K5, PINID_K6, PINID_K7,
28
 
 PINID_L0, PINID_L1, PINID_L2, PINID_L3, PINID_L4, PINID_L5, PINID_L6, PINID_L7,
29
 
 PINID_M0, PINID_M1, PINID_M2, PINID_M3, PINID_M4, PINID_M5, PINID_M6, PINID_M7,
30
 
 PINID_N0, PINID_N1, PINID_N2, PINID_N3, PINID_N4, PINID_N5, PINID_N6, PINID_N7,
31
 
// PINID_O0, PINID_O1, PINID_O2, PINID_O3, PINID_O4, PINID_O5, PINID_O6, PINID_O7,-> DO NOT USE!!!! O == 0
32
 
 PINID_P0, PINID_P1, PINID_P2, PINID_P3, PINID_P4, PINID_P5, PINID_P6, PINID_P7,
33
 
 PINID_Q0, PINID_Q1, PINID_Q2, PINID_Q3, PINID_Q4, PINID_Q5, PINID_Q6, PINID_Q7,
34
 
 PINID_R0, PINID_R1, PINID_R2, PINID_R3, PINID_R4, PINID_R5, PINID_R6, PINID_R7,
35
 
 // - AUX Port (Custom) -
36
 
 PINID_X0, PINID_X1, PINID_X2, PINID_X3, PINID_X4, PINID_X5, PINID_X6, PINID_X7,
37
 
 // - PDI Port -
38
 
 PINID_D2W_DAT, PINID_D2W_CLK,
39
 
 // - Power Pins -
40
 
 PINID_VDD0, PINID_VDD1, PINID_VDD2, PINID_VDD3,
41
 
 PINID_GND0, PINID_GND1, PINID_GND2, PINID_GND3,
42
 
 // - Maximum number of pins -
43
 
 PINID_MAX
44
 
 } t_pinid;
45
 
 
46
 
 
47
 
module t (/*AUTOARG*/
48
 
   // Inputs
49
 
   clk
50
 
   );
51
 
   input clk;
52
 
 
53
 
   wire  a = clk;
54
 
   wire  b = 1'b0;
55
 
   reg   c;
56
 
 
57
 
   test test_i (/*AUTOINST*/
58
 
                // Inputs
59
 
                .clk                    (clk));
60
 
 
61
 
   // This is a compile time only test. Immediately finish
62
 
   always @(posedge clk) begin
63
 
      $write("*-* All Finished *-*\n");
64
 
      $finish;
65
 
   end
66
 
 
67
 
endmodule
68
 
 
69
 
 
70
 
module test (/*AUTOARG*/
71
 
   // Inputs
72
 
   clk
73
 
   );
74
 
   input clk;
75
 
 
76
 
   // Use the enumeration size to initialize a dynamic array
77
 
   t_pinid  e;
78
 
   int   myarray1 [] = new [e.num];
79
 
 
80
 
   always @(posedge clk) begin
81
 
 
82
 
`ifdef TEST_VERBOSE
83
 
      $write ("Enumeration has %d members\n", e.num);
84
 
`endif
85
 
 
86
 
      e = e.first;
87
 
 
88
 
      forever begin
89
 
         myarray1[e] <= e.prev;
90
 
 
91
 
`ifdef TEST_VERBOSE
92
 
         $write ("myarray1[%d] (enum %s) = %d\n", e, e.name, myarray1[e]);
93
 
`endif
94
 
 
95
 
         if (e == e.last) begin
96
 
            break;
97
 
         end
98
 
         else begin
99
 
            e = e.next;
100
 
         end
101
 
      end
102
 
   end
103
 
 
104
 
endmodule