8ac5750834f660b70a6bd2d0e4eed84adaff54d1
[jump.git] / dol / src / dol / visitor / hdsd / scd / fsm / scd_stsw_base.h
1 #ifndef SCD_STSW_BASE_H
2 #define SCD_STSW_BASE_H
3
4 #include "scd_simulator.h"
5 #include "fsm/scd_cont_state.h"
6 #include "fsm/scd_cont_wrapper_if.h"
7
8
9 /* forward declaration */
10 class scd_cont_slave_wrapper;
11
12
13 /**
14  * Base class for all control slave wrapper states.
15  */
16 class scd_stsw_base : public scd_cont_state, public scd_cont_wrapper_if
17 {
18 public:    
19     /**
20      * Constructor.
21      * \param sim the simulation environment
22      * \param fsm the FSM of this state
23      */
24     scd_stsw_base(scd_simulator& sim, scd_cont_slave_wrapper& fsm);
25
26     virtual ~scd_stsw_base() {}
27
28     /**
29      * Signalizes the state that the slave has been connected to the wrapper.
30      */
31     virtual void set_connected();
32
33     /**
34      * Signalizes the state that a failed command has been received
35      * from the slave.
36      */
37     virtual void set_failed();
38
39     /**
40      * Signalizes the state that a time_nack command has been received
41      * from the slave.
42      */
43     virtual void recv_time_nack() {}
44
45     /**
46      * Signalizes the state that a time_ack command has been received
47      * from the slave.
48      */
49     virtual void recv_time_ack() {}
50
51     /**
52      * Signalizes the state that a term_nack command has been received
53      * from the slave.
54      */
55     virtual void recv_term_nack() {}
56
57     /**
58      * Signalizes the state that a term_ack command has been received
59      * from the slave.
60      */
61     virtual void recv_term_ack() {}
62
63     /* scd_cont_wrapper_if */
64     void send_time_req();
65     void send_time_nack() {}
66     void send_time(const sc_core::sc_time& time);
67     void send_term_req();
68     void send_term_nack() {};
69     void send_term();
70     bool time_req() const;
71     bool time_ack() const;
72     bool term_req() const;
73     bool term_ack() const;
74     bool idle() const;
75     bool done() const;
76
77     /* scd_cont_fsm_if */
78     void set_busy();
79     void set_idle(const sc_core::sc_time& time);
80     void set_done();
81     void set_fail();
82     void process() {};
83     bool active() const;
84     bool busy() const;
85     bool failed() const;
86     bool advance_time() const;
87     const sc_core::sc_time& get_time_step();
88
89 protected:
90     scd_cont_slave_wrapper& _fsm;
91     sc_core::sc_time& _time_step;
92     scd_cont_state& _st_init;
93     scd_cont_state& _st_busy;
94     scd_cont_state& _st_idle;
95     scd_cont_state& _st_done;
96     scd_cont_state& _st_time_req;
97     scd_cont_state& _st_time_ack;
98     scd_cont_state& _st_term_req;
99     scd_cont_state& _st_term_ack;
100     scd_cont_state& _st_terminate;
101     scd_cont_state& _st_terminated;
102     scd_cont_state& _st_fail;
103     scd_cont_state& _st_failed;
104 };
105
106 #endif