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