inlining.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 inlining.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 "inlining.h" 40 41// list of defines 42#define clock(a) wait(a) 43#define intu4(a) sc_biguint<4> a; 44#define vec4(a) sc_lv<4> a; 45#define my_case(a, b, c) switch (a) { \ 46 case 0: \ 47 case 1: \ 48 case 2: \ 49 case 3: \ 50 b = 0; \ 51 break; \ 52 default : \ 53 b = c; \ 54 break; \ 55 }; 56#define my_wait_case(a, b, c) switch (a) { \ 57 case 0: \ 58 case 1: \ 59 case 2: \ 60 case 3: \ 61 b = 0; \ 62 wait(); \ 63 break; \ 64 default : \ 65 b = c; \ 66 wait(); \ 67 break; \ 68 }; 69 70void inlining::entry(){ 71 72 int tmp1; 73 int tmp2; 74 vec4(tmp3); 75 sc_bv<4> tmp4; 76 77 // reset_loop 78 if (reset.read() == true) { 79 out_value1.write(0); 80 out_value2.write(0); 81 out_valid.write(false); 82 clock(1); 83 } else clock(1); 84 85 // 86 // main loop 87 // 88 while(1) { 89 do { wait(); } while (in_valid == false); 90 91 //reading inputs 92 tmp1 = in_value1.read().to_int(); 93 tmp2 = in_value2.read().to_int(); 94 tmp3 = in_value3.read(); 95 tmp4 = in_value4.read(); 96 97 //execution 98 my_wait_case(tmp1, tmp3, tmp4); 99 out_value1.write(tmp3); 100 clock(1); 101 102 my_case(tmp2, tmp3, tmp4); 103 out_value2.write(tmp4); 104 out_valid.write(true); 105 clock(1); 106 out_valid.write(false); 107 108 } 109} 110 111// EOF 112 113