pr-207_blast.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  pr-207_blast.cpp --
23
24  Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
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#include "systemc.h"
39
40
41struct my_pair {
42    char x;
43    char y;
44};
45
46typedef sc_signal<bool>          sig_bool;
47typedef sc_signal<char>          sig_char;
48typedef sc_signal<unsigned char> sig_uchar;
49
50SC_MODULE( pr207 )
51{
52    SC_HAS_PROCESS( pr207 );
53
54    sc_in_clk clk;
55
56    pr207(sc_module_name NAME,
57          sc_clock& CLK,
58
59          const sig_bool& RESET,
60          const sig_bool& START,
61          const sig_char& C1,
62          const sig_char& C2,
63          const sig_uchar& IDX1,
64          const sig_uchar& IDX2,
65                sig_char& D1,
66                sig_char& D2,
67                sig_bool& READY
68          )
69        :
70          reset(RESET),
71          start(START),
72          c1(C1),
73          c2(C2),
74          idx1(IDX1),
75          idx2(IDX2),
76          d1(D1),
77          d2(D2),
78          ready(READY)
79    {
80        clk(CLK);
81		SC_CTHREAD( entry, clk.pos() );
82        reset_signal_is(reset,true);
83    }
84    void entry();
85
86    const sig_bool& reset;
87    const sig_bool& start;
88    const sig_char& c1;
89    const sig_char& c2;
90    const sig_uchar& idx1;
91    const sig_uchar& idx2;
92          sig_char& d1;
93          sig_char& d2;
94          sig_bool& ready;
95
96};
97
98void
99pr207::entry()
100{
101    my_pair pair_array[10];
102
103    ready = true;
104    d1 = 0;
105    d2 = 0;
106    wait();
107    while (true) {
108        do { wait(); } while (start == 0);
109        ready = false;
110        wait();
111        pair_array[idx1.read()].x = c1;
112        pair_array[idx1.read()].y = c2;
113        wait();
114        pair_array[idx2.read()] = pair_array[idx1.read()];
115        wait();
116        char d1_tmp = pair_array[idx2.read()].y;
117        wait();
118        char d2_tmp = pair_array[idx2.read()].x;
119        wait();
120        d1 = d1_tmp;
121        d2 = d2_tmp;
122        ready = true;
123    }
124}
125
126int sc_main(int argc, char* argv[] )
127{
128  return 0;
129}
130