scc  2022.4.0
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 
24 namespace scc {
31 public:
32  virtual ~resource_access_if() = default;
39  virtual std::size_t size() const = 0;
45  virtual void reset() = 0;
56  virtual bool write(const uint8_t* data, std::size_t length, uint64_t offset, sc_core::sc_time& d) = 0;
57  inline bool write(const uint8_t* data, std::size_t length, uint64_t offset = 0) {
58  sc_core::sc_time d;
59  return write(data, length, offset, d);
60  }
71  virtual bool read(uint8_t* data, std::size_t length, uint64_t offset, sc_core::sc_time& d) const = 0;
72  inline bool read(uint8_t* data, std::size_t length, uint64_t offset = 0) const {
73  sc_core::sc_time d;
74  return read(data, length, offset, d);
75  }
76 
86  virtual bool write_dbg(const uint8_t* data, std::size_t length, uint64_t offset = 0) = 0;
96  virtual bool read_dbg(uint8_t* data, std::size_t length, uint64_t offset = 0) const = 0;
97 };
104 public:
106  using pointer = value_type*;
107  using const_pointer = const value_type*;
108  using reference = value_type&;
109  using const_reference = const value_type&;
110  using iterator = resource_access_if*;
111  using const_iterator = const resource_access_if*;
112 
113  virtual ~indexed_resource_access_if() = default;
120  virtual std::size_t size() = 0;
128  virtual reference operator[](std::size_t idx) noexcept = 0;
136  virtual const_reference operator[](std::size_t idx) const noexcept = 0;
144  virtual reference at(std::size_t idx) = 0;
152  virtual const_reference at(std::size_t idx) const = 0;
153 };
154 } // namespace scc
155 #endif /* _SYSC_RESOURCE_ACCESS_IF_H_ */
interface defining access to an indexed resource e.g. register file
virtual std::size_t size()=0
get the size of the resource
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
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 bool write_dbg(const uint8_t *data, std::size_t length, uint64_t offset=0)=0
debug write to the resource
SCC SystemC utilities.