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