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 <string_view>
20#include <string>
21
22#include "bank.h"
24
25namespace simics {
26
27// Helper class to create and initialize a bank on a port
28template <typename TBank = Bank, typename... Args>
29class PortBank : public TBank {
30 static_assert(std::is_base_of<Bank, TBank>::value,
31 "TBank must be derived from Bank");
32 public:
33 PortBank(BankPortInterface *port_iface, Description desc, Args... args)
34 : TBank(port_iface->dev_obj(), port_iface->bank_name().data(),
35 args ...) {
36 port_iface->set_bank({port_iface->bank_name().data(), desc, {}});
37 }
38};
39
40class BigEndianBank : public Bank {
41 public:
44};
45
46// Each missed byte in a missed read is set to miss_pattern
47class MissPatternBank : public Bank {
48 public:
50 uint8_t miss_pattern = 0)
51 : Bank(dev_obj, name) {
52 set_miss_pattern(miss_pattern);
53 }
54};
55
62class SharedMemoryBank : public Bank {
63 public:
66 std::string_view name_of_bank_memory)
67 : Bank(dev_obj, name) {
68 allocate_bank_memory(name_of_bank_memory);
69 }
70};
71
72} // namespace simics
73
74#endif
Definition: bank-port-interface.h:30
virtual void set_bank(const bank_t &bank)=0
virtual std::string_view bank_name() const =0
Definition: bank.h:63
void set_miss_pattern(uint8_t miss_pattern) override
Definition: bank.h:139
void allocate_bank_memory(std::string_view name)
std::string_view name() const override
Definition: bank.h:113
MappableConfObject * dev_obj() const override
Definition: bank.h:116
Definition: bank-templates.h:40
BigEndianBank(MappableConfObject *dev_obj, const std::string &name)
Definition: bank-templates.h:42
std::string_view bank_name() const override
Definition: hierarchical-object.h:168
Definition: mappable-conf-object.h:131
Definition: bank-templates.h:47
MissPatternBank(MappableConfObject *dev_obj, const std::string &name, uint8_t miss_pattern=0)
Definition: bank-templates.h:49
Definition: bank-templates.h:29
PortBank(BankPortInterface *port_iface, Description desc, Args... args)
Definition: bank-templates.h:33
Normally a bank allocates memory from the device object using the name of the bank as the key.
Definition: bank-templates.h:62
SharedMemoryBank(MappableConfObject *dev_obj, const std::string &name, std::string_view name_of_bank_memory)
Definition: bank-templates.h:65
Definition: attr-value.h:23
ByteOrder
Definition: bank-interface.h:34
std::string_view Description
Type used to describe a resource.
Definition: common-types.h:43