/******************************************************************************
    Copyright (c) 1998-2000 CoWare, Inc.    ALL RIGHTS RESERVED

The following code is derived, directly or indirectly, from the SystemC
source code released by Synopsys, Inc Copyright (c) 1996-2001, Synopsys,
Inc., CoWare, Inc., Frontier Design, Inc. and others. All Rights reserved.
The contents of this file are subject to the restrictions and limitations
set forth in the SystemC Open Source License Version 2.0 (the "License");
You may not use this file except in compliance with such restrictions and
limitations. You may obtain instructions on how to receive a copy of the
License at http://www.systemc.org/.  Software distributed by Contributors
under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License."

******************************************************************************/

/****************************************************************
    sc_slave :  class of refinable slave port.  Does not have 
      read or write property unlike inslave/outslave/inoutslave

    Authors : Harish Sarin, CoWare Inc. (harish@coware.com)
	    : Cesar Quiroz, CoWare Inc. (cesar@coware.com)
            : Vijay Kumar,  CoWare Inc. (vijay@coware.com)

    MODIFICATION LOG 
    Modifier Name & Affiliation:
    Description of Modification:

****************************************************************/

#ifndef SC_SLAVE_H_
#define SC_SLAVE_H_


#include "sc_pport_b.h"


///////////////////////////////////////////////////////////////
template<class T=int, class Protocol = sc_abstract<T> >
class sc_slave :public sc_pport_b ,public  Protocol::sc_slave_protocol {
 public:

	sc_slave(char *NAME=0) : sc_object(NAME), sc_pport_b(NAME) { set_port(this);}
	virtual ~sc_slave() { }
	
	BIND_STATUS operator () (sc_slave<T,Protocol>& p) {	return bind(p); }
	BIND_STATUS operator () (sc_link_mp<T>& link) {	return bind(link); }
	

  	virtual void add_procs(sc_async_process_handle h) { p_add_procs(h);}
	typename Protocol::sc_slave_protocol* operator -> () { return this; }
        virtual const char * getProtocolType() {
           return typeid(Protocol).name();
        }
};


///////////////////////////////////////////////////////////////
template<class T=int, class Protocol = sc_abstract<T> >
class sc_inoutslave :public sc_pport_b,public Protocol::sc_inouts_protocol  {
 public:

	sc_inoutslave(char *NAME=0) : sc_object(NAME), sc_pport_b(NAME) { set_port(this); }
	virtual ~sc_inoutslave() { }
	
	BIND_STATUS operator () (sc_inoutslave<T,Protocol>& p) { return bind(p); }
	BIND_STATUS operator () (sc_link_mp<T>& link) { return bind(link); }
	
	operator T () { return read(); }

	sc_inoutslave<T,Protocol>& operator = (const T& val) {
		write(val);
		return *this;
	}
	typename Protocol::sc_inouts_protocol* operator -> () { return this; }


 	virtual void add_procs(sc_async_process_handle h) { p_add_procs(h);}


        virtual const char * getProtocolType() {
           return typeid(Protocol).name();
        }
};


///////////////////////////////////////////////////////////////
template<class T=int, class Protocol = sc_abstract<T> >
class sc_inslave :public sc_pport_b ,public Protocol::sc_ins_protocol {
 public:

	sc_inslave(char *NAME=0) : sc_object(NAME), sc_pport_b(NAME) { set_port(this); }
	virtual ~sc_inslave() { }
	
	BIND_STATUS operator () (sc_inoutslave<T,Protocol>& p) { return bind(p); }
	BIND_STATUS operator () (sc_inslave<T,Protocol>& p) { return bind(p);	}
	BIND_STATUS operator () (sc_link_mp<T>& link) {	return bind(link); }
	
	operator T () { return read(); }
  	virtual void add_procs(sc_async_process_handle h) { p_add_procs(h);}

	typename Protocol::sc_ins_protocol* operator -> () { return this; }
        virtual const char * getProtocolType() {
           return typeid(Protocol).name();
        }
};

///////////////////////////////////////////////////////////////
template<class T=int, class Protocol = sc_abstract<T> >
class sc_outslave :public sc_pport_b ,public Protocol::sc_outs_protocol{
 public:

	sc_outslave(char *NAME=0) : sc_object(NAME), sc_pport_b(NAME) { set_port(this); }
	virtual ~sc_outslave() { }
	
	BIND_STATUS operator () (sc_inoutslave<T,Protocol>& p) { return bind(p); }
	BIND_STATUS operator () (sc_outslave<T,Protocol>& p) { return bind(p); }
	BIND_STATUS operator () (sc_link_mp<T>& link) {	return bind(link); }
 	virtual void add_procs(sc_async_process_handle h) { p_add_procs(h);}

	sc_outslave<T,Protocol>& operator = (const T& val) {
		write(val);
		return *this;
	}

	typename Protocol::sc_outs_protocol* operator -> () { return this; }
        virtual const char *getProtocolType() {
           return typeid(Protocol).name();
        }
};

#endif
