SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
i2c_slave_v2_simics_adapter.h
Go to the documentation of this file.
1/*
2 © 2015 Intel Corporation
3
4 This software and the related documents are Intel copyrighted materials, and
5 your use of them is governed by the express license under which they were
6 provided to you ("License"). Unless the License provides otherwise, you may
7 not use, modify, copy, publish, distribute, disclose or transmit this software
8 or the related documents without Intel's prior written permission.
9
10 This software and the related documents are provided as is, with no express or
11 implied warranties, other than those that are expressly stated in the License.
12*/
13
14#ifndef SIMICS_SYSTEMC_IFACE_I2C_SLAVE_V2_SIMICS_ADAPTER_H
15#define SIMICS_SYSTEMC_IFACE_I2C_SLAVE_V2_SIMICS_ADAPTER_H
16
17#include <simics/devs/i2c.h>
20
21#include <simics/base/attr-value.h>
22
23#include <string>
24#include <vector>
25
26namespace simics {
27namespace systemc {
28namespace iface {
29
30template<typename TBase, typename TInterface = I2cSlaveV2Interface>
31class I2cSlaveV2SimicsAdapter : public SimicsAdapter<i2c_slave_v2_interface_t> {
32 public:
34 : SimicsAdapter<i2c_slave_v2_interface_t>(
35 I2C_SLAVE_V2_INTERFACE, init_iface()) {
36 }
37
38 protected:
39 static void start(conf_object_t *obj, uint8 address) {
40 adapter<TBase, TInterface>(obj)->start(address);
41 }
42 static void read(conf_object_t *obj) {
43 adapter<TBase, TInterface>(obj)->read();
44 }
45 static void write(conf_object_t *obj, uint8 value) {
46 adapter<TBase, TInterface>(obj)->write(value);
47 }
48 static void stop(conf_object_t *obj) {
49 adapter<TBase, TInterface>(obj)->stop();
50 }
51 static attr_value_t addresses(conf_object_t *obj) {
52 std::vector<uint8_t> addresses
53 = adapter<TBase, TInterface>(obj)->addresses();
54 attr_value_t list = SIM_alloc_attr_list(addresses.size());
55 for (unsigned i = 0; i < addresses.size(); ++i)
56 SIM_attr_list_set_item(&list, i,
57 SIM_make_attr_uint64(addresses[i]));
58
59 return list;
60 }
61
62 private:
63 std::vector<std::string> description(conf_object_t *obj,
64 DescriptionType type) override {
65 return descriptionBase<TBase, TInterface>(obj, type);
66 }
67 i2c_slave_v2_interface_t init_iface() {
68 i2c_slave_v2_interface_t iface = {};
69 iface.start = start;
70 iface.read = read;
71 iface.write = write;
72 iface.stop = stop;
73 iface.addresses = addresses;
74 return iface;
75 }
76};
77
78} // namespace iface
79} // namespace systemc
80} // namespace simics
81
82#endif
Definition: i2c_slave_v2_simics_adapter.h:31
I2cSlaveV2SimicsAdapter()
Definition: i2c_slave_v2_simics_adapter.h:33
static void start(conf_object_t *obj, uint8 address)
Definition: i2c_slave_v2_simics_adapter.h:39
static void read(conf_object_t *obj)
Definition: i2c_slave_v2_simics_adapter.h:42
static void write(conf_object_t *obj, uint8 value)
Definition: i2c_slave_v2_simics_adapter.h:45
static void stop(conf_object_t *obj)
Definition: i2c_slave_v2_simics_adapter.h:48
static attr_value_t addresses(conf_object_t *obj)
Definition: i2c_slave_v2_simics_adapter.h:51
Base class for mapping Simics interface to a C++ interface.
Definition: simics_adapter.h:45
DescriptionType
Definition: description_interface.h:23
Definition: adapter.h:79