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 41void datatypes::entry() 42 43{ 44 sc_bigint<8> tmp1; 45 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 and operations 102 103 // signed(8) <- signed(8) & unsigned(8) 104 tmp1r = tmp1 & tmp2; 105 // unsigned(8) <- char & long 106 tmp2r = tmp6 & tmp3; 107 // long <- int & char 108 tmp3r = tmp4 & tmp6; 109 // int <- int & short 110 tmp4r = tmp4 & tmp5; 111 // short <- short & const 112 tmp5r = tmp5 & 5; 113 // char <- char_array[0] & int_array[1] 114 tmp6r = tmpb[0] & tmpa[1]; 115 // bool <- bool & bool; 116 tmp7r = tmp7 & tmp7; 117 // sc_bool_vector(4) <- sc_bool_vector(4) & sc_logic_vector(4) 118 tmp8r = tmp8 & tmp9; 119 // sc_logic_vector(4) <- sc_bool_vector(4) & "0111" 120 tmp9r = tmp9 & sc_bv<4>( "0111" ); 121 122 //write outputs 123 out_value1.write(tmp1r); 124 out_value2.write(tmp2r); 125 out_value3.write(tmp3r); 126 out_value4.write(tmp4r); 127 out_value5.write(tmp5r); 128 out_value6.write(tmp6r); 129 out_value7.write(tmp7r); 130 out_value8.write(tmp8r); 131 out_value9.write(tmp9r); 132 133 out_valid.write(true); 134 wait(); 135 out_ack.write(false); 136 out_valid.write(false); 137 138 } 139 140} // End 141 142 143