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  test02.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// test of positional binding -- general test of operator ,
39
40#include "systemc.h"
41
42template <class T>
43SC_MODULE( prim_source )
44{
45    sc_out<T>                     out;
46    sc_port<sc_signal_out_if<T> > port_out;
47
48    SC_CTOR( prim_source ) {}
49};
50
51template <class T>
52SC_MODULE( prim_transfer )
53{
54    sc_in<T>                      in;
55    sc_port<sc_signal_in_if<T> >  port_in;
56    sc_out<T>                     out;
57    sc_port<sc_signal_out_if<T> > port_out;
58
59
60    SC_CTOR( prim_transfer ) {}
61};
62
63template <class T>
64SC_MODULE( prim_sink )
65{
66    sc_in<T>                     in;
67    sc_port<sc_signal_in_if<T> > port_in;
68
69    SC_CTOR( prim_sink ) {}
70};
71
72template <class T>
73SC_MODULE( hier_source )
74{
75    sc_out<T>                     out;
76    sc_port<sc_signal_out_if<T> > port_out;
77
78    prim_source<T> prim_source1;
79
80    SC_CTOR( hier_source )
81    : prim_source1( "prim_source1" )
82    {
83	prim_source1, out, port_out;
84    }
85};
86
87template <class T>
88SC_MODULE( hier_transfer )
89{
90    sc_in<T>                      in;
91    sc_port<sc_signal_in_if<T> >  port_in;
92    sc_out<T>                     out;
93    sc_port<sc_signal_out_if<T> > port_out;
94
95    prim_transfer<T> prim_transfer1;
96
97    SC_CTOR( hier_transfer )
98    : prim_transfer1( "prim_transfer1" )
99    {
100	prim_transfer1, in, port_in, out, port_out;
101    }
102};
103
104template <class T>
105SC_MODULE( hier_sink )
106{
107    sc_in<T>                     in;
108    sc_port<sc_signal_in_if<T> > port_in;
109
110    prim_sink<T> prim_sink1;
111
112    SC_CTOR( hier_sink )
113    : prim_sink1( "prim_sink1" )
114    {
115	prim_sink1, in, port_in;
116    }
117};
118
119template <class T>
120SC_MODULE( hier1 )
121{
122    sc_signal<T> sig1;
123    sc_signal<T> sig2;
124    sc_signal<T> sig3;
125    sc_signal<T> sig4;
126
127    prim_source<T>   prim_source1;
128    prim_transfer<T> prim_transfer1;
129    prim_sink<T>     prim_sink1;
130
131    SC_CTOR( hier1 )
132    : prim_source1( "prim_source1" ),
133      prim_transfer1( "prim_transfer1" ),
134      prim_sink1( "prim_sink1" )
135    {
136	prim_source1, sig1, sig2;
137	prim_transfer1, sig1, sig2, sig3, sig4;
138	prim_sink1, sig3, sig4;
139    }
140};
141
142template <class T>
143SC_MODULE( hier2 )
144{
145    sc_signal<T> sig1;
146    sc_signal<T> sig2;
147    sc_signal<T> sig3;
148    sc_signal<T> sig4;
149
150    hier_source<T>   hier_source1;
151    hier_transfer<T> hier_transfer1;
152    hier_sink<T>     hier_sink1;
153
154    SC_CTOR( hier2 )
155    : hier_source1( "hier_source1" ),
156      hier_transfer1( "hier_transfer1" ),
157      hier_sink1( "hier_sink1" )
158    {
159	hier_source1, sig1, sig2;
160	hier_transfer1, sig1, sig2, sig3, sig4;
161	hier_sink1, sig3, sig4;
162    }
163};
164
165int
166sc_main( int, char*[] )
167{
168    hier1<int> hier1_int( "hier1_int" );
169    hier1<bool> hier1_bool( "hier1_bool" );
170    hier1<sc_logic> hier1_logic( "hier1_logic" );
171
172    hier2<int> hier2_int( "hier2_int" );
173    hier2<bool> hier2_bool( "hier2_bool" );
174    hier2<sc_logic> hier2_logic( "hier2_logic" );
175
176    sc_start(0, SC_NS);
177
178    return 0;
179}
180