scc 2026.07
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 "checker_if.h"
21#include <array>
22#include <axi/axi_tlm.h>
23#include <deque>
24#include <tlm/scc/tlm_gp_shared.h>
25#include <unordered_map>
26
27namespace axi {
28namespace checker {
29
30class 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
35public:
36 axi_protocol(std::string const& name, unsigned bus_width_in_bytes, unsigned rd_response_timeout, unsigned wr_response_timeout)
37 : name(name)
38 , bw(bus_width_in_bytes)
39 , rd_response_timeout(rd_response_timeout)
40 , wr_response_timeout(wr_response_timeout) {}
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
55private:
56 std::array<phase_type, 3> req_beat;
57 std::array<phase_type, 3> resp_beat;
58 phase_type dataless_req;
59 std::array<unsigned, 3> req_id{{umax, umax, umax}};
60 std::array<unsigned, 3> resp_id{{umax, umax, umax}};
61 unsigned wr_req_beat_count{0};
62 std::array<std::unordered_map<unsigned, std::deque<uintptr_t>>, 3> open_tx_by_id;
63 std::unordered_map<unsigned, std::deque<uintptr_t>> resp_by_id;
64 std::unordered_map<unsigned, unsigned> rd_resp_beat_count;
65 bool check_phase_change(payload_type const& trans, const phase_type& phase);
66 void request_update(payload_type const& trans);
67 void response_update(payload_type const& trans);
68 void check_properties(payload_type const& trans);
69 void check_datawith_settings(payload_type const& trans);
70};
71
72} /* namespace checker */
73} /* namespace axi */
74
75#endif /* _AXI_CHECKER_AXI_PROTOCOL_H_ */
TLM2.0 components modeling AHB.