dol: initial dol commit
[jump.git] / dol / src / dol / visitor / hdsd / scd / fsm / scd_stsw_base.h
diff --git a/dol/src/dol/visitor/hdsd/scd/fsm/scd_stsw_base.h b/dol/src/dol/visitor/hdsd/scd/fsm/scd_stsw_base.h
new file mode 100644 (file)
index 0000000..8ac5750
--- /dev/null
@@ -0,0 +1,106 @@
+#ifndef SCD_STSW_BASE_H
+#define SCD_STSW_BASE_H
+
+#include "scd_simulator.h"
+#include "fsm/scd_cont_state.h"
+#include "fsm/scd_cont_wrapper_if.h"
+
+
+/* forward declaration */
+class scd_cont_slave_wrapper;
+
+
+/**
+ * Base class for all control slave wrapper states.
+ */
+class scd_stsw_base : public scd_cont_state, public scd_cont_wrapper_if
+{
+public:    
+    /**
+     * Constructor.
+     * \param sim the simulation environment
+     * \param fsm the FSM of this state
+     */
+    scd_stsw_base(scd_simulator& sim, scd_cont_slave_wrapper& fsm);
+
+    virtual ~scd_stsw_base() {}
+
+    /**
+     * Signalizes the state that the slave has been connected to the wrapper.
+     */
+    virtual void set_connected();
+
+    /**
+     * Signalizes the state that a failed command has been received
+     * from the slave.
+     */
+    virtual void set_failed();
+
+    /**
+     * Signalizes the state that a time_nack command has been received
+     * from the slave.
+     */
+    virtual void recv_time_nack() {}
+
+    /**
+     * Signalizes the state that a time_ack command has been received
+     * from the slave.
+     */
+    virtual void recv_time_ack() {}
+
+    /**
+     * Signalizes the state that a term_nack command has been received
+     * from the slave.
+     */
+    virtual void recv_term_nack() {}
+
+    /**
+     * Signalizes the state that a term_ack command has been received
+     * from the slave.
+     */
+    virtual void recv_term_ack() {}
+
+    /* scd_cont_wrapper_if */
+    void send_time_req();
+    void send_time_nack() {}
+    void send_time(const sc_core::sc_time& time);
+    void send_term_req();
+    void send_term_nack() {};
+    void send_term();
+    bool time_req() const;
+    bool time_ack() const;
+    bool term_req() const;
+    bool term_ack() const;
+    bool idle() const;
+    bool done() const;
+
+    /* scd_cont_fsm_if */
+    void set_busy();
+    void set_idle(const sc_core::sc_time& time);
+    void set_done();
+    void set_fail();
+    void process() {};
+    bool active() const;
+    bool busy() const;
+    bool failed() const;
+    bool advance_time() const;
+    const sc_core::sc_time& get_time_step();
+
+protected:
+    scd_cont_slave_wrapper& _fsm;
+    sc_core::sc_time& _time_step;
+    scd_cont_state& _st_init;
+    scd_cont_state& _st_busy;
+    scd_cont_state& _st_idle;
+    scd_cont_state& _st_done;
+    scd_cont_state& _st_time_req;
+    scd_cont_state& _st_time_ack;
+    scd_cont_state& _st_term_req;
+    scd_cont_state& _st_term_ack;
+    scd_cont_state& _st_terminate;
+    scd_cont_state& _st_terminated;
+    scd_cont_state& _st_fail;
+    scd_cont_state& _st_failed;
+};
+
+#endif