112841Sgabeblack@google.com/*
212841Sgabeblack@google.com * Copyright 2018 Google, Inc.
312841Sgabeblack@google.com *
412841Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
512841Sgabeblack@google.com * modification, are permitted provided that the following conditions are
612841Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
712841Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
812841Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
912841Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1012841Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1112841Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1212841Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1312841Sgabeblack@google.com * this software without specific prior written permission.
1412841Sgabeblack@google.com *
1512841Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1612841Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1712841Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1812841Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1912841Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2012841Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2112841Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2212841Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2312841Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2412841Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2512841Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2612841Sgabeblack@google.com *
2712841Sgabeblack@google.com * Authors: Gabe Black
2812841Sgabeblack@google.com */
2912841Sgabeblack@google.com
3012841Sgabeblack@google.com#ifndef __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__
3112841Sgabeblack@google.com#define __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__
3212841Sgabeblack@google.com
3312841Sgabeblack@google.com#include <iostream>
3412933Sgabeblack@google.com#include <string>
3512933Sgabeblack@google.com#include <vector>
3612841Sgabeblack@google.com
3713044Sgabeblack@google.com#include "../core/sc_event.hh"
3812841Sgabeblack@google.com#include "../core/sc_module.hh" // for sc_gen_unique_name
3912841Sgabeblack@google.com#include "../core/sc_prim.hh"
4013044Sgabeblack@google.com#include "../dt/bit/sc_logic.hh"
4112841Sgabeblack@google.com#include "sc_signal_inout_if.hh"
4212841Sgabeblack@google.com
4312841Sgabeblack@google.comnamespace sc_core
4412841Sgabeblack@google.com{
4512841Sgabeblack@google.com
4612841Sgabeblack@google.comclass sc_port_base;
4712841Sgabeblack@google.com
4813277Sgabeblack@google.com} // namespace sc_core
4913277Sgabeblack@google.com
5013277Sgabeblack@google.comnamespace sc_gem5
5113277Sgabeblack@google.com{
5213277Sgabeblack@google.com
5313277Sgabeblack@google.comclass Process;
5413288Sgabeblack@google.comclass Reset;
5513277Sgabeblack@google.com
5613277Sgabeblack@google.comclass ScSignalBase : public sc_core::sc_prim_channel
5712841Sgabeblack@google.com{
5812841Sgabeblack@google.com  public:
5913277Sgabeblack@google.com    virtual const char *kind() const { return "sc_signal"; }
6013277Sgabeblack@google.com
6113277Sgabeblack@google.com  protected:
6213277Sgabeblack@google.com    ScSignalBase(const char *_name);
6313277Sgabeblack@google.com    virtual ~ScSignalBase();
6413277Sgabeblack@google.com
6513277Sgabeblack@google.com    const sc_core::sc_event &defaultEvent() const;
6613277Sgabeblack@google.com    const sc_core::sc_event &valueChangedEvent() const;
6713277Sgabeblack@google.com
6813277Sgabeblack@google.com    bool event() const;
6913277Sgabeblack@google.com
7013277Sgabeblack@google.com    void _signalChange();
7113277Sgabeblack@google.com
7213277Sgabeblack@google.com    virtual sc_core::sc_writer_policy get_writer_policy() const = 0;
7313277Sgabeblack@google.com
7413303Sgabeblack@google.com    InternalScEvent _valueChangedEvent;
7513277Sgabeblack@google.com    uint64_t _changeStamp;
7613277Sgabeblack@google.com    sc_core::sc_port_base *_gem5WriterPort;
7713277Sgabeblack@google.com};
7813277Sgabeblack@google.com
7913277Sgabeblack@google.comclass ScSignalBaseBinary : public ScSignalBase
8013277Sgabeblack@google.com{
8113277Sgabeblack@google.com  protected:
8213277Sgabeblack@google.com    ScSignalBaseBinary(const char *_name);
8313277Sgabeblack@google.com
8413288Sgabeblack@google.com    mutable std::vector<sc_gem5::Reset *> _resets;
8513288Sgabeblack@google.com    void _signalReset(sc_gem5::Reset *reset);
8613288Sgabeblack@google.com    void _signalReset();
8713288Sgabeblack@google.com
8813277Sgabeblack@google.com    const sc_core::sc_event &posedgeEvent() const;
8913277Sgabeblack@google.com    const sc_core::sc_event &negedgeEvent() const;
9013277Sgabeblack@google.com
9113277Sgabeblack@google.com    bool posedge() const;
9213277Sgabeblack@google.com    bool negedge() const;
9313277Sgabeblack@google.com
9413303Sgabeblack@google.com    InternalScEvent _posedgeEvent;
9513303Sgabeblack@google.com    InternalScEvent _negedgeEvent;
9613277Sgabeblack@google.com
9713277Sgabeblack@google.com    uint64_t _posStamp;
9813277Sgabeblack@google.com    uint64_t _negStamp;
9913495Sgabeblack@google.com
10013495Sgabeblack@google.com    void _signalPosedge();
10113495Sgabeblack@google.com    void _signalNegedge();
10213277Sgabeblack@google.com};
10313277Sgabeblack@google.com
10413277Sgabeblack@google.comtemplate <class T>
10513277Sgabeblack@google.comclass ScSignalBasePicker : public ScSignalBase
10613277Sgabeblack@google.com{
10713277Sgabeblack@google.com  protected:
10813277Sgabeblack@google.com    ScSignalBasePicker(const char *_name) : ScSignalBase(_name) {}
10913277Sgabeblack@google.com};
11013277Sgabeblack@google.com
11113277Sgabeblack@google.comtemplate <>
11213277Sgabeblack@google.comclass ScSignalBasePicker<bool> : public ScSignalBaseBinary
11313277Sgabeblack@google.com{
11413277Sgabeblack@google.com  protected:
11513277Sgabeblack@google.com    ScSignalBasePicker(const char *_name) : ScSignalBaseBinary(_name) {}
11613277Sgabeblack@google.com};
11713277Sgabeblack@google.com
11813277Sgabeblack@google.comtemplate <>
11913277Sgabeblack@google.comclass ScSignalBasePicker<sc_dt::sc_logic> : public ScSignalBaseBinary
12013277Sgabeblack@google.com{
12113277Sgabeblack@google.com  protected:
12213277Sgabeblack@google.com    ScSignalBasePicker(const char *_name) : ScSignalBaseBinary(_name) {}
12313277Sgabeblack@google.com};
12413277Sgabeblack@google.com
12513277Sgabeblack@google.comtemplate <sc_core::sc_writer_policy WRITER_POLICY>
12613277Sgabeblack@google.comclass WriteChecker;
12713277Sgabeblack@google.com
12813277Sgabeblack@google.comtemplate <>
12913277Sgabeblack@google.comclass WriteChecker<sc_core::SC_ONE_WRITER>
13013277Sgabeblack@google.com{
13113277Sgabeblack@google.com  public:
13213277Sgabeblack@google.com    WriteChecker(ScSignalBase *_sig);
13313277Sgabeblack@google.com
13413277Sgabeblack@google.com    void checkPort(sc_core::sc_port_base &port,
13513277Sgabeblack@google.com            std::string iface_type_name, std::string out_name);
13613277Sgabeblack@google.com    void checkWriter();
13713277Sgabeblack@google.com
13813277Sgabeblack@google.com  private:
13913277Sgabeblack@google.com    ScSignalBase *sig;
14013277Sgabeblack@google.com    sc_core::sc_port_base *firstPort;
14113277Sgabeblack@google.com    Process *proc;
14213277Sgabeblack@google.com    uint64_t writeStamp;
14313277Sgabeblack@google.com};
14413277Sgabeblack@google.com
14513277Sgabeblack@google.comtemplate <>
14613277Sgabeblack@google.comclass WriteChecker<sc_core::SC_MANY_WRITERS>
14713277Sgabeblack@google.com{
14813277Sgabeblack@google.com  public:
14913277Sgabeblack@google.com    WriteChecker(ScSignalBase *_sig);
15013277Sgabeblack@google.com
15113277Sgabeblack@google.com    void checkPort(sc_core::sc_port_base &port,
15213277Sgabeblack@google.com            std::string iface_type_name, std::string out_name);
15313277Sgabeblack@google.com    void checkWriter();
15413277Sgabeblack@google.com
15513277Sgabeblack@google.com  private:
15613277Sgabeblack@google.com    ScSignalBase *sig;
15713277Sgabeblack@google.com    Process *proc;
15813277Sgabeblack@google.com    uint64_t writeStamp;
15913277Sgabeblack@google.com};
16013277Sgabeblack@google.com
16113277Sgabeblack@google.comtemplate <class T, sc_core::sc_writer_policy WRITER_POLICY>
16213277Sgabeblack@google.comclass ScSignalBaseT :
16313277Sgabeblack@google.com    public ScSignalBasePicker<T>, public sc_core::sc_signal_inout_if<T>
16413277Sgabeblack@google.com{
16513277Sgabeblack@google.com  public:
16613277Sgabeblack@google.com    ScSignalBaseT(const char *_name) :
16713277Sgabeblack@google.com        ScSignalBasePicker<T>(_name), m_cur_val(T()), m_new_val(T()),
16813277Sgabeblack@google.com        _checker(this)
16912841Sgabeblack@google.com    {}
17013277Sgabeblack@google.com    ScSignalBaseT(const char *_name, const T &initial_value) :
17113277Sgabeblack@google.com        ScSignalBasePicker<T>(_name), m_cur_val(initial_value),
17213277Sgabeblack@google.com        m_new_val(initial_value), _checker(this)
17312841Sgabeblack@google.com    {}
17413277Sgabeblack@google.com    virtual ~ScSignalBaseT() {}
17512841Sgabeblack@google.com
17612841Sgabeblack@google.com    virtual void
17713277Sgabeblack@google.com    register_port(sc_core::sc_port_base &port, const char *iface_type_name)
17812841Sgabeblack@google.com    {
17913277Sgabeblack@google.com#       if !defined(SC_NO_WRITE_CHECK)
18013277Sgabeblack@google.com        {
18113277Sgabeblack@google.com            _checker.checkPort(port, iface_type_name,
18213277Sgabeblack@google.com                typeid(sc_core::sc_signal_inout_if<T>).name());
18313274Sgabeblack@google.com        }
18413277Sgabeblack@google.com#       endif
18512841Sgabeblack@google.com    }
18612841Sgabeblack@google.com
18713044Sgabeblack@google.com    virtual const T &read() const { return m_cur_val; }
18813044Sgabeblack@google.com    operator const T&() const { return read(); }
18912841Sgabeblack@google.com
19012841Sgabeblack@google.com    virtual void
19113044Sgabeblack@google.com    write(const T &t)
19212841Sgabeblack@google.com    {
19313277Sgabeblack@google.com#       if !defined(SC_NO_WRITE_CHECK)
19413277Sgabeblack@google.com        {
19513277Sgabeblack@google.com            _checker.checkWriter();
19613277Sgabeblack@google.com        }
19713277Sgabeblack@google.com#       endif
19813044Sgabeblack@google.com        m_new_val = t;
19913044Sgabeblack@google.com        bool changed = !(m_cur_val == m_new_val);
20013044Sgabeblack@google.com        if (changed)
20113277Sgabeblack@google.com            this->request_update();
20212841Sgabeblack@google.com    }
20312841Sgabeblack@google.com
20413277Sgabeblack@google.com    virtual const sc_core::sc_event &
20512841Sgabeblack@google.com    default_event() const
20612841Sgabeblack@google.com    {
20713277Sgabeblack@google.com        return ScSignalBase::defaultEvent();
20812841Sgabeblack@google.com    }
20913277Sgabeblack@google.com
21013277Sgabeblack@google.com    virtual const sc_core::sc_event &
21112841Sgabeblack@google.com    value_changed_event() const
21212841Sgabeblack@google.com    {
21313277Sgabeblack@google.com        return ScSignalBase::valueChangedEvent();
21412841Sgabeblack@google.com    }
21512841Sgabeblack@google.com
21613044Sgabeblack@google.com    virtual void print(std::ostream &os=std::cout) const { os << m_cur_val; }
21712841Sgabeblack@google.com    virtual void
21813044Sgabeblack@google.com    dump(std::ostream &os=std::cout) const
21912841Sgabeblack@google.com    {
22013277Sgabeblack@google.com        os << "     name = " << this->name() << ::std::endl;
22113044Sgabeblack@google.com        os << "    value = " << m_cur_val << ::std::endl;
22213044Sgabeblack@google.com        os << "new value = " << m_new_val << ::std::endl;
22312841Sgabeblack@google.com    }
22413277Sgabeblack@google.com
22513277Sgabeblack@google.com    virtual bool event() const { return ScSignalBase::event(); }
22613277Sgabeblack@google.com
22713277Sgabeblack@google.com    virtual sc_core::sc_writer_policy
22813277Sgabeblack@google.com    get_writer_policy() const
22913277Sgabeblack@google.com    {
23013277Sgabeblack@google.com        return WRITER_POLICY;
23113277Sgabeblack@google.com    }
23212841Sgabeblack@google.com
23312841Sgabeblack@google.com  protected:
23412945Sgabeblack@google.com    // These members which store the current and future value of the signal
23512945Sgabeblack@google.com    // are not specified in the standard but are referred to directly by one
23612945Sgabeblack@google.com    // of the tests.
23712945Sgabeblack@google.com    T m_cur_val;
23812945Sgabeblack@google.com    T m_new_val;
23912945Sgabeblack@google.com
24013277Sgabeblack@google.com    WriteChecker<WRITER_POLICY> _checker;
24113277Sgabeblack@google.com};
24213277Sgabeblack@google.com
24313277Sgabeblack@google.comtemplate <typename T, sc_core::sc_writer_policy WRITER_POLICY>
24413277Sgabeblack@google.comclass ScSignalBinary : public ScSignalBaseT<T, WRITER_POLICY>
24513277Sgabeblack@google.com{
24613277Sgabeblack@google.com  public:
24713277Sgabeblack@google.com    ScSignalBinary(const char *_name) : ScSignalBaseT<T, WRITER_POLICY>(_name)
24813277Sgabeblack@google.com    {}
24913277Sgabeblack@google.com    ScSignalBinary(const char *_name, const T& initial_value) :
25013277Sgabeblack@google.com        ScSignalBaseT<T, WRITER_POLICY>(_name, initial_value)
25113277Sgabeblack@google.com    {}
25213277Sgabeblack@google.com
25313277Sgabeblack@google.com    const sc_core::sc_event &
25413277Sgabeblack@google.com    posedge_event() const
25513277Sgabeblack@google.com    {
25613277Sgabeblack@google.com        return ScSignalBaseBinary::posedgeEvent();
25713277Sgabeblack@google.com    }
25813277Sgabeblack@google.com    const sc_core::sc_event &
25913277Sgabeblack@google.com    negedge_event() const
26013277Sgabeblack@google.com    {
26113277Sgabeblack@google.com        return ScSignalBaseBinary::negedgeEvent();
26213277Sgabeblack@google.com    }
26313277Sgabeblack@google.com
26413277Sgabeblack@google.com    bool posedge() const { return ScSignalBaseBinary::posedge(); }
26513277Sgabeblack@google.com    bool negedge() const { return ScSignalBaseBinary::negedge(); }
26613277Sgabeblack@google.com};
26713277Sgabeblack@google.com
26813277Sgabeblack@google.com} // namespace sc_gem5
26913277Sgabeblack@google.com
27013277Sgabeblack@google.comnamespace sc_core
27113277Sgabeblack@google.com{
27213277Sgabeblack@google.com
27313277Sgabeblack@google.comtemplate <class T, sc_writer_policy WRITER_POLICY=SC_ONE_WRITER>
27413277Sgabeblack@google.comclass sc_signal : public sc_gem5::ScSignalBaseT<T, WRITER_POLICY>
27513277Sgabeblack@google.com{
27613277Sgabeblack@google.com  public:
27713277Sgabeblack@google.com    sc_signal() : sc_gem5::ScSignalBaseT<T, WRITER_POLICY>(
27813277Sgabeblack@google.com            sc_gen_unique_name("signal"))
27913277Sgabeblack@google.com    {}
28013277Sgabeblack@google.com    explicit sc_signal(const char *name) :
28113277Sgabeblack@google.com        sc_gem5::ScSignalBaseT<T, WRITER_POLICY>(name)
28213277Sgabeblack@google.com    {}
28313277Sgabeblack@google.com    explicit sc_signal(const char *name, const T &initial_value) :
28413277Sgabeblack@google.com        sc_gem5::ScSignalBaseT<T, WRITER_POLICY>(name, initial_value)
28513277Sgabeblack@google.com    {}
28613277Sgabeblack@google.com    virtual ~sc_signal() {}
28713277Sgabeblack@google.com
28813277Sgabeblack@google.com    sc_signal<T, WRITER_POLICY> &
28913277Sgabeblack@google.com    operator = (const T &t)
29013277Sgabeblack@google.com    {
29113277Sgabeblack@google.com        this->write(t);
29213277Sgabeblack@google.com        return *this;
29313277Sgabeblack@google.com    }
29413277Sgabeblack@google.com    sc_signal<T, WRITER_POLICY> &
29513277Sgabeblack@google.com    operator = (const sc_signal<T, WRITER_POLICY> &s)
29613277Sgabeblack@google.com    {
29713277Sgabeblack@google.com        this->write(s.read());
29813277Sgabeblack@google.com        return *this;
29913277Sgabeblack@google.com    }
30013277Sgabeblack@google.com
30113277Sgabeblack@google.com  protected:
30213277Sgabeblack@google.com    virtual void
30313277Sgabeblack@google.com    update()
30413277Sgabeblack@google.com    {
30513277Sgabeblack@google.com        if (this->m_new_val == this->m_cur_val)
30613277Sgabeblack@google.com            return;
30713277Sgabeblack@google.com
30813277Sgabeblack@google.com        this->m_cur_val = this->m_new_val;
30913277Sgabeblack@google.com        this->_signalChange();
31013277Sgabeblack@google.com    }
31113277Sgabeblack@google.com
31212841Sgabeblack@google.com  private:
31312841Sgabeblack@google.com    // Disabled
31413277Sgabeblack@google.com    sc_signal(const sc_signal<T, WRITER_POLICY> &);
31512841Sgabeblack@google.com};
31612841Sgabeblack@google.com
31712841Sgabeblack@google.comtemplate <class T, sc_writer_policy WRITER_POLICY>
31812841Sgabeblack@google.cominline std::ostream &
31913142Sgabeblack@google.comoperator << (std::ostream &os, const sc_signal<T, WRITER_POLICY> &s)
32012841Sgabeblack@google.com{
32113142Sgabeblack@google.com    os << s.read();
32212841Sgabeblack@google.com    return os;
32312841Sgabeblack@google.com}
32412841Sgabeblack@google.com
32512841Sgabeblack@google.comtemplate <sc_writer_policy WRITER_POLICY>
32612841Sgabeblack@google.comclass sc_signal<bool, WRITER_POLICY> :
32713277Sgabeblack@google.com    public sc_gem5::ScSignalBinary<bool, WRITER_POLICY>
32812841Sgabeblack@google.com{
32912841Sgabeblack@google.com  public:
33013277Sgabeblack@google.com    sc_signal() :
33113277Sgabeblack@google.com        sc_gem5::ScSignalBinary<bool, WRITER_POLICY>(
33213277Sgabeblack@google.com                sc_gen_unique_name("signal"))
33313044Sgabeblack@google.com    {}
33413044Sgabeblack@google.com    explicit sc_signal(const char *name) :
33513277Sgabeblack@google.com        sc_gem5::ScSignalBinary<bool, WRITER_POLICY>(name)
33613044Sgabeblack@google.com    {}
33712912Sgabeblack@google.com    explicit sc_signal(const char *name, const bool &initial_value) :
33813277Sgabeblack@google.com        sc_gem5::ScSignalBinary<bool, WRITER_POLICY>(name, initial_value)
33913044Sgabeblack@google.com    {}
34013044Sgabeblack@google.com    virtual ~sc_signal() {}
34112841Sgabeblack@google.com
34212841Sgabeblack@google.com    sc_signal<bool, WRITER_POLICY> &
34313044Sgabeblack@google.com    operator = (const bool &b)
34412841Sgabeblack@google.com    {
34513277Sgabeblack@google.com        this->write(b);
34612841Sgabeblack@google.com        return *this;
34712841Sgabeblack@google.com    }
34812841Sgabeblack@google.com    sc_signal<bool, WRITER_POLICY> &
34913044Sgabeblack@google.com    operator = (const sc_signal<bool, WRITER_POLICY> &s)
35012841Sgabeblack@google.com    {
35113277Sgabeblack@google.com        this->write(s.read());
35212841Sgabeblack@google.com        return *this;
35312841Sgabeblack@google.com    }
35412841Sgabeblack@google.com
35512841Sgabeblack@google.com  protected:
35612841Sgabeblack@google.com    virtual void
35712841Sgabeblack@google.com    update()
35812841Sgabeblack@google.com    {
35913277Sgabeblack@google.com        if (this->m_new_val == this->m_cur_val)
36013044Sgabeblack@google.com            return;
36113044Sgabeblack@google.com
36213277Sgabeblack@google.com        this->m_cur_val = this->m_new_val;
36313495Sgabeblack@google.com        this->_signalChange();
36413495Sgabeblack@google.com    }
36513495Sgabeblack@google.com
36613495Sgabeblack@google.com    void
36713495Sgabeblack@google.com    _signalChange()
36813495Sgabeblack@google.com    {
36913495Sgabeblack@google.com        sc_gem5::ScSignalBinary<bool, WRITER_POLICY>::_signalChange();
37013288Sgabeblack@google.com        this->_signalReset();
37113495Sgabeblack@google.com        if (this->m_cur_val)
37213495Sgabeblack@google.com            this->_signalPosedge();
37313495Sgabeblack@google.com        else
37413495Sgabeblack@google.com            this->_signalNegedge();
37512841Sgabeblack@google.com    }
37612841Sgabeblack@google.com
37712841Sgabeblack@google.com  private:
37813288Sgabeblack@google.com    bool
37913288Sgabeblack@google.com    _addReset(sc_gem5::Reset *reset) const
38013288Sgabeblack@google.com    {
38113288Sgabeblack@google.com        this->_resets.push_back(reset);
38213288Sgabeblack@google.com        return true;
38313288Sgabeblack@google.com    }
38413288Sgabeblack@google.com
38512841Sgabeblack@google.com    // Disabled
38613277Sgabeblack@google.com    sc_signal(const sc_signal<bool, WRITER_POLICY> &);
38712841Sgabeblack@google.com};
38812841Sgabeblack@google.com
38912841Sgabeblack@google.comtemplate <sc_writer_policy WRITER_POLICY>
39012841Sgabeblack@google.comclass sc_signal<sc_dt::sc_logic, WRITER_POLICY> :
39113277Sgabeblack@google.com    public sc_gem5::ScSignalBinary<sc_dt::sc_logic, WRITER_POLICY>
39212841Sgabeblack@google.com{
39312841Sgabeblack@google.com  public:
39413277Sgabeblack@google.com    sc_signal() :
39513277Sgabeblack@google.com        sc_gem5::ScSignalBinary<sc_dt::sc_logic, WRITER_POLICY>(
39613277Sgabeblack@google.com                sc_gen_unique_name("signal"))
39713044Sgabeblack@google.com    {}
39813044Sgabeblack@google.com    explicit sc_signal(const char *name) :
39913277Sgabeblack@google.com        sc_gem5::ScSignalBinary<sc_dt::sc_logic, WRITER_POLICY>(name)
40013044Sgabeblack@google.com    {}
40112912Sgabeblack@google.com    explicit sc_signal(const char *name,
40212912Sgabeblack@google.com            const sc_dt::sc_logic &initial_value) :
40313277Sgabeblack@google.com        sc_gem5::ScSignalBinary<sc_dt::sc_logic, WRITER_POLICY>(
40413277Sgabeblack@google.com                name, initial_value)
40513044Sgabeblack@google.com    {}
40613044Sgabeblack@google.com    virtual ~sc_signal() {}
40712841Sgabeblack@google.com
40812841Sgabeblack@google.com    sc_signal<sc_dt::sc_logic, WRITER_POLICY> &
40913044Sgabeblack@google.com    operator = (const sc_dt::sc_logic &l)
41012841Sgabeblack@google.com    {
41113277Sgabeblack@google.com        this->write(l);
41212841Sgabeblack@google.com        return *this;
41312841Sgabeblack@google.com    }
41412841Sgabeblack@google.com    sc_signal<sc_dt::sc_logic, WRITER_POLICY> &
41513044Sgabeblack@google.com    operator = (const sc_signal<sc_dt::sc_logic, WRITER_POLICY> &s)
41612841Sgabeblack@google.com    {
41713277Sgabeblack@google.com        this->write(s.read());
41812841Sgabeblack@google.com        return *this;
41912841Sgabeblack@google.com    }
42012841Sgabeblack@google.com
42112841Sgabeblack@google.com  protected:
42212841Sgabeblack@google.com    virtual void
42312841Sgabeblack@google.com    update()
42412841Sgabeblack@google.com    {
42513277Sgabeblack@google.com        if (this->m_new_val == this->m_cur_val)
42613044Sgabeblack@google.com            return;
42713044Sgabeblack@google.com
42813277Sgabeblack@google.com        this->m_cur_val = this->m_new_val;
42913277Sgabeblack@google.com        this->_signalChange();
43013495Sgabeblack@google.com    }
43113495Sgabeblack@google.com
43213495Sgabeblack@google.com    void
43313495Sgabeblack@google.com    _signalChange()
43413495Sgabeblack@google.com    {
43513495Sgabeblack@google.com        sc_gem5::ScSignalBinary<sc_dt::sc_logic, WRITER_POLICY>::
43613495Sgabeblack@google.com            _signalChange();
43713495Sgabeblack@google.com        if (this->m_cur_val == sc_dt::SC_LOGIC_1)
43813495Sgabeblack@google.com            this->_signalPosedge();
43913495Sgabeblack@google.com        else if (this->m_cur_val == sc_dt::SC_LOGIC_0)
44013495Sgabeblack@google.com            this->_signalNegedge();
44113205Sgabeblack@google.com    }
44213205Sgabeblack@google.com
44312841Sgabeblack@google.com  private:
44412841Sgabeblack@google.com    // Disabled
44513277Sgabeblack@google.com    sc_signal(const sc_signal<sc_dt::sc_logic, WRITER_POLICY> &);
44612841Sgabeblack@google.com};
44712841Sgabeblack@google.com
44812841Sgabeblack@google.com} // namespace sc_core
44912841Sgabeblack@google.com
45012841Sgabeblack@google.com#endif  //__SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__
451