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