SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
mii_management_extension.h
Go to the documentation of this file.
1/*
2 © 2021 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_MII_MANAGEMENT_EXTENSION_H
15#define SIMICS_SYSTEMC_IFACE_MII_MANAGEMENT_EXTENSION_H
16
19#include <stdint.h>
20
21namespace simics {
22namespace systemc {
23namespace iface {
24
25class MiiManagementExtension : public Extension<MiiManagementExtension,
26 MiiManagementInterface> {
27 public:
28 void call(MiiManagementInterface *device) override {
29 switch (method_.value<Method>()) {
30 case SERIAL_ACCESS:
32 method_input_[0].value<int>(),
33 method_input_[1].value<int>());
34 break;
35 case READ_REGISTER:
37 method_input_[0].value<int>(),
38 method_input_[1].value<int>());
39 break;
40 case WRITE_REGISTER:
41 device->write_register(method_input_[0].value<int>(),
42 method_input_[1].value<int>(),
43 method_input_[2].value<uint16_t>());
44 break;
45 }
46 }
47
48 int serial_access(int data_in, int clock) override {
49 method_input_.push_back(data_in);
50 method_input_.push_back(clock);
51 method_ = SERIAL_ACCESS;
52 send();
53 return method_return_.value<int>();
54 }
55
56 uint16_t read_register(int phy, int reg) override {
57 method_input_.push_back(phy);
58 method_input_.push_back(reg);
59 method_ = READ_REGISTER;
60 send();
61 return method_return_.value<uint16_t>();
62 }
63
64 void write_register(int phy, int reg, uint16_t value) override {
65 method_input_.push_back(phy);
66 method_input_.push_back(reg);
67 method_input_.push_back(value);
68 method_ = WRITE_REGISTER;
69 send();
70 }
71
72 private:
73 enum Method {
74 SERIAL_ACCESS,
75 READ_REGISTER,
76 WRITE_REGISTER
77 };
78};
79
80} // namespace iface
81} // namespace systemc
82} // namespace simics
83
84#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: mii_management_extension.h:26
int serial_access(int data_in, int clock) override
Definition: mii_management_extension.h:48
uint16_t read_register(int phy, int reg) override
Definition: mii_management_extension.h:56
void write_register(int phy, int reg, uint16_t value) override
Definition: mii_management_extension.h:64
void call(MiiManagementInterface *device) override
Definition: mii_management_extension.h:28
Definition: mii_management_interface.h:23
virtual int serial_access(int data_in, int clock)=0
virtual void write_register(int phy, int reg, uint16_t value)=0
virtual uint16_t read_register(int phy, int reg)=0
T value()
Definition: any_type.h:87
Definition: adapter.h:79