C++ Device API Reference Manual
Reference documentation for the Simics C++ Device API.
 
Loading...
Searching...
No Matches
bank-templates.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2021 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_BANK_TEMPLATES_H
17#define SIMICS_BANK_TEMPLATES_H
18
19#include <cstdint>
20#include <string>
21#include <string_view>
22
23#include "simics/bank.h"
26
27namespace simics {
28
29// Helper class to create and initialize a bank on a port
30template <typename TBank = Bank, typename... Args>
31class PortBank : public TBank {
32 static_assert(std::is_base_of<Bank, TBank>::value,
33 "TBank must be derived from Bank");
34 public:
35 PortBank(BankPortInterface *port_iface, Description desc, Args... args)
36 : TBank(port_iface->dev_obj(), port_iface->bank_name().data(),
37 args ...) {
38 port_iface->set_bank({port_iface->bank_name().data(), desc, {}});
39 }
40};
41
42class BigEndianBank : public Bank {
43 public:
46};
47
48// Each missed byte in a missed read is set to miss_pattern
49class MissPatternBank : public Bank {
50 public:
52 uint8_t miss_pattern = 0)
53 : Bank(dev_obj, name) {
54 set_miss_pattern(miss_pattern);
55 }
56};
57
64class SharedMemoryBank : public Bank {
65 public:
68 std::string_view name_of_bank_memory)
69 : Bank(dev_obj, name) {
70 allocate_bank_memory(name_of_bank_memory);
71 }
72};
73
74} // namespace simics
75
76#endif
Definition: bank-port-interface.h:31
virtual void set_bank(const bank_t &bank)=0
virtual std::string_view bank_name() const =0
Base class to represent a Simics register bank.
Definition: bank.h:51
void set_miss_pattern(uint8_t miss_pattern) override
Set the miss pattern for the bank.
Definition: bank.h:96
void allocate_bank_memory(std::string_view name)
Allocate memory for this bank by name.
std::string_view name() const override
Get the name of the bank without level delimiters.
Definition: bank.h:70
MappableConfObject * dev_obj() const override
Get the device object.
Definition: bank.h:73
Definition: bank-templates.h:42
BigEndianBank(MappableConfObject *dev_obj, const std::string &name)
Definition: bank-templates.h:44
std::string_view bank_name() const override
Definition: mappable-conf-object.h:134
Definition: bank-templates.h:49
MissPatternBank(MappableConfObject *dev_obj, const std::string &name, uint8_t miss_pattern=0)
Definition: bank-templates.h:51
Definition: bank-templates.h:31
PortBank(BankPortInterface *port_iface, Description desc, Args... args)
Definition: bank-templates.h:35
Normally a bank allocates memory from the device object using the name of the bank as the key.
Definition: bank-templates.h:64
SharedMemoryBank(MappableConfObject *dev_obj, const std::string &name, std::string_view name_of_bank_memory)
Definition: bank-templates.h:67
Definition: after-bank.h:33
ByteOrder
Definition: bank-interface.h:33
std::string_view Description
Type used to describe a resource.
Definition: common-types.h:46