test.cpp revision 12855:588919e0e4aa
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  test.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/*
39Dec/19/00 ulrich
40
41Assignment to a bit-slice of an sc_bv, even with an sc_bv with proper size, does not
42compile on Solaris SC5.0. It works for gcc, though.
43
44It works for sc_int and sc_bigint on both compilers.
45
46
47I am using SystemC 1.0.1 (someone **PLEASE** add 1.0.1 to the Stellar list of release!)
48
49Example:
50*/
51
52#include <systemc.h>
53
54int sc_main(int argc, char* arg[])
55{
56  sc_bv<8> bv8 = 3;
57  sc_bv<4> bv4 = 3;
58  sc_int<8> i8 = 3;
59  sc_int<4> i4 = 3;
60  sc_bigint<8> bi8=3;
61  sc_bigint<4> bi4=3;
62
63  // OK
64  bi8.range(5,2) = bi4.range(3,0);
65  bi8.range(5,2) = bi4;
66  bi8.range(5,2) = 3;
67  bi8.range(5,2) = (sc_bigint<4>(3)).range(3,0);
68
69  // OK
70  i8.range(5,2) = i4.range(3,0);
71  i8.range(5,2) = i4;
72  i8.range(5,2) = 3;
73  i8.range(5,2) = (sc_int<4>(3)).range(3,0);
74
75
76  // OK
77  bv8.range(5,2) = bv4.range(3,0);
78
79  // OK gcc, error SC5.0
80  bv8.range(5,2) = bv4;
81  bv8.range(5,2) = (sc_bv<4>(3)).range(3,0);
82
83  return 0;
84}
85