b4d0af00d4613bb5092d48d851362f1e5497d05b
[jump.git] / dol / src / dol / visitor / hdsd / scd / fsm / scd_sts_base.cpp
1 #include "fsm/scd_sts_base.h"
2
3 #include "scd_logging.h"
4 #include "scd_exception.h"
5 #include "scd_cont_man_slave.h"
6 #include "scd_command.h"
7 #include "scd_cont_man.h"
8
9
10
11 scd_sts_base::scd_sts_base(scd_simulator& sim, scd_cont_man_slave& fsm):
12     scd_cont_state(sim), _fsm(fsm),
13     _st_init(fsm._st_init), _st_busy(fsm._st_busy), _st_idle(fsm._st_idle),
14     _st_done(fsm._st_done), _st_time_ack(fsm._st_time_ack),
15     _st_time(fsm._st_time), _st_term_ack(fsm._st_term_ack),
16     _st_terminated(fsm._st_terminated), _st_fail(fsm._st_fail),
17     _st_failed(fsm._st_failed),
18     _writer(fsm._writer), _reader(fsm._reader), _connector(fsm._connector)
19 {
20 }
21
22
23 void scd_sts_base::set_failed()
24 {
25     _sim.get_poller().remove_handler(_fsm);
26     _sim.get_chan_man().close();
27     _fsm.set_state(_st_failed);
28 }
29
30
31 void scd_sts_base::recv_time_req()
32 {
33     scd_command* cmd = new scd_command(SCD_CM_CONTROL, SCD_CM_TIME_NACK);
34     _fsm.send_command(cmd);
35 }
36
37
38 void scd_sts_base::recv_time(const sc_core::sc_time& time)
39 {
40     scd_warn("received time message in wrong state");
41 }
42
43
44 void scd_sts_base::recv_term_req()
45 {
46     scd_command* cmd = new scd_command(SCD_CM_CONTROL, SCD_CM_TERM_NACK);
47     _fsm.send_command(cmd);
48 }
49
50
51 void scd_sts_base::recv_term()
52 {
53     scd_warn("received terminate message in wrong state");
54 }
55
56
57 void scd_sts_base::set_fail()
58 {
59     scd_command* cmd = new scd_command(SCD_CM_CONTROL, SCD_CM_FAILED);
60     _fsm.send_command(cmd);
61     _fsm.set_state(_st_fail);
62 }
63
64
65 bool scd_sts_base::active() const { return true; }
66
67
68 bool scd_sts_base::busy() const { return false; }
69
70
71 bool scd_sts_base::failed() const { return false; }
72
73
74 bool scd_sts_base::advance_time() const { return false; }
75
76
77 const sc_core::sc_time& scd_sts_base::get_time_step()
78 {
79     scd_warn("illegal call to get_time_step()");
80     throw scd_exception("illegal call");
81 }