C++ Device API Reference Manual
Reference documentation for the Simics C++ Device API.
 
Loading...
Searching...
No Matches
hierarchical-object.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_HIERARCHICAL_OBJECT_H
17#define SIMICS_HIERARCHICAL_OBJECT_H
18
19#include <cstdint>
20#include <string>
21#include <string_view>
22
23#include "simics/conf-object.h" // ConfObjectRef
26
27namespace simics {
28
29class FieldInterface;
30class RegisterInterface;
31class BankInterface;
32
34constexpr static const char &SEPARATOR = '.';
35
45 public:
52
54
55 // No duplication
58
61
63 static bool is_valid_hierarchical_name(std::string_view name);
64
67 static std::string_view::size_type level_of_hierarchical_name(
68 std::string_view name);
69
71 static const uint64_t Register_Read {1};
72 static const uint64_t Register_Write {2};
73 static const uint64_t Register_Read_Exception {3};
74 static const uint64_t Register_Write_Exception {4};
75
77 template<typename T> T *dev_ptr() {
78 static_assert(std::is_base_of<MappableConfObject, T>::value,
79 "T needs be a MappableConfObject");
80 return dynamic_cast<T *>(dev_obj());
81 }
82
83 // see HierarchicalObjectInterface
84 const std::string &hierarchical_name() const override;
85 std::string_view name() const override;
86 const std::string &description() const override;
87 void set_description(std::string_view desc) override;
88 Level hierarchy_level() const override;
89 std::string_view bank_name() const override;
90 MappableConfObject *dev_obj() const override;
91 ConfObjectRef bank_obj_ref() const override;
92 std::string_view parent_name() const override;
93 FieldInterface *lookup_field(const std::string &name) const override;
94 RegisterInterface *lookup_register(const std::string &name) const override;
95 BankInterface *lookup_bank(const std::string &name) const override;
96
97 private:
98 void init();
99 // Ensure that a bank port is created before the initialization of
100 // HierarchicalObject.
101 void ensureBankPortExists(const std::string &bank_name);
102
103 MappableConfObject *dev_obj_ {nullptr};
104 std::string hierarchical_name_;
105 std::string desc_;
106 ConfObjectRef bank_obj_ref_;
107 Level level_;
108};
109
110} // namespace simics
111
112#endif
An interface implemented by a Simics bank.
Definition: bank-interface.h:47
Represents Simics C type conf_object_t.
Definition: conf-object.h:38
Definition: field-interface.h:34
Interface for hierarchical objects used in bank register modeling.
Definition: hierarchical-object-interface.h:49
Base class for Bank, Register, and Field classes.
Definition: hierarchical-object.h:44
T * dev_ptr()
Definition: hierarchical-object.h:77
static const uint64_t Register_Read
Log group ID for Register_Read and Register_Write is fixed.
Definition: hierarchical-object.h:71
HierarchicalObject(HierarchicalObject &&rhs) noexcept
static const uint64_t Register_Write_Exception
Definition: hierarchical-object.h:74
HierarchicalObject & operator=(const HierarchicalObject &)=delete
static const uint64_t Register_Read_Exception
Definition: hierarchical-object.h:73
std::string_view bank_name() const override
BankInterface * lookup_bank(const std::string &name) const override
static const uint64_t Register_Write
Definition: hierarchical-object.h:72
static std::string_view::size_type level_of_hierarchical_name(std::string_view name)
RegisterInterface * lookup_register(const std::string &name) const override
ConfObjectRef bank_obj_ref() const override
HierarchicalObject(MappableConfObject *dev_obj, const std::string &name)
Constructor for HierarchicalObject.
FieldInterface * lookup_field(const std::string &name) const override
HierarchicalObject & operator=(HierarchicalObject &&rhs) noexcept
static bool is_valid_hierarchical_name(std::string_view name)
std::string_view name() const override
Level hierarchy_level() const override
std::string_view parent_name() const override
const std::string & description() const override
void set_description(std::string_view desc) override
MappableConfObject * dev_obj() const override
HierarchicalObject(const HierarchicalObject &)=delete
const std::string & hierarchical_name() const override
Definition: mappable-conf-object.h:134
Definition: register-interface.h:37
Definition: after-bank.h:33
Level
Enum representing the hierarchy level of an object.
Definition: hierarchical-object-interface.h:37