SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
serial_device_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_SERIAL_DEVICE_EXTENSION_H
15#define SIMICS_SYSTEMC_IFACE_SERIAL_DEVICE_EXTENSION_H
16
19
20namespace simics {
21namespace systemc {
22namespace iface {
23
24//:: pre SerialDeviceExtension {{
25class SerialDeviceExtension : public Extension<SerialDeviceExtension,
26 SerialDeviceInterface> {
27 public:
28 void call(SerialDeviceInterface *device) override {
29 switch (method_.value<Method>()) {
30 case WRITE:
31 method_return_ = device->write(method_input_[0].value<int>());
32 break;
33 case RECEIVE_READY:
34 device->receive_ready();
35 break;
36 }
37 }
38
39 int write(int value) override {
40 method_input_.push_back(value);
41 method_ = WRITE;
42 send();
43 return method_return_.value<int>();
44 }
45 void receive_ready() override {
46 method_ = RECEIVE_READY;
47 send();
48 }
49
50 private:
51 enum Method {
52 WRITE,
53 RECEIVE_READY
54 };
55};
56// }}
57
58} // namespace iface
59} // namespace systemc
60} // namespace simics
61
62#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: serial_device_extension.h:26
void receive_ready() override
Definition: serial_device_extension.h:45
void call(SerialDeviceInterface *device) override
Definition: serial_device_extension.h:28
int write(int value) override
Definition: serial_device_extension.h:39
Definition: serial_device_interface.h:22
T value()
Definition: any_type.h:87
Definition: adapter.h:79