test01.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 test01.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/* 39Martin, 40tis is a very simple test that I used to verify functionality and timing 41with 1.2.1 on NT and I can see how memory consumption grows linearly with 42time. When I ran my implementation I could see the program footprint of 43about 400K during the whole simulation. 44The test runs about 20 seconds and memory footprint grows to about 90MB. If 45you run it longer it starts swapping memory do the disk and goes very 46slowly. So I waited till it grew to 1GB and then killed it because all 47computer does at that point is swapping memory. I guess if you let it run 48long enough it would eventually die. I think this happens only with 49optimized libraries. 50*/ 51 52//-------------------------------------------------------------------------- 53 54#include <systemc.h> 55 56#define sc_ns SC_NS 57#define sc_ms SC_MS 58 59class A : public sc_module 60{ 61 sc_event e1; 62 63 void f() 64 { 65 while(true) 66 { 67 e1.notify(sc_time(5,sc_ns)); 68 wait(e1); 69 70 wait(2,sc_ns); 71 } 72 } 73 public: 74 sc_in_clk clk; 75 SC_CTOR(A) { SC_THREAD(f); sensitive<<clk;} 76}; 77 78class B : public sc_module 79{ 80 sc_event e2, e3; 81 void f() 82 { 83 while(true) 84 { 85 e2.notify(sc_time(1,sc_ns)); 86 wait(e2); 87 88 e3.notify(sc_time(10,sc_ns)); 89 90 wait(e3); 91 } 92 } 93 public: 94 sc_in_clk clk; 95 SC_CTOR(B) { SC_THREAD(f); sensitive<<clk;} 96}; 97 98int sc_main(int argc, char* argv[]) 99{ 100 A a("a"); 101 B b("b"); 102 103 sc_time clk_time(10.0, sc_ns); 104 sc_clock clock("clock",clk_time); 105 a.clk(clock); 106 b.clk(clock); 107 108 sc_start(0, SC_NS); 109 sc_time sim_time(10.,sc_ms); 110 sc_start(sim_time); 111 return 0; 112} 113//-------------------------------------------------------------------------- 114