balancing.cpp revision 12855:588919e0e4aa
112047Schristian.menard@tu-dresden.de/***************************************************************************** 212047Schristian.menard@tu-dresden.de 312047Schristian.menard@tu-dresden.de Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412047Schristian.menard@tu-dresden.de more contributor license agreements. See the NOTICE file distributed 512047Schristian.menard@tu-dresden.de with this work for additional information regarding copyright ownership. 612047Schristian.menard@tu-dresden.de Accellera licenses this file to you under the Apache License, Version 2.0 712047Schristian.menard@tu-dresden.de (the "License"); you may not use this file except in compliance with the 812047Schristian.menard@tu-dresden.de License. You may obtain a copy of the License at 912047Schristian.menard@tu-dresden.de 1012047Schristian.menard@tu-dresden.de http://www.apache.org/licenses/LICENSE-2.0 1112047Schristian.menard@tu-dresden.de 1212047Schristian.menard@tu-dresden.de Unless required by applicable law or agreed to in writing, software 1312047Schristian.menard@tu-dresden.de distributed under the License is distributed on an "AS IS" BASIS, 1412047Schristian.menard@tu-dresden.de WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512047Schristian.menard@tu-dresden.de implied. See the License for the specific language governing 1612047Schristian.menard@tu-dresden.de permissions and limitations under the License. 1712047Schristian.menard@tu-dresden.de 1812047Schristian.menard@tu-dresden.de *****************************************************************************/ 1912047Schristian.menard@tu-dresden.de 2012047Schristian.menard@tu-dresden.de/***************************************************************************** 2112047Schristian.menard@tu-dresden.de 2212047Schristian.menard@tu-dresden.de balancing.cpp -- 2312047Schristian.menard@tu-dresden.de 2412047Schristian.menard@tu-dresden.de Original Author: Rocco Jonack, Synopsys, Inc., 1999-10-25 2512047Schristian.menard@tu-dresden.de 2612047Schristian.menard@tu-dresden.de *****************************************************************************/ 2712047Schristian.menard@tu-dresden.de 2812047Schristian.menard@tu-dresden.de/***************************************************************************** 2912047Schristian.menard@tu-dresden.de 3012047Schristian.menard@tu-dresden.de MODIFICATION LOG - modifiers, enter your name, affiliation, date and 3112047Schristian.menard@tu-dresden.de changes you are making here. 3212047Schristian.menard@tu-dresden.de 3312047Schristian.menard@tu-dresden.de Name, Affiliation, Date: 3412047Schristian.menard@tu-dresden.de Description of Modification: 3512047Schristian.menard@tu-dresden.de 3612047Schristian.menard@tu-dresden.de *****************************************************************************/ 3712047Schristian.menard@tu-dresden.de 3812047Schristian.menard@tu-dresden.de 3912047Schristian.menard@tu-dresden.de#include "balancing.h" 4012047Schristian.menard@tu-dresden.de 4112047Schristian.menard@tu-dresden.de 4212047Schristian.menard@tu-dresden.devoid balancing::entry(){ 4312047Schristian.menard@tu-dresden.de 4412047Schristian.menard@tu-dresden.de sc_biguint<4> tmp1; 4512047Schristian.menard@tu-dresden.de sc_bigint<4> tmp2; 4612047Schristian.menard@tu-dresden.de sc_biguint<4> tmp3; 4712047Schristian.menard@tu-dresden.de unsigned int tmpint; 4812047Schristian.menard@tu-dresden.de sc_unsigned out_tmp2(12); 4912047Schristian.menard@tu-dresden.de sc_unsigned out_tmp3(12); 5012047Schristian.menard@tu-dresden.de 5112047Schristian.menard@tu-dresden.de // reset_loop 5212047Schristian.menard@tu-dresden.de if (reset.read() == true) { 5312047Schristian.menard@tu-dresden.de out_value1.write(0); 5412047Schristian.menard@tu-dresden.de out_value2.write(0); 5512047Schristian.menard@tu-dresden.de out_value3.write(0); 5612047Schristian.menard@tu-dresden.de out_valid1.write(false); 5712047Schristian.menard@tu-dresden.de out_valid2.write(false); 5812047Schristian.menard@tu-dresden.de out_valid3.write(false); 5912047Schristian.menard@tu-dresden.de out_tmp2 = 0; 6012047Schristian.menard@tu-dresden.de out_tmp3 = 0; 6112047Schristian.menard@tu-dresden.de wait(); 6212047Schristian.menard@tu-dresden.de } else wait(); 63 64 // 65 // main loop 66 // 67 while(1) { 68 do { wait(); } while (in_valid == false); 69 70 //reading inputs 71 tmp1 = in_value1.read(); 72 73 //easy, just a bunch of different waits 74 out_valid1.write(true); 75 tmpint = tmp1.to_uint(); 76 switch (tmpint) { 77 case 4 : 78 wait(); 79 wait(); 80 wait(); 81 wait(); 82 out_value1.write(3); 83 wait(); 84 case 3 : 85 out_value1.write(2); 86 wait(); 87 wait(); 88 wait(); 89 case 2 : 90 out_value1.write(1); 91 wait(); 92 wait(); 93 default : 94 out_value1.write(tmp1); 95 wait(); 96 }; 97 out_valid1.write(false); 98 wait(); 99 100 //the first branch should be pushed out in latency due to long delay 101 tmp2 = in_value2.read(); 102 tmp1 = tmp2; 103 out_valid2.write(true); 104 wait(); 105 tmpint = tmp1.to_uint(); 106 switch (tmpint) { 107 case 0 : 108 case 1 : 109 case 2 : 110 case 3 : 111 //long operation should extent latency 112 out_tmp2 = tmp2*tmp2*tmp2; 113 wait(); 114 case 4 : 115 case 5 : 116 case 6 : 117 case 7 : 118 //short operation should not extent latency 119 out_tmp2 = 4; 120 wait(); 121 case 8 | 9 | 10 | 11: 122 //wait statements should extent latency 123 out_tmp2 = 1; 124 wait(); 125 wait(); 126 wait(); 127 }; 128 wait(); 129 130 out_value2.write( sc_biguint<4>( out_tmp2 ) ); 131 out_valid2.write(false); 132 wait(); 133 134 //the first branch should be pushed out in latency due to long delay 135 tmp3 = in_value3.read(); 136 out_valid3.write(true); 137 wait(); 138 tmpint = tmp3.to_uint(); 139 switch (tmpint) { 140 case 0 : 141 case 1 : 142 case 2 : 143 case 3 : 144 //long operation should extent latency 145 out_tmp2 = tmp2*tmp2*tmp2; 146 wait(); 147 case 4 : 148 case 5 : 149 case 6 : 150 case 7 : 151 //short operation should not extent latency 152 out_tmp2 = 4; 153 case 8 : 154 case 9 : 155 case 10 : 156 case 11 : 157 //wait statements should extent latency 158 out_tmp2 = 1; 159 wait(); 160 wait(); 161 wait(); 162 }; 163 wait(); 164 out_value3.write( sc_biguint<4>( out_tmp3 ) ); 165 wait(); 166 out_valid3.write(false); 167 } 168} 169 170// EOF 171 172