test1.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 test1.cpp -- Test alternations of sc_start(0, SC_NS) and sc_start(1, SC_NS). 23 24 Original Author: Andy Goodrich, Forte Design Systems, 18 August 2006 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 "systemc.h" 40 41SC_MODULE(X) 42{ 43 SC_CTOR(X) 44 { 45 SC_METHOD(comb); 46 sensitive << tweak; 47 SC_CTHREAD(sync, clk.pos()); 48 } 49 void comb() 50 { 51 cout << " X::comb() - " << 52 sc_time_stamp() << " " << 53 tweak.read() << endl; 54 } 55 void sync() 56 { 57 for (;;) 58 { 59 wait(); 60 cout << " X::sync() - " << 61 sc_time_stamp() << " " << 62 tweak.read() << endl; 63 } 64 } 65 sc_in_clk clk; 66 sc_in<bool> tweak; 67}; 68 69#define ACTION(action,descr) \ 70{ \ 71 cout << descr << " - " << \ 72 sc_time_stamp() << " " << \ 73 tweak.read() << endl; \ 74 action ; \ 75 cout << " " << \ 76 sc_time_stamp() << " " << \ 77 tweak.read() << endl; \ 78} 79 80 81int sc_main(int argc, char* argv[]) 82{ 83 sc_clock clock; 84 sc_signal<bool> tweak; 85 X x("x"); 86 x.clk(clock); 87 x.tweak(tweak); 88 89 cout << "Event Start Parameters End Parameters" << endl; 90 cout << "------------- ---------------- --------------\n" << endl; 91 92 ACTION(sc_start(1, SC_NS),"sc_start(1, SC_NS)") 93 ACTION(tweak = !tweak,"~tweak ") 94 ACTION(sc_start(0, SC_NS),"sc_start(0, SC_NS)") 95 ACTION(sc_start(0, SC_NS),"sc_start(0, SC_NS)") 96 ACTION(sc_start(1, SC_NS),"sc_start(1, SC_NS)") 97 ACTION(sc_start(0, SC_NS),"sc_start(0, SC_NS)") 98 ACTION(sc_start(0, SC_NS),"sc_start(0, SC_NS)") 99 100 ACTION(tweak = !tweak,"~tweak ") 101 ACTION(sc_start(0, SC_NS),"sc_start(0, SC_NS)") 102 103 ACTION(tweak = !tweak,"~tweak ") 104 ACTION(sc_start(0, SC_NS),"sc_start(0, SC_NS)") 105 ACTION(sc_start(0, SC_NS),"sc_start(0, SC_NS)") 106 107 ACTION(sc_start(1, SC_NS),"sc_start(1, SC_NS)") 108 ACTION(sc_start(1, SC_NS),"sc_start(1, SC_NS)") 109 ACTION(sc_start(0, SC_NS),"sc_start(0, SC_NS)") 110 ACTION(tweak = !tweak,"~tweak ") 111 ACTION(sc_start(0, SC_NS),"sc_start(0, SC_NS)") 112 ACTION(sc_start(0, SC_NS),"sc_start(0, SC_NS)") 113 114 cerr << "Program completed" << endl; 115 return 0; 116} 117 118