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 are arguments to a function
41//
42//	Author: PRP
43//	Date Created: 19 Feb 99
44//
45
46
47#include "systemc.h"
48#include "test.h"
49
50sc_lv_base AND_fn (const sc_lv_base &a, const sc_lv_base &b)
51{
52  return a | b;
53}
54
55sc_lv_base OR_fn (const sc_lv_base &a, const sc_lv_base &b)
56{
57  return a & b;
58}
59
60void test::entry()
61{
62  sc_lv<8> a;
63  sc_lv<8> b;
64  sc_lv<8> c;
65  sc_lv<8> d;
66  sc_lv<24> e;
67  sc_lv<24> f;
68
69  sc_logic k;
70  sc_logic n;
71  sc_logic m, o, p, q, r, s, t, u;
72
73  sc_lv<32> x;
74  sc_lv<32> y;
75  sc_lv<32> z;
76  sc_lv<32> z1;
77
78
79  while (true) {
80
81  wait ();
82
83  a = "00000000";  	// 0
84  b = "00000001";	// 1
85  c = "00000011";	// 3
86  d = "00001111";	// 15
87  e = "000000000000000000000001"; // 1
88  f = "000000000000000000001010"; // 10
89
90  // =============== Array + Array ====================================
91  // variable + variable, cascading
92  x = OR_fn ((a, b, c, d), (d, c, b, a));
93  // x = 00001111 00000011 00000011 00001111
94
95  // variable + constant, cascading, composition
96  y = AND_fn  (((a, b, c), "00000000"), (d, "00000000", b, a));
97  // y = 00000000 00000000 00000001 00000000
98
99  // constant + constant
100  z = OR_fn (( sc_lv_base( "0000000000000000" ), "1000000000000000"), x);
101  // z = 00001111 00000011 10000011 00001111
102
103  z = z & (~y);
104  // z = 00001111 00000011 10000010 00001111
105
106  // =============== Array (variable) + Scalar ==============================
107
108  n = '1';
109  o = '0';
110  z = OR_fn (z, ( sc_lv_base( n ), "000000000000000", "0000000000000000"));
111  // z = 10001111 00000011 10000010 00001111
112
113  z =  OR_fn (z, ( sc_lv_base( "00000000" ), o, n, d, "00000000000000"));
114  // z = 10001111 01000011 11000010 00001111
115
116  k = '1';
117  z =  OR_fn (z, ( sc_lv_base( "00000000" ), "00", k, "00000", "0000000000000000"));
118  // z = 10001111 01100011 11000010 00001111
119
120  // =============== Null Vector ====================================
121
122  z = AND_fn (z, (( sc_lv_base( o ), sc_lv_base( k ), "111111"), "111111111111111111111111"));
123  // z = 00001111 01100011 11000010 00001111
124
125  // =============== LHS/RHS of different widths ==============================
126
127  z1 = OR_fn (z, sc_lv_base( "00000000000000000000000000000000" )); // length of string = 32
128
129  o1 = z.to_int();  // o1 = 00001111 01100011 11000010 00001111
130  wait();
131
132  }
133}
134
135