C++ Device API Reference Manual
Reference documentation for the Simics C++ Device API.
 
Loading...
Searching...
No Matches
field.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2022 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_FIELD_H
17#define SIMICS_FIELD_H
18
19#include <cstddef>
20#include <cstdint>
21#include <string>
22
25
26namespace simics {
27
28class MappableConfObject;
29class RegisterInterface;
30
38 public FieldInterface {
39 public:
40 // Construct from hierarchical name
41 // @param name begins with the bank name, e.g, "bankA.registerB.fieldC"
42 Field(MappableConfObject *dev_obj, const std::string &name);
43
44 // Construct from parent
45 Field(RegisterInterface *parent, std::string_view field_name);
46
47 // No duplication
48 Field(const Field&) = delete;
49 Field& operator=(const Field&) = delete;
50
51 Field(Field &&rhs);
53
54 virtual ~Field() = default;
55
56 // FieldInterface
57 std::string_view name() const override;
58 const std::string &description() const override;
59 unsigned number_of_bits() const override;
60 void init(std::string_view desc, const bits_type &bits,
61 int8_t offset) override;
62 RegisterInterface *parent() const override;
63
64 uint64_t get() const override;
65
66 void set(uint64_t value) override;
67
68 uint64_t read(uint64_t enabled_bits) override;
69
70 void write(uint64_t value, uint64_t enabled_bits) override;
71
72 size_t offset() const;
73
74 // Set the bits for this field. They are references to the bits
75 // in the corresponding register
76 void set_bits(const bits_type &bits);
77
78 private:
80 void set_iface();
81
82 // The bits are represented by the byte pointer and bits mask see @bits_type
83 // The first bit corresponds to the least significant digit of
84 // the value and the last bit corresponds to the most significant digit
85 bits_type bits_;
86 // The number of total bits of the field
87 std::uint8_t number_of_bits_ {0};
88 // The offset of the first bit in containing register
89 std::int8_t offset_ {-1};
90
91 // The parent interface
92 RegisterInterface *parent_ {nullptr};
93};
94
95} // namespace simics
96
97#endif
Definition: field-interface.h:34
Base class to represent a Simics field.
Definition: field.h:38
unsigned number_of_bits() const override
void init(std::string_view desc, const bits_type &bits, int8_t offset) override
Initialize the field with a description, size in bits and an offset.
RegisterInterface * parent() const override
void write(uint64_t value, uint64_t enabled_bits) override
uint64_t get() const override
size_t offset() const
Field & operator=(const Field &)=delete
Field(RegisterInterface *parent, std::string_view field_name)
const std::string & description() const override
Get the description of the field.
std::string_view name() const override
Get the name of the field without level delimiters.
void set_bits(const bits_type &bits)
Field(Field &&rhs)
uint64_t read(uint64_t enabled_bits) override
Field & operator=(Field &&rhs)
Field(MappableConfObject *dev_obj, const std::string &name)
void set(uint64_t value) override
Field(const Field &)=delete
virtual ~Field()=default
Base class for Bank, Register, and Field classes.
Definition: hierarchical-object.h:44
MappableConfObject * dev_obj() const override
Definition: mappable-conf-object.h:134
Definition: register-interface.h:37
Definition: after-bank.h:33
std::vector< std::pair< uint8_t *, uint8_t > > bits_type
Definition: field-interface.h:30