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//
39//	Verifies the functionality of concanetation operation.
40//	Operands form the rvalue of an assignment
41//
42//	Author: PRP
43//	Date Created: 19 Feb 99
44//
45
46
47#include "systemc.h"
48#include "test.h"
49
50void test::entry()
51{
52  sc_lv<8> a;
53  sc_lv<8> b;
54  sc_lv<8> c;
55  sc_lv<8> d;
56  sc_lv<24> e;
57  sc_lv<24> f;
58
59  // sc_logic k;
60  // sc_logic n;
61  // sc_logic m, o, p, q, r, s, t, u;
62  sc_lv<1> k, n, m, o, p, q, r, s, t, u;
63
64  sc_lv<32> x;
65  sc_lv<32> y;
66  sc_lv<32> z;
67
68  int i,j;
69
70  while (true) {
71
72  wait ();
73
74
75  b = "00000001";	// 1
76  c = "00000011";	// 3
77  d = "00001111";	// 15
78
79  // =============== Array + Array ====================================
80
81  (a, f) = "00000000000000000000000000000011"; // a = 0, f = 3
82
83  // =============== Cascading ====================================
84  // cascading  array variables
85  (a, f) = (b, c, d, a);
86	// a = 00000001  f = "00000011 00001111 00000000"
87  z = (a, f);
88
89  // composing cascaded  array variables
90  x = ( sc_lv_base( "00000011" ), "00000011", "00000011", "00000101");
91  (a, (b, c, d)) = x;
92  z = z | x;	// z = 00000011 00000011 00001111 00000101
93
94  // =============== Array (variable) + Scalar ==============================
95
96  (b, c, d, a.range (7, 2), k, n) = (a, b, c, d);
97	// b = 00000011  c = 00000011  d = 00000011 a = 00000111
98	// k = 0  n = 1
99  z = z | (a, b, c, d); // z = 00000111 00000011 00001111 00000111
100
101  ( k, m, a.range (5, 0)) = z.range (15, 8);
102	// k = 0  m = 0  a = 00001111
103  z = z | ( sc_lv_base( n ), m, k, n, "0000", a, "0000000000000000");
104	// z = 10010111 00001111 00001111 00000111
105
106  // =============== Null Vector ====================================
107
108  ( m, n, o, p, q, r, s, t ) = "11011010";
109  a = ( sc_lv_base( s ), t, q, r, o, m, n, p);	// a = "10100111"
110  z = (z.range (31, 8), a); 	// z = 10010111 00001111 00001111 10100111
111
112  b = "00000000";
113
114  z =  z | (b, b, b, z.range (7, 0));
115
116  // =============== LHS/RHS of different widths ==============================
117
118  (x.range (15, 0), x.range (31, 16)) = ("1001011100001111000011111010011101");
119  // RHS is (z, "01")
120  // x = 00111110 10011101 01011100 00111100
121
122  (z.range (31, 16), z.range (15, 0)) = (x.range (7, 0), x.range (23, 16),
123					 x.range (15, 8), x.range (31, 24));
124	// z = 00111100 10011101 01011100 00111110
125
126  o1 = z.to_int();
127  wait();
128
129  }
130}
131
132