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 test18.cpp -- Test that time cannot go backwards in simulator 23 24 Original Author: Andy Goodrich, Forte Design Systems, 2006-05-03 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// $Log: test18.cpp,v $ 39// Revision 1.1.1.1 2006/12/15 20:26:06 acg 40// systemc_tests-2.3 41// 42// Revision 1.1 2006/05/03 19:37:10 acg 43// Andy Goodrich: new test to check that time will not run backward if a 44// negative value is given to sc_event::notify() 45// 46 47#include "systemc.h" 48 49SC_MODULE(DUT) 50{ 51 SC_CTOR(DUT) 52 { 53 SC_METHOD(catcher); 54 sensitive << m_event; 55 dont_initialize(); 56 SC_CTHREAD(thrower,m_clk.pos()); 57 } 58 void catcher() 59 { 60 cout << sc_time_stamp() << " caught" << endl; 61 } 62 void thrower() 63 { 64 sc_time minus_four(-4.0, SC_NS); 65 wait(7); 66 for (;;) 67 { 68 wait(); 69 cout << sc_time_stamp() << " throwing" << endl; 70 m_event.notify(minus_four); 71 } 72 } 73 sc_in<bool> m_clk; 74 sc_event m_event; 75}; 76 77int sc_main(int argc, char* argv[]) 78{ 79 sc_clock clock; 80 DUT dut("dut"); 81 82 dut.m_clk(clock); 83 84 sc_start(11, SC_NS); 85 86 cout << "Program completed" << endl; 87 return 0; 88} 89