112855Sgabeblack@google.com/***************************************************************************** 212855Sgabeblack@google.com 312855Sgabeblack@google.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412855Sgabeblack@google.com more contributor license agreements. See the NOTICE file distributed 512855Sgabeblack@google.com with this work for additional information regarding copyright ownership. 612855Sgabeblack@google.com Accellera licenses this file to you under the Apache License, Version 2.0 712855Sgabeblack@google.com (the "License"); you may not use this file except in compliance with the 812855Sgabeblack@google.com License. You may obtain a copy of the License at 912855Sgabeblack@google.com 1012855Sgabeblack@google.com http://www.apache.org/licenses/LICENSE-2.0 1112855Sgabeblack@google.com 1212855Sgabeblack@google.com Unless required by applicable law or agreed to in writing, software 1312855Sgabeblack@google.com distributed under the License is distributed on an "AS IS" BASIS, 1412855Sgabeblack@google.com WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512855Sgabeblack@google.com implied. See the License for the specific language governing 1612855Sgabeblack@google.com permissions and limitations under the License. 1712855Sgabeblack@google.com 1812855Sgabeblack@google.com *****************************************************************************/ 1912855Sgabeblack@google.com 2012855Sgabeblack@google.com/***************************************************************************** 2112855Sgabeblack@google.com 2212855Sgabeblack@google.com fsm.cpp -- 2312855Sgabeblack@google.com 2412855Sgabeblack@google.com Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-30 2512855Sgabeblack@google.com 2612855Sgabeblack@google.com *****************************************************************************/ 2712855Sgabeblack@google.com 2812855Sgabeblack@google.com/***************************************************************************** 2912855Sgabeblack@google.com 3012855Sgabeblack@google.com MODIFICATION LOG - modifiers, enter your name, affiliation, date and 3112855Sgabeblack@google.com changes you are making here. 3212855Sgabeblack@google.com 3312855Sgabeblack@google.com Name, Affiliation, Date: 3412855Sgabeblack@google.com Description of Modification: 3512855Sgabeblack@google.com 3612855Sgabeblack@google.com *****************************************************************************/ 3712855Sgabeblack@google.com 3812855Sgabeblack@google.com 3912855Sgabeblack@google.com#include "fsm.h" 4012855Sgabeblack@google.com 4112855Sgabeblack@google.comvoid fsm::entry(){ 4212855Sgabeblack@google.com 4312855Sgabeblack@google.com sc_biguint<4> tmp1; 4412855Sgabeblack@google.com sc_biguint<4> tmp2; 4512855Sgabeblack@google.com sc_biguint<4> tmp3; 4612855Sgabeblack@google.com sc_unsigned out_tmp2(12); 4712855Sgabeblack@google.com sc_unsigned out_tmp3(12); 4812855Sgabeblack@google.com 4912855Sgabeblack@google.com unsigned int tmpint; 5012855Sgabeblack@google.com 5112855Sgabeblack@google.com // reset_loop 5212855Sgabeblack@google.com if (reset.read() == true) { 5312855Sgabeblack@google.com out_value1.write(0); 5412855Sgabeblack@google.com out_value2.write(0); 5512855Sgabeblack@google.com out_value3.write(0); 5612855Sgabeblack@google.com out_valid1.write(false); 5712855Sgabeblack@google.com out_valid2.write(false); 5812855Sgabeblack@google.com out_valid3.write(false); 5912855Sgabeblack@google.com wait(); 6012855Sgabeblack@google.com } else wait(); 6112855Sgabeblack@google.com 6212855Sgabeblack@google.com // 6312855Sgabeblack@google.com // main loop 6412855Sgabeblack@google.com // 6512855Sgabeblack@google.com while(1) { 6612855Sgabeblack@google.com do { wait(); } while (in_valid == false); 6712855Sgabeblack@google.com 6812855Sgabeblack@google.com //reading inputs 6912855Sgabeblack@google.com tmp1 = in_value1.read(); 7012855Sgabeblack@google.com 7112855Sgabeblack@google.com //easy, just a bunch of different waits 7212855Sgabeblack@google.com out_valid1.write(true); 7312855Sgabeblack@google.com tmpint = tmp1.to_uint(); 7412855Sgabeblack@google.com wait(); 7512855Sgabeblack@google.com switch (tmpint) { 7612855Sgabeblack@google.com case 4 : 7712855Sgabeblack@google.com wait(); 7812855Sgabeblack@google.com wait(); 7912855Sgabeblack@google.com wait(); 8012855Sgabeblack@google.com wait(); 8112855Sgabeblack@google.com out_value1.write(3); 8212855Sgabeblack@google.com wait(); 8312855Sgabeblack@google.com break; 8412855Sgabeblack@google.com case 3 : 8512855Sgabeblack@google.com out_value1.write(2); 8612855Sgabeblack@google.com wait(); 8712855Sgabeblack@google.com wait(); 8812855Sgabeblack@google.com wait(); 8912855Sgabeblack@google.com break; 9012855Sgabeblack@google.com case 2 : 9112855Sgabeblack@google.com out_value1.write(1); 9212855Sgabeblack@google.com wait(); 9312855Sgabeblack@google.com wait(); 9412855Sgabeblack@google.com break; 9512855Sgabeblack@google.com default : 9612855Sgabeblack@google.com out_value1.write(tmp1); 9712855Sgabeblack@google.com wait(); 9812855Sgabeblack@google.com break; 9912855Sgabeblack@google.com }; 10012855Sgabeblack@google.com out_valid1.write(false); 10112855Sgabeblack@google.com wait(); 10212855Sgabeblack@google.com 10312855Sgabeblack@google.com //the first branch should be pushed out in latency due to long delay 10412855Sgabeblack@google.com tmp2 = in_value2.read(); 10512855Sgabeblack@google.com out_valid2.write(true); 10612855Sgabeblack@google.com wait(); 10712855Sgabeblack@google.com tmpint = tmp2.to_uint(); 10812855Sgabeblack@google.com switch (tmpint) { 10912855Sgabeblack@google.com case 0 : 11012855Sgabeblack@google.com case 1 : 11112855Sgabeblack@google.com case 2 : 11212855Sgabeblack@google.com case 3 : 11312855Sgabeblack@google.com //long operation should extent latency 11412855Sgabeblack@google.com out_tmp2 = tmp2*tmp2*tmp2; 11512855Sgabeblack@google.com wait(); 11612855Sgabeblack@google.com break; 11712855Sgabeblack@google.com case 4 : 11812855Sgabeblack@google.com case 5 : 11912855Sgabeblack@google.com case 6 : 12012855Sgabeblack@google.com case 7 : 12112855Sgabeblack@google.com //short operation should not extent latency 12212855Sgabeblack@google.com out_tmp2 = 4; 12312855Sgabeblack@google.com wait(); 12412855Sgabeblack@google.com break; 12512855Sgabeblack@google.com case 8 : 12612855Sgabeblack@google.com case 9 : 12712855Sgabeblack@google.com case 10 : 12812855Sgabeblack@google.com case 11 : 12912855Sgabeblack@google.com //wait statements should extent latency 13012855Sgabeblack@google.com out_tmp2 = 1; 13112855Sgabeblack@google.com wait(); 13212855Sgabeblack@google.com wait(); 13312855Sgabeblack@google.com wait(); 13412855Sgabeblack@google.com break; 13512855Sgabeblack@google.com }; 13612855Sgabeblack@google.com 13712855Sgabeblack@google.com out_value2.write( sc_biguint<4>( out_tmp2 ) ); 13812855Sgabeblack@google.com out_valid2.write(false); 13912855Sgabeblack@google.com wait(); 14012855Sgabeblack@google.com 14112855Sgabeblack@google.com // and just another short case, maybe later to check unbalanched case 14212855Sgabeblack@google.com tmp3 = in_value3.read(); 14312855Sgabeblack@google.com out_valid3.write(true); 14412855Sgabeblack@google.com wait(); 14512855Sgabeblack@google.com tmpint = tmp3.to_uint(); 14612855Sgabeblack@google.com switch (tmpint) { 14712855Sgabeblack@google.com case 0 : 14812855Sgabeblack@google.com case 1 : 14912855Sgabeblack@google.com case 2 : 15012855Sgabeblack@google.com case 3 : 15112855Sgabeblack@google.com //long operation should extent latency 15212855Sgabeblack@google.com out_tmp3 = tmp3*tmp3*tmp3; 15312855Sgabeblack@google.com wait(); 15412855Sgabeblack@google.com break; 15512855Sgabeblack@google.com default : 15612855Sgabeblack@google.com //short operation should not extent latency 15712855Sgabeblack@google.com out_tmp3 = 4; 15812855Sgabeblack@google.com wait(); 15912855Sgabeblack@google.com break; 16012855Sgabeblack@google.com }; 16112855Sgabeblack@google.com out_value3.write( sc_biguint<4>( out_tmp3 ) ); 16212855Sgabeblack@google.com wait(); 16312855Sgabeblack@google.com out_valid3.write(false); 16412855Sgabeblack@google.com } 16512855Sgabeblack@google.com} 16612855Sgabeblack@google.com 16712855Sgabeblack@google.com// EOF 16812855Sgabeblack@google.com 169