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