if_test.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  if_test.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 "if_test.h"
40
41void if_test::entry(){
42
43  sc_biguint<4>   tmp1;
44  sc_bigint<4>    tmp2;
45  sc_lv<4>        tmp3;
46  sc_bv<4>        tmp4;
47  int             tmp5;
48
49  // reset_loop
50    if (reset.read() == true) {
51      out_value1.write(0);
52      out_value2.write(0);
53      out_value3.write(0);
54      out_value4.write(0);
55      out_value5.write(0);
56      out_valid.write(false);
57      wait();
58    } else wait();
59
60  //
61  // main loop
62  //
63  while(1) {
64    do { wait(); } while  (in_valid == false);
65
66    //reading inputs
67    tmp1 = in_value1.read();
68    tmp2 = in_value2.read();
69    tmp3 = in_value3.read();
70    tmp4 = in_value4.read();
71    tmp5 = in_value5.read();
72
73    //execution
74    if (tmp1 == 4) {
75	out_value1.write(3);
76    } else if (tmp1 == 3) {
77	out_value1.write(2);
78    } else if (tmp1 == 2) {
79	out_value1.write(1);
80    } else {
81	out_value1.write(tmp1);
82    };
83    wait();
84
85    if (tmp2 < 6 ) {
86      out_value2.write(0);
87      wait();
88    } else  {
89      out_value2.write(tmp2);
90      wait();
91    };
92
93    if (tmp3 == "0000" ) {
94      out_value3.write(1);
95      wait();
96      wait();
97    } else {
98      out_value3.write(tmp3);
99      wait();
100    };
101
102    if (tmp4 != "0001" ) {
103      out_value4.write(tmp4);
104    };
105    wait();
106
107    out_value5.write((tmp5>=6)?0:tmp5);
108    wait();
109
110    out_valid.write(true);
111    wait();
112    out_valid.write(false);
113
114  }
115}
116
117// EOF
118
119