conditions.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 conditions.cpp -- 23 24 Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-22 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 "conditions.h" 40 41void conditions::entry(){ 42 43 sc_biguint<4> tmp1; 44 sc_bigint<4> tmp2; 45 sc_biguint<4> tmp2a; 46 sc_lv<4> tmp3; 47 sc_bv<4> tmp4; 48 int tmp5; 49 bool cond_tmp; 50 51 // reset_loop 52 if (reset.read() == true) { 53 out_value1.write(0); 54 out_value2.write(0); 55 out_value3.write(0); 56 out_value4.write(0); 57 out_value5.write(0); 58 out_valid.write(false); 59 wait(); 60 } else wait(); 61 62 // 63 // main loop 64 // 65 while(1) { 66 do { wait(); } while (in_valid == false); 67 68 //reading inputs 69 tmp1 = in_value1.read(); 70 tmp2 = in_value2.read(); 71 tmp4 = in_value4.read(); 72 tmp5 = in_value5.read(); 73 74 // complex condition on variables 75 if ((tmp1==4) && (tmp2<6) || (tmp5+tmp4.to_int()==6)) { 76 out_value1.write(4); 77 } else { 78 out_value1.write(tmp1); 79 }; 80 wait(); 81 82 // complex conditions on signal reads 83 if ((in_value1.read().to_uint()==4) && (in_value2.read().to_int()<6) || 84 (in_value4.read().to_int()+in_value5.read()==6)) { 85 out_value2.write(4); 86 } else { 87 out_value2.write(tmp1); 88 }; 89 wait(); 90 91 //reading inputs 92 tmp1 = in_value1.read(); 93 tmp2 = in_value2.read(); 94 tmp3 = in_value3.read(); 95 tmp4 = in_value4.read(); 96 tmp5 = in_value5.read(); 97 98 // complex conditions outside the if; does it matter for timing? 99 cond_tmp = (tmp1==4) && (tmp2<6) || (tmp5+tmp4.to_int()==6); 100 if (cond_tmp) { 101 out_value3.write(4); 102 } else { 103 out_value3.write(tmp1); 104 }; 105 wait(); 106 107 // arithmetic if can only be done when using the same datatypes 108 // therefor the temporary assignment 109 tmp2a = 0; 110 out_value4.write((tmp3.to_int()==4) && (tmp1<6) || 111 (tmp5+tmp2.to_int()==6)?tmp2a:tmp1); 112 wait(); 113 114 // arithmetic if can only be done when using the same datatypes 115 // therefor the temporary assignment 116 tmp5 = tmp2.to_int(); 117 out_value5.write((in_value3.read().to_int()==4) && 118 (in_value1.read().to_int()<6) || 119 (in_value5.read()+in_value2.read().to_int()==6)? 120 0:tmp5); 121 out_valid.write(true); 122 wait(); 123 out_valid.write(false); 124 125 } 126} 127 128// EOF 129 130