scc 2026.07
SystemC components library
resource_access_if.h
1/*******************************************************************************
2 * Copyright 2016, 2018 MINRES Technologies GmbH
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 _SYSC_RESOURCE_ACCESS_IF_H_
18#define _SYSC_RESOURCE_ACCESS_IF_H_
19
20#include <cstddef>
21#include <cstdint>
22#include <sysc/kernel/sc_time.h>
23
24namespace scc {
31public:
32 virtual ~resource_access_if() = default;
38 virtual char const* full_name() const = 0;
44 virtual std::size_t size() const = 0;
50 virtual void reset() = 0;
61 virtual bool write(const uint8_t* data, std::size_t length, uint64_t offset, sc_core::sc_time& d) = 0;
62 inline bool write(const uint8_t* data, std::size_t length, uint64_t offset = 0) {
63 sc_core::sc_time d;
64 return write(data, length, offset, d);
65 }
76 virtual bool read(uint8_t* data, std::size_t length, uint64_t offset, sc_core::sc_time& d) const = 0;
77 inline bool read(uint8_t* data, std::size_t length, uint64_t offset = 0) const {
78 sc_core::sc_time d;
79 return read(data, length, offset, d);
80 }
81
91 virtual bool write_dbg(const uint8_t* data, std::size_t length, uint64_t offset = 0) = 0;
101 virtual bool read_dbg(uint8_t* data, std::size_t length, uint64_t offset = 0) const = 0;
102};
103
109public:
110 using value_type = resource_access_if;
111 using pointer = value_type*;
112 using const_pointer = const value_type*;
113 using reference = value_type&;
114 using const_reference = const value_type&;
115 using iterator = resource_access_if*;
116 using const_iterator = const resource_access_if*;
117
118 virtual ~indexed_resource_access_if() = default;
125 virtual std::size_t size() = 0;
133 virtual reference operator[](std::size_t idx) noexcept = 0;
141 virtual const_reference operator[](std::size_t idx) const noexcept = 0;
149 virtual reference at(std::size_t idx) = 0;
157 virtual const_reference at(std::size_t idx) const = 0;
158};
159} // namespace scc
160#endif /* _SYSC_RESOURCE_ACCESS_IF_H_ */
interface defining access to an indexed resource e.g. register file
virtual const_reference operator[](std::size_t idx) const noexcept=0
get value at index
virtual reference operator[](std::size_t idx) noexcept=0
get value at index
virtual std::size_t size()=0
get the size of the resource
interface defining access to a resource e.g. a register
virtual std::size_t size() const =0
return the size of the resource
virtual bool read_dbg(uint8_t *data, std::size_t length, uint64_t offset=0) const =0
debug read the data from the resource
virtual void reset()=0
reset the resource
virtual char const * full_name() const =0
return the name of the resource
virtual bool write_dbg(const uint8_t *data, std::size_t length, uint64_t offset=0)=0
debug write to the resource
SCC TLM utilities.