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

configurable_tracer.h 4.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*******************************************************************************
  2. * Copyright (C) 2018, MINRES Technologies GmbH
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * 3. Neither the name of the copyright holder nor the names of its contributors
  16. * may be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  23. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  24. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  25. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  28. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29. * POSSIBILITY OF SUCH DAMAGE.
  30. * Contributors:
  31. * eyck@minres.com - initial API and implementation
  32. ******************************************************************************/
  33. #ifndef _SCC_CONFIGURABLE_TRACER_H_
  34. #define _SCC_CONFIGURABLE_TRACER_H_
  35. #include "tracer.h"
  36. #include <cci_configuration>
  37. namespace scc {
  38. /**
  39. *
  40. */
  41. class configurable_tracer : public scc::tracer {
  42. public:
  43. /**
  44. * constructs a tracer object
  45. *
  46. * @param name basename of the trace file(s)
  47. * @param type type of trace file for transactions
  48. * @param enable enable VCD (signal based) tracing
  49. * @param default value of attribute enableTracing if not defined by module or CCIs
  50. */
  51. configurable_tracer(const std::string&&, file_type, bool = true, bool = false);
  52. /**
  53. * constructs a tracer object
  54. *
  55. * @param name basename of the trace file(s)
  56. * @param type type of trace file for transactions
  57. * @param enable enable VCD (signal based) tracing
  58. * @param default value of attribute enableTracing if not defined by module or CCIs
  59. */
  60. configurable_tracer(const std::string& name, file_type type, bool enable_vcd = true, bool default_enable = false)
  61. :configurable_tracer(std::string(name), type, enable_vcd, default_enable)
  62. {}
  63. /**
  64. * destructor
  65. */
  66. ~configurable_tracer();
  67. /**
  68. * adds default trace control attribute of name 'enableTracing' to each sc_module in a design hierarchy
  69. */
  70. void add_control() {
  71. for (auto *o : sc_core::sc_get_top_level_objects(sc_core::sc_curr_simcontext)) augment_object_hierarchical(o);
  72. }
  73. protected:
  74. //! the default for tracing if no attribute is configured
  75. const bool default_trace_enable;
  76. //! depth-first walk thru the design hierarchy and trace signals resp. call trace() function
  77. void descend(const sc_core::sc_object *) override;
  78. //! check for existence of 'enableTracing' attribute and return value of default otherwise
  79. bool get_trace_enabled(const sc_core::sc_object *, bool = false);
  80. //! add the 'enableTracing' attribute to sc_module
  81. void augment_object_hierarchical(const sc_core::sc_object *);
  82. //! the originator of cci values
  83. cci::cci_originator cci_originator;
  84. //! the cci broker
  85. cci::cci_broker_handle cci_broker;
  86. //! array of created cci parameter
  87. std::vector<cci::cci_param_untyped *> params;
  88. };
  89. } /* namespace scc */
  90. #endif /* _SCC_CONFIGURABLE_TRACER_H_ */