SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
i2c_slave_v2_extension.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_EXTENSION_H
15#define SIMICS_SYSTEMC_IFACE_I2C_SLAVE_V2_EXTENSION_H
16
19
20#include <stdint.h>
21#include <vector>
22
23namespace simics {
24namespace systemc {
25namespace iface {
26
27class I2cSlaveV2Extension : public Extension<I2cSlaveV2Extension,
28 I2cSlaveV2Interface> {
29 public:
30 void call(I2cSlaveV2Interface *device) override {
31 switch (method_.value<Method>()) {
32 case START:
33 device->start(method_input_[0].value<uint8_t>());
34 break;
35 case READ:
36 device->read();
37 break;
38 case WRITE:
39 device->write(method_input_[0].value<uint8_t>());
40 break;
41 case STOP:
42 device->stop();
43 break;
44 case ADDRESSES:
45 method_return_ = device->addresses();
46 break;
47 }
48 }
49
50 void start(uint8_t address) override {
51 method_input_.push_back(address);
52 method_ = START;
53 send();
54 }
55 void read() override {
56 method_ = READ;
57 send();
58 }
59 void write(uint8_t value) override {
60 method_input_.push_back(value);
61 method_ = WRITE;
62 send();
63 }
64 void stop() override {
65 method_ = STOP;
66 send();
67 }
68 std::vector<uint8_t> addresses() override {
69 method_ = ADDRESSES;
70 method_return_error_ = std::vector<uint8_t>();
71 send();
72 return method_return_.value<std::vector<uint8_t> >();
73 }
74
75 private:
76 enum Method {
77 START,
78 READ,
79 WRITE,
80 STOP,
81 ADDRESSES
82 };
83};
84
85} // namespace iface
86} // namespace systemc
87} // namespace simics
88
89#endif
Base class for TLM2 extension, responsible for marshal/unmarshal of a Simics interface.
Definition: extension.h:38
std::vector< types::AnyType > method_input_
Definition: extension.h:116
Definition: i2c_slave_v2_extension.h:28
void write(uint8_t value) override
Definition: i2c_slave_v2_extension.h:59
std::vector< uint8_t > addresses() override
Definition: i2c_slave_v2_extension.h:68
void call(I2cSlaveV2Interface *device) override
Definition: i2c_slave_v2_extension.h:30
void start(uint8_t address) override
Definition: i2c_slave_v2_extension.h:50
void read() override
Definition: i2c_slave_v2_extension.h:55
void stop() override
Definition: i2c_slave_v2_extension.h:64
Definition: i2c_slave_v2_interface.h:24
virtual std::vector< uint8_t > addresses()=0
virtual void write(uint8_t value)=0
virtual void start(uint8_t address)=0
T value()
Definition: any_type.h:87
Definition: adapter.h:79