datatypes.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  datatypes.cpp --
23
24  Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-30
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#include "datatypes.h"
40#define true 1
41#define false  0
42
43void datatypes::entry()
44
45{
46
47  sc_bigint<8>    tmp1;
48  sc_bigint<8>    tmp1r;
49  sc_biguint<8>   tmp2;
50  sc_biguint<8>   tmp2r;
51  long            tmp3;
52  long            tmp3r;
53  int             tmp4;
54  int             tmp4r;
55  short           tmp5;
56  short           tmp5r;
57  char            tmp6;
58  char            tmp6r;
59
60// define 1 dimensional array
61   unsigned int  tmp7[2];
62   char tmp8[2];
63
64// define sc_bool_vector
65  sc_bv<4>	tmp10;
66  tmp10[3] = 0;  tmp10[2] = 1;  tmp10[1] = 0;  tmp10[0] = 1;
67
68// define 2 dimentional array
69   sc_bv<1> tmp11[2];
70
71// reset_loop
72  if (reset.read() == true) {
73    out_valid.write(false);
74    out_ack.write(false);
75    wait();
76  } else wait();
77
78//
79// main loop
80//
81
82// initialization of sc_array
83
84   tmp7[0] = 3;
85   tmp7[1] = 12;
86   tmp8[0] = 'S';
87   tmp8[1] = 'C';
88   tmp11[0][0] = "1";
89   tmp11[1][0] = "0";
90
91
92 while(1) {
93    while(in_valid.read()==false) wait();
94
95    //reading the inputs
96    tmp1 = in_value1.read();
97    tmp2 = in_value2.read();
98    tmp3 = in_value3.read();
99    tmp4 = in_value4.read();
100    tmp5 = in_value5.read();
101    tmp6 = in_value6.read();
102
103    out_ack.write(true);
104
105    //execute mixed data type shift left operations
106    tmp1r = tmp1 << (tmp7[0] % 8);
107    tmp2r = tmp2 << 2;
108    tmp3r = tmp3 << 1;
109    tmp4r = tmp4 << (tmp7[1] % 16);
110    tmp5r = tmp3 << ((unsigned int)(tmp1.to_int()) % 32);
111    tmp6r = tmp6 << 1;
112
113    //write outputs
114    out_value1.write(tmp1r);
115    out_value2.write(tmp2r);
116    out_value3.write(tmp3r);
117    out_value4.write(tmp4r);
118    out_value5.write(tmp5r);
119    out_value6.write(tmp6r);
120
121    out_valid.write(true);
122    wait();
123    out_ack.write(false);
124    out_valid.write(false);
125
126    //execute mixed data type shift left operations
127    tmp1r = tmp1 << (tmp7[0] % 8);
128    tmp2r = tmp2 << (unsigned int)(tmp4 % 8);
129    tmp3r = tmp3 << (short)(tmp5 % 32);
130    tmp4r = tmp4 << 2;
131    tmp5r = tmp3 << ((unsigned int)(tmp5) % 16);
132    tmp6r = tmp6 << (tmp2.to_uint() % 32);
133
134    //write outputs
135    out_value1.write(tmp1r);
136    out_value2.write(tmp2r);
137    out_value3.write(tmp3r);
138    out_value4.write(tmp4r);
139    out_value5.write(tmp5r);
140    out_value6.write(tmp6r);
141
142    out_valid.write(true);
143    wait();
144    out_ack.write(false);
145    out_valid.write(false);
146
147 }
148
149} // End
150
151