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 test.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/* 39Hello, 40 41sorry for asking again about the sc_start/sc_cycle problem but... 42 43The following program causes trouble (SystemC V2.0b2): 44*/ 45 46#include "systemc.h" 47 48SC_MODULE(createpulse) 49 { 50 public: 51 sc_in_clk i_clk; 52 private: 53 int trigger1,trigger2; 54 void pulse() 55 { 56 while(true) 57 { 58 wait(); 59 cout << sc_time_stamp() << ": trigger1 : " <<trigger1++ << endl; 60 wait(1,SC_NS); 61 cout << sc_time_stamp() << ": trigger2 : " <<trigger2++ << endl; 62 } 63 } 64 public: 65 SC_CTOR(createpulse) 66 { 67 SC_THREAD(pulse); 68 sensitive << i_clk.pos(); 69 trigger1 = 0; 70 trigger2 = 0; 71 } 72 }; 73 74// createpulse dut("testpulse"); 75 76int sc_main(int argc, char *argv[]) 77 { 78 int i; 79 sc_trace_file *tf; 80 sc_signal<bool> clk1; 81 82 sc_set_time_resolution(1,SC_NS); 83 sc_set_default_time_unit(1,SC_NS); 84 85 // sc_clock dummy( "dummy", 2, SC_NS ); 86 87 createpulse dut("testpulse"); 88 89 dut.i_clk(clk1); // see other posting 90 91 tf=sc_create_vcd_trace_file("vcdtrace"); 92 sc_trace(tf,clk1,"clock"); 93 94 // sc_initialize(); // comment out for sc_start version 95 for(i=0;i<10;i++) 96 { 97 clk1=0; 98 // sc_cycle(5,SC_NS); // change to sc_start 99 sc_start( 5, SC_NS ); 100 clk1=1; 101 // sc_cycle(5,SC_NS); // change to sc_start 102 sc_start( 5, SC_NS ); 103 } 104 105 cout << "finishing at " << sc_time_stamp() << endl; 106 sc_close_vcd_trace_file(tf); 107 108 return(EXIT_SUCCESS); 109 } 110 111/* 112With this programm, the clk1 is generated as can be seen in the trace file. 113But the pulse procedure gets stuck in the second wait function. With SystemC 114V1.x, this worked with replacing sc_cycle with sc_start (and removing the 115sc_initialize), however calling sc_start multiple was an undocumented feature 116and it doesnt work in V2.0b2 (no clk is generated). 117I know that this problem can be solved by creating an own clock generation 118module using wait()s and just a single sc_start in sc_main, but IMHO 119sometimes it is desirable to do it the way shown above. So is this possible 120with SystemC V2.0 ? 121 122Regards, Sven Heithecker 123 124-- 125Sven Heithecker IDA, Hans-Sommer-Str. 66 126Technical University of Braunschweig 38106 Braunschweig 127Tel. +49-(0)531-391-3751(voice)/4587(fax) Germany 128http://www.ida.ing.tu-bs.de/~svenh heithecker@ida.ing.tu-bs.de 129*/ 130