scc  2024.06
SystemC components library
axi_protocol.h
1 /*
2  * Copyright 2020-2022 Arteris IP
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _AXI_CHECKER_AXI_PROTOCOL_H_
18 #define _AXI_CHECKER_AXI_PROTOCOL_H_
19 
20 #include <axi/axi_tlm.h>
21 #include "checker_if.h"
22 #include <tlm/scc/tlm_gp_shared.h>
23 #include <array>
24 #include <unordered_map>
25 #include <deque>
26 
27 namespace axi {
28 namespace checker {
29 
30 class axi_protocol: public checker_if<axi::axi_protocol_types> {
31  using payload_type=axi::axi_protocol_types::tlm_payload_type;
32  using phase_type=axi::axi_protocol_types::tlm_phase_type;
33  constexpr static unsigned umax = std::numeric_limits<unsigned>::max();
34 public:
35  axi_protocol(std::string const& name, unsigned bus_width_in_bytes, unsigned rd_response_timeout, unsigned wr_response_timeout)
36  : name(name)
37  , bw(bus_width_in_bytes)
38  , rd_response_timeout(rd_response_timeout)
39  , wr_response_timeout(wr_response_timeout)
40  {}
41  virtual ~axi_protocol() = default;
42  axi_protocol(const axi_protocol &other) = delete;
43  axi_protocol(axi_protocol &&other) = delete;
44  axi_protocol& operator=(const axi_protocol &other) = delete;
45  axi_protocol& operator=(axi_protocol &&other) = delete;
46  void fw_pre(payload_type const& trans, phase_type const& phase) override;
47  void fw_post(payload_type const& trans, phase_type const& phase, tlm::tlm_sync_enum rstat) override;
48  void bw_pre(payload_type const& trans, phase_type const& phase) override;
49  void bw_post(payload_type const& trans, phase_type const& phase, tlm::tlm_sync_enum rstat) override;
50  std::string const name;
51  unsigned const bw;
52  unsigned const rd_response_timeout;
53  unsigned const wr_response_timeout;
54 private:
55  std::array<phase_type, 3> req_beat;
56  std::array<phase_type, 3> resp_beat;
57  phase_type dataless_req;
58  std::array<unsigned, 3> req_id{{umax, umax, umax}};
59  std::array<unsigned, 3> resp_id{{umax, umax, umax}};
60  unsigned wr_req_beat_count{0};
61  std::array<std::unordered_map<unsigned, std::deque<uintptr_t>>, 3> open_tx_by_id;
62  std::unordered_map<unsigned, std::deque<uintptr_t>> resp_by_id;
63  std::unordered_map<unsigned, unsigned> rd_resp_beat_count;
64  bool check_phase_change(payload_type const& trans, const phase_type &phase);
65  void request_update(payload_type const& trans);
66  void response_update(payload_type const& trans);
67  void check_properties(payload_type const& trans);
68  void check_datawith_settings(payload_type const&trans);
69 };
70 
71 } /* namespace checker */
72 } /* namespace axi */
73 
74 #endif /* _AXI_CHECKER_AXI_PROTOCOL_H_ */
TLM2.0 components modeling AHB.
Definition: axi_initiator.h:30