datatypes.cpp revision 12855:588919e0e4aa
16498Snate@binkert.org/*****************************************************************************
24479Sbinkertn@umich.edu
34479Sbinkertn@umich.edu  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
44479Sbinkertn@umich.edu  more contributor license agreements.  See the NOTICE file distributed
54479Sbinkertn@umich.edu  with this work for additional information regarding copyright ownership.
66498Snate@binkert.org  Accellera licenses this file to you under the Apache License, Version 2.0
74479Sbinkertn@umich.edu  (the "License"); you may not use this file except in compliance with the
84479Sbinkertn@umich.edu  License.  You may obtain a copy of the License at
94479Sbinkertn@umich.edu
106498Snate@binkert.org    http://www.apache.org/licenses/LICENSE-2.0
114479Sbinkertn@umich.edu
124479Sbinkertn@umich.edu  Unless required by applicable law or agreed to in writing, software
134479Sbinkertn@umich.edu  distributed under the License is distributed on an "AS IS" BASIS,
144479Sbinkertn@umich.edu  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
154479Sbinkertn@umich.edu  implied.  See the License for the specific language governing
164479Sbinkertn@umich.edu  permissions and limitations under the License.
174479Sbinkertn@umich.edu
184479Sbinkertn@umich.edu *****************************************************************************/
194479Sbinkertn@umich.edu
204479Sbinkertn@umich.edu/*****************************************************************************
214479Sbinkertn@umich.edu
224479Sbinkertn@umich.edu  datatypes.cpp --
234479Sbinkertn@umich.edu
244479Sbinkertn@umich.edu  Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-30
254479Sbinkertn@umich.edu
264479Sbinkertn@umich.edu *****************************************************************************/
274479Sbinkertn@umich.edu
286498Snate@binkert.org/*****************************************************************************
294479Sbinkertn@umich.edu
304479Sbinkertn@umich.edu  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
314479Sbinkertn@umich.edu  changes you are making here.
326498Snate@binkert.org
334479Sbinkertn@umich.edu      Name, Affiliation, Date:
344479Sbinkertn@umich.edu  Description of Modification:
354479Sbinkertn@umich.edu
364479Sbinkertn@umich.edu *****************************************************************************/
374479Sbinkertn@umich.edu
384479Sbinkertn@umich.edu
394479Sbinkertn@umich.edu#include "datatypes.h"
404479Sbinkertn@umich.edu
414479Sbinkertn@umich.eduvoid datatypes::entry()
424479Sbinkertn@umich.edu
434479Sbinkertn@umich.edu{
444479Sbinkertn@umich.edu  sc_bigint<8>    tmp1;
454479Sbinkertn@umich.edu  sc_bigint<8>    tmp1r;
46  sc_biguint<8>   tmp2;
47  sc_biguint<8>   tmp2r;
48  long            tmp3;
49  long            tmp3r;
50  int             tmp4;
51  int             tmp4r;
52  short           tmp5;
53  short           tmp5r;
54  char            tmp6;
55  char            tmp6r;
56  bool            tmp7;
57  bool            tmp7r;
58  sc_bv<4>        tmp8;
59  sc_bv<4>        tmp8r;
60  sc_lv<4>        tmp9;
61  sc_lv<4>        tmp9r;
62
63// define 1 dimensional array
64   int  tmpa[2];
65   char tmpb[2];
66
67// reset_loop
68  if (reset.read() == true) {
69    out_valid.write(false);
70    out_ack.write(false);
71    wait();
72  } else wait();
73
74//
75// main loop
76//
77// initialization of sc_array
78
79   tmpa[0] = 12;
80   tmpa[1] = 127;
81   tmpb[1] = 'G';
82
83
84 while(1) {
85    while(in_valid.read()==false) wait();
86
87    //reading the inputs
88    tmp1 = in_value1.read();
89    tmp2 = in_value2.read();
90    tmp3 = in_value3.read();
91    tmp4 = in_value4.read();
92    tmp5 = in_value5.read();
93    tmp6 = in_value6.read();
94    tmpb[0] = in_value7.read();
95    tmp7 = in_value8.read();
96    tmp8 = in_value9.read();
97    tmp9 = in_value10.read();
98
99    out_ack.write(true);
100
101    //execute mixed data type not operations
102
103    // signed(8) <- ~ unsigned(8)
104    tmp1r = ~ tmp2;
105    // unsigned(8) <- ~ long
106    tmp2r = ~ tmp3;
107    // long <- ~ char
108    tmp3r = ~ tmp6;
109    // int <- ~ short
110    tmp4r = ~ tmp5;
111    // short <- ~ int
112    tmp5r = ~ tmp4;
113    // char <- ~ char_array[0]
114    // tmp6r = ~ tmp8[0];
115    tmp6r = ~ tmp8[0].to_bool();
116    // bool <- ! bool;
117    tmp7r = !tmp7;
118    // sc_bool_vector(4) <- ~ sc_logic_vector(4)
119    tmp8r = ~ tmp9;
120    //  sc_logic_vector(4) <- ~ sc_bool_vector(4)
121    tmp9r = ~ tmp9;
122
123    //write outputs
124    out_value1.write(tmp1r);
125    out_value2.write(tmp2r);
126    out_value3.write(tmp3r);
127    out_value4.write(tmp4r);
128    out_value5.write(tmp5r);
129    out_value6.write(tmp6r);
130    out_value7.write(tmp7r);
131    out_value8.write(tmp8r);
132    out_value9.write(tmp9r);
133
134    out_valid.write(true);
135    wait();
136    out_ack.write(false);
137    out_valid.write(false);
138
139 }
140
141} // End
142
143
144