A SystemC productivity library for virtual platform development utilizing SCV and TLM2.0 https://www.minres.com/#opensource

ext_attribute.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*******************************************************************************
  2. * Copyright 2017, 2018 MINRES Technologies GmbH
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *******************************************************************************/
  16. #ifndef _SCC_EXT_ATTRIBUTE_H_
  17. #define _SCC_EXT_ATTRIBUTE_H_
  18. #include "configurer.h"
  19. #include "utilities.h"
  20. namespace scc {
  21. /**
  22. * extended attribute inheriting from sc_attribute
  23. */
  24. template <typename T> class ext_attribute : public sc_core::sc_attribute<T> {
  25. public:
  26. using base_type = sc_core::sc_attribute<T>;
  27. /**
  28. * create an extended attribute based on name and owner with default value
  29. *
  30. * @param name_
  31. * @param owner
  32. */
  33. ext_attribute(const std::string &name_, sc_core::sc_module *owner)
  34. : base_type(name_)
  35. , owner(owner) {
  36. owner->add_attribute(*this);
  37. configurer::instance().set_configuration_value(this, owner);
  38. }
  39. /**
  40. * create an extended attribute based on name, value and owner
  41. *
  42. * @param name_
  43. * @param value_
  44. * @param owner
  45. */
  46. ext_attribute(const std::string &name_, const T &value_, sc_core::sc_module *owner)
  47. : base_type(name_, value_)
  48. , owner(owner) {
  49. owner->add_attribute(*this);
  50. configurer::instance().set_configuration_value(this, owner);
  51. }
  52. /**
  53. * no copy constructor
  54. *
  55. * @param a
  56. */
  57. ext_attribute(const ext_attribute<T> &a) = delete;
  58. /**
  59. * a default destructor
  60. */
  61. ~ext_attribute() = default;
  62. /**
  63. * the owner of this attribute (a backward reference)
  64. */
  65. const sc_core::sc_module *owner;
  66. };
  67. };
  68. #endif /* _SYSC_EXT_ATTRIBUTE_H_ */