112837Sgabeblack@google.com/*
212837Sgabeblack@google.com * Copyright 2018 Google, Inc.
312837Sgabeblack@google.com *
412837Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
512837Sgabeblack@google.com * modification, are permitted provided that the following conditions are
612837Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
712837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
812837Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
912837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1012837Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1112837Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1212837Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1312837Sgabeblack@google.com * this software without specific prior written permission.
1412837Sgabeblack@google.com *
1512837Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1612837Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1712837Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1812837Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1912837Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2012837Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2112837Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2212837Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2312837Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2412837Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2512837Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2612837Sgabeblack@google.com *
2712837Sgabeblack@google.com * Authors: Gabe Black
2812837Sgabeblack@google.com */
2912837Sgabeblack@google.com
3012837Sgabeblack@google.com#ifndef __SYSTEMC_EXT_CORE_SC_MAIN_HH__
3112837Sgabeblack@google.com#define __SYSTEMC_EXT_CORE_SC_MAIN_HH__
3212837Sgabeblack@google.com
3313043Sgabeblack@google.com#include <iostream>
3413043Sgabeblack@google.com
3512860Sgabeblack@google.com#include "../dt/int/sc_nbdefs.hh"
3612860Sgabeblack@google.com#include "sc_time.hh"
3712860Sgabeblack@google.com
3812837Sgabeblack@google.comextern "C" int sc_main(int argc, char *argv[]);
3912837Sgabeblack@google.com
4012837Sgabeblack@google.comnamespace sc_core
4112837Sgabeblack@google.com{
4212837Sgabeblack@google.com    extern "C" int sc_argc();
4312837Sgabeblack@google.com
4412837Sgabeblack@google.com    // The standard version of this function doesn't have these "const"
4512837Sgabeblack@google.com    // qualifiers, but the canonical SystemC implementation does.
4612837Sgabeblack@google.com    extern "C" const char *const *sc_argv();
4712860Sgabeblack@google.com
4812860Sgabeblack@google.com    enum sc_starvation_policy
4912860Sgabeblack@google.com    {
5012860Sgabeblack@google.com        SC_RUN_TO_TIME,
5112860Sgabeblack@google.com        SC_EXIT_ON_STARVATION
5212860Sgabeblack@google.com    };
5312860Sgabeblack@google.com
5412860Sgabeblack@google.com    void sc_start();
5512860Sgabeblack@google.com    void sc_start(const sc_time &, sc_starvation_policy p=SC_RUN_TO_TIME);
5612860Sgabeblack@google.com    static inline void
5712860Sgabeblack@google.com    sc_start(double d, sc_time_unit t, sc_starvation_policy p=SC_RUN_TO_TIME)
5812860Sgabeblack@google.com    {
5912860Sgabeblack@google.com        sc_start(sc_time(d, t), p);
6012860Sgabeblack@google.com    }
6112860Sgabeblack@google.com
6212860Sgabeblack@google.com    void sc_pause();
6312860Sgabeblack@google.com
6412860Sgabeblack@google.com    enum sc_stop_mode
6512860Sgabeblack@google.com    {
6612860Sgabeblack@google.com        SC_STOP_FINISH_DELTA,
6712860Sgabeblack@google.com        SC_STOP_IMMEDIATE,
6812860Sgabeblack@google.com    };
6912860Sgabeblack@google.com
7012860Sgabeblack@google.com    void sc_set_stop_mode(sc_stop_mode mode);
7112860Sgabeblack@google.com    sc_stop_mode sc_get_stop_mode();
7212860Sgabeblack@google.com
7312860Sgabeblack@google.com    void sc_stop();
7412860Sgabeblack@google.com
7512860Sgabeblack@google.com    const sc_time &sc_time_stamp();
7612860Sgabeblack@google.com    sc_dt::uint64 sc_delta_count();
7712860Sgabeblack@google.com    bool sc_is_running();
7812860Sgabeblack@google.com    bool sc_pending_activity_at_current_time();
7912860Sgabeblack@google.com    bool sc_pending_activity_at_future_time();
8012860Sgabeblack@google.com    bool sc_pending_activity();
8112860Sgabeblack@google.com    sc_time sc_time_to_pending_activity();
8212860Sgabeblack@google.com
8312860Sgabeblack@google.com    enum sc_status
8412860Sgabeblack@google.com    {
8512860Sgabeblack@google.com        SC_ELABORATION = 0x1,
8612860Sgabeblack@google.com        SC_BEFORE_END_OF_ELABORATION = 0x02,
8712860Sgabeblack@google.com        SC_END_OF_ELABORATION = 0x04,
8812860Sgabeblack@google.com        SC_START_OF_SIMULATION = 0x08,
8912860Sgabeblack@google.com        SC_RUNNING = 0x10,
9012860Sgabeblack@google.com        SC_PAUSED = 0x20,
9112860Sgabeblack@google.com        SC_STOPPED = 0x40,
9212926Sgabeblack@google.com        SC_END_OF_SIMULATION = 0x80,
9312926Sgabeblack@google.com
9412926Sgabeblack@google.com        // Nonstandard
9512926Sgabeblack@google.com        SC_END_OF_INITIALIZATION = 0x100,
9612926Sgabeblack@google.com        SC_END_OF_UPDATE = 0x400,
9712926Sgabeblack@google.com        SC_BEFORE_TIMESTEP = 0x800,
9812926Sgabeblack@google.com        SC_STATUS_ANY = 0xdff
9912860Sgabeblack@google.com    };
10012860Sgabeblack@google.com
10112860Sgabeblack@google.com    sc_status sc_get_status();
10213043Sgabeblack@google.com
10313043Sgabeblack@google.com    std::ostream &operator << (std::ostream &os, sc_status s);
10412837Sgabeblack@google.com} // namespace sc_core
10512837Sgabeblack@google.com
10612837Sgabeblack@google.com#endif  //__SYSTEMC_EXT_CORE_SC_MAIN_HH__
107