21#include <boost/mpl/list.hpp>
22#include <boost/statechart/custom_reaction.hpp>
23#include <boost/statechart/event.hpp>
24#include <boost/statechart/state.hpp>
25#include <boost/statechart/state_machine.hpp>
26#include <boost/statechart/transition.hpp>
30namespace mpl = boost::mpl;
31namespace bsc = boost::statechart;
36struct WReq : bsc::event<WReq> {};
39struct BegReq : bsc::event<BegReq> {};
40struct EndReq : bsc::event<EndReq> {};
62 void InvokeResponsePhaseBeg(
const BegResp&) {
63 if(cb.at(axi::fsm::ResponsePhaseBeg))
64 cb.at(axi::fsm::ResponsePhaseBeg)();
67 if(cb.at(axi::fsm::ResponsePhaseBeg))
68 cb.at(axi::fsm::ResponsePhaseBeg)();
73 bsc::state_machine<AxiProtocolFsm, Idle>::terminate();
75 axi::fsm::protocol_cb cb;
78struct Idle : bsc::state<Idle, AxiProtocolFsm> {
82 if(context<AxiProtocolFsm>().cb.at(axi::fsm::RequestPhaseBeg))
83 context<AxiProtocolFsm>().cb.at(axi::fsm::RequestPhaseBeg)();
85 typedef mpl::list<bsc::transition<BegPartReq, PartialRequest>, bsc::transition<BegReq, Request>, bsc::transition<WReq, ATrans>>
89struct ATrans : bsc::state<ATrans, AxiProtocolFsm> {
90 ATrans(my_context ctx)
92 if(context<AxiProtocolFsm>().cb.at(axi::fsm::WValidE))
93 context<AxiProtocolFsm>().cb.at(axi::fsm::WValidE)();
96 if(context<AxiProtocolFsm>().cb.at(axi::fsm::WReadyE))
97 context<AxiProtocolFsm>().cb.at(axi::fsm::WReadyE)();
99 typedef mpl::list<bsc::transition<BegPartReq, PartialRequest>, bsc::transition<BegReq, Request>> reactions;
102struct PartialRequest : bsc::state<PartialRequest, AxiProtocolFsm> {
103 PartialRequest(my_context ctx)
105 if(context<AxiProtocolFsm>().cb.at(axi::fsm::BegPartReqE))
106 context<AxiProtocolFsm>().cb.at(axi::fsm::BegPartReqE)();
109 if(context<AxiProtocolFsm>().cb.at(axi::fsm::EndPartReqE))
110 context<AxiProtocolFsm>().cb.at(axi::fsm::EndPartReqE)();
112 typedef bsc::transition<EndPartReq, WriteIdle> reactions;
115struct WriteIdle : bsc::simple_state<WriteIdle, AxiProtocolFsm> {
116 typedef mpl::list<bsc::transition<BegPartReq, PartialRequest>, bsc::transition<BegReq, Request>> reactions;
119struct Request : bsc::state<Request, AxiProtocolFsm> {
120 Request(my_context ctx)
122 if(context<AxiProtocolFsm>().cb.at(axi::fsm::BegReqE))
123 context<AxiProtocolFsm>().cb.at(axi::fsm::BegReqE)();
126 if(context<AxiProtocolFsm>().cb.at(axi::fsm::EndReqE))
127 context<AxiProtocolFsm>().cb.at(axi::fsm::EndReqE)();
129 typedef mpl::list<bsc::transition<EndReq, WaitForResponse>,
130 bsc::transition<BegResp, Response, AxiProtocolFsm, &AxiProtocolFsm::InvokeResponsePhaseBeg>,
131 bsc::transition<BegPartResp, PartialResponse, AxiProtocolFsm, &AxiProtocolFsm::InvokeResponsePhaseBeg>>
135struct WaitForResponse : bsc::state<WaitForResponse, AxiProtocolFsm> {
136 WaitForResponse(my_context ctx)
139 if(context<AxiProtocolFsm>().cb.at(axi::fsm::ResponsePhaseBeg))
140 context<AxiProtocolFsm>().cb.at(axi::fsm::ResponsePhaseBeg)();
142 typedef mpl::list<bsc::transition<BegPartResp, PartialResponse>, bsc::transition<BegResp, Response>> reactions;
145struct PartialResponse : bsc::state<PartialResponse, AxiProtocolFsm> {
146 PartialResponse(my_context ctx)
148 if(context<AxiProtocolFsm>().cb.at(axi::fsm::BegPartRespE))
149 context<AxiProtocolFsm>().cb.at(axi::fsm::BegPartRespE)();
152 if(context<AxiProtocolFsm>().cb.at(axi::fsm::EndPartRespE))
153 context<AxiProtocolFsm>().cb.at(axi::fsm::EndPartRespE)();
155 typedef bsc::transition<EndPartResp, ReadIdle> reactions;
158struct ReadIdle : bsc::simple_state<ReadIdle, AxiProtocolFsm> {
159 typedef mpl::list<bsc::transition<BegPartResp, PartialResponse>, bsc::transition<BegResp, Response>> reactions;
162struct Response : bsc::state<Response, AxiProtocolFsm> {
163 Response(my_context ctx)
165 if(context<AxiProtocolFsm>().cb.at(axi::fsm::BegRespE))
166 context<AxiProtocolFsm>().cb.at(axi::fsm::BegRespE)();
169 if(context<AxiProtocolFsm>().cb.at(axi::fsm::EndRespE))
170 context<AxiProtocolFsm>().cb.at(axi::fsm::EndRespE)();
172 typedef mpl::list<bsc::transition<EndResp, Idle>, bsc::transition<EndRespNoAck, WaitAck>> reactions;
175struct WaitAck : bsc::state<WaitAck, AxiProtocolFsm> {
176 WaitAck(my_context ctx)
179 if(context<AxiProtocolFsm>().cb.at(axi::fsm::Ack))
180 context<AxiProtocolFsm>().cb.at(axi::fsm::Ack)();
182 typedef bsc::transition<AckRecv, Idle> reactions;
TLM2.0 components modeling AHB.
special state to map AWREADY/WDATA of SNPS to AXI protocol
the beat of a burst response
the phase between 2 read burst response beats
the request, either the last beat of a write or the address phase of a read
the write response or the last read response (beat)
waiting for ack in case of ACE access
the operation state where the target can do it's stuff
the phase between 2 burst beats, should keep the link locked