1/*****************************************************************************
2
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements.  See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License.  You may obtain a copy of the License at
9
10    http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied.  See the License for the specific language governing
16  permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22  tvec3.cpp --
23
24  Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
25
26 *****************************************************************************/
27
28/*****************************************************************************
29
30  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
31  changes you are making here.
32
33      Name, Affiliation, Date:
34  Description of Modification:
35
36 *****************************************************************************/
37
38#include "systemc.h"
39
40typedef sc_signal_rv<3> sc_signal_resolved_vector;
41
42SC_MODULE( proc1 )
43{
44  SC_HAS_PROCESS( proc1 );
45
46  sc_signal_resolved_vector& out;
47  sc_in<bool> in;
48
49  proc1( sc_module_name n,
50	 sc_signal_resolved_vector& OUT_,
51	 sc_signal<bool>& IN_ )
52    : out(OUT_)
53  {
54    in(IN_);
55	SC_METHOD( entry );
56    sensitive << in;
57  }
58
59  void entry();
60};
61
62void
63proc1::entry()
64{
65  sc_lv<3> a;
66  if ((bool) in == true) {
67    cout << "P1: Set to 1" << endl;
68    a = "111";
69    out = a;
70  }
71  else {
72    cout << "P1: Set to Z" << endl;
73    a = "ZZZ";
74    out = a;
75  }
76}
77
78
79SC_MODULE( proc2 )
80{
81  SC_HAS_PROCESS( proc2 );
82
83  sc_signal_resolved_vector& out;
84  sc_in<bool> in;
85
86  proc2( sc_module_name n,
87	 sc_signal_resolved_vector& OUT_,
88	 sc_signal<bool>& IN_ )
89    : out(OUT_)
90  {
91    in(IN_);
92	SC_METHOD( entry );
93    sensitive << in;
94  }
95
96  void entry();
97};
98
99void
100proc2::entry()
101{
102  sc_lv<3> a;
103  if ((bool) in == false) {
104    cout << "P2: Set to 1" << endl;
105    a = "111";
106    out = a;
107  }
108  else {
109    cout << "P2: Set to Z" << endl;
110    a = "ZZZ";
111    out = a;
112  }
113}
114
115SC_MODULE( proc3 )
116{
117  SC_HAS_PROCESS( proc3 );
118
119  const sc_signal_resolved_vector& in;
120
121  proc3( sc_module_name n,
122	 const sc_signal_resolved_vector& IN_ )
123    : in(IN_)
124  {
125    SC_METHOD( entry );
126    sensitive << in;
127  }
128
129  void entry()
130  {
131    sc_lv<3> v;
132    v = in;
133    cout << "Value on Bus = " << v.to_string().c_str() << endl;
134  }
135};
136
137int sc_main(int ac, char *av[])
138{
139  sc_signal_resolved_vector Bus;
140  sc_signal<bool> clock;
141
142  proc1 P1("P1", Bus, clock);
143  proc2 P2("P2", Bus, clock);
144  proc3 P3("P3", Bus);
145
146  sc_start(1, SC_NS);
147  clock = 1;
148  sc_start(10, SC_NS);
149  for (int i = 0; i < 3; i++) {
150    clock = 0;
151    sc_start(10, SC_NS);
152    clock = 1;
153    sc_start(10, SC_NS);
154  }
155  return 0;
156}
157
158