self_reset_bug.cpp revision 12855
12459SN/A/*****************************************************************************
22459SN/A
32459SN/A  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
42459SN/A  more contributor license agreements.  See the NOTICE file distributed
52459SN/A  with this work for additional information regarding copyright ownership.
62459SN/A  Accellera licenses this file to you under the Apache License, Version 2.0
72459SN/A  (the "License"); you may not use this file except in compliance with the
82459SN/A  License.  You may obtain a copy of the License at
92459SN/A
102459SN/A    http://www.apache.org/licenses/LICENSE-2.0
112459SN/A
122459SN/A  Unless required by applicable law or agreed to in writing, software
132459SN/A  distributed under the License is distributed on an "AS IS" BASIS,
142459SN/A  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
152459SN/A  implied.  See the License for the specific language governing
162459SN/A  permissions and limitations under the License.
172459SN/A
182459SN/A *****************************************************************************/
192459SN/A
202459SN/A// self_reset_bug.cpp -- test for
212459SN/A//
222459SN/A//  Original Author: John Aynsley, Doulus
232459SN/A//
242459SN/A// MODIFICATION LOG - modifiers, enter your name, affiliation, date and
252459SN/A//
262459SN/A
272665SN/A//
282665SN/A
292665SN/A#define SC_INCLUDE_DYNAMIC_PROCESSES
302459SN/A
312459SN/A#include <systemc>
326329Sgblack@eecs.umich.edu
336329Sgblack@eecs.umich.eduusing namespace sc_core;
342459SN/Ausing std::cout;
3512109SRekai.GonzalezAlberquilla@arm.comusing std::endl;
368961Sgblack@eecs.umich.edu
376329Sgblack@eecs.umich.edustruct Top: sc_module
386320SN/A{
396329Sgblack@eecs.umich.edu  Top(sc_module_name _name)
402459SN/A  {
412459SN/A    SC_METHOD(target);
422459SN/A      target_handle = sc_get_current_process_handle();
436329Sgblack@eecs.umich.edu
447741Sgblack@eecs.umich.edu    count = 0;
457741Sgblack@eecs.umich.edu    f0 = f1 = f2 = f3 = 0;
469046SAli.Saidi@ARM.com  }
476329Sgblack@eecs.umich.edu
487741Sgblack@eecs.umich.edu  sc_process_handle target_handle;
497741Sgblack@eecs.umich.edu  int count;
507741Sgblack@eecs.umich.edu  int f0, f1, f2, f3;
517741Sgblack@eecs.umich.edu
529920Syasuko.eckert@amd.com  void target()
539920Syasuko.eckert@amd.com  {
549920Syasuko.eckert@amd.com    switch (count)
559920Syasuko.eckert@amd.com    {
5612109SRekai.GonzalezAlberquilla@arm.com      case 0:
5712109SRekai.GonzalezAlberquilla@arm.com        f0 = 1;
5812109SRekai.GonzalezAlberquilla@arm.com        count = 1;
5912109SRekai.GonzalezAlberquilla@arm.com        next_trigger(10, SC_NS);
6012109SRekai.GonzalezAlberquilla@arm.com        break;
6112109SRekai.GonzalezAlberquilla@arm.com
6212109SRekai.GonzalezAlberquilla@arm.com      case 1:
6312109SRekai.GonzalezAlberquilla@arm.com        f1 = 1;
6412109SRekai.GonzalezAlberquilla@arm.com        count = 2;
657741Sgblack@eecs.umich.edu        target_handle.reset();
667741Sgblack@eecs.umich.edu        break;
677741Sgblack@eecs.umich.edu
687741Sgblack@eecs.umich.edu      case 2:
697741Sgblack@eecs.umich.edu        f2 = 1;
707741Sgblack@eecs.umich.edu        count = 3;
716329Sgblack@eecs.umich.edu        target_handle.reset();
727741Sgblack@eecs.umich.edu        break;
737741Sgblack@eecs.umich.edu
747741Sgblack@eecs.umich.edu      case 3:
757741Sgblack@eecs.umich.edu        f3 = 1;
767741Sgblack@eecs.umich.edu        count = 4;
777741Sgblack@eecs.umich.edu        break;
787741Sgblack@eecs.umich.edu    }
796329Sgblack@eecs.umich.edu  }
807741Sgblack@eecs.umich.edu
817741Sgblack@eecs.umich.edu  SC_HAS_PROCESS(Top);
827741Sgblack@eecs.umich.edu};
837741Sgblack@eecs.umich.edu
847741Sgblack@eecs.umich.eduint sc_main(int argc, char* argv[])
859920Syasuko.eckert@amd.com{
866320SN/A  Top top("top");
878342Sksewell@umich.edu
888342Sksewell@umich.edu  sc_start();
892459SN/A
902459SN/A  sc_assert( top.f0 );
912459SN/A  sc_assert( top.f1 );
92  sc_assert( top.f2 );
93  sc_assert( top.f3 );
94
95  cout << endl << "Success" << endl;
96  return 0;
97}
98
99