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

resetable.h 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*******************************************************************************
  2. * Copyright 2016, 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 _SYSC_RESETTABLE_H_
  17. #define _SYSC_RESETTABLE_H_
  18. #include "resource_access_if.h"
  19. #include <vector>
  20. namespace scc {
  21. class resetable {
  22. public:
  23. /**
  24. * the default destructor
  25. */
  26. virtual ~resetable() = default;
  27. /**
  28. * begin the reset state
  29. */
  30. void reset_start() {
  31. _in_reset = true;
  32. for (auto res : resources) res->reset();
  33. }
  34. /**
  35. * finish the reset state
  36. */
  37. void reset_stop() {
  38. for (auto res : resources) res->reset();
  39. _in_reset = false;
  40. }
  41. /**
  42. * get the current state of this reset domain
  43. *
  44. * @return tru if reset is active
  45. */
  46. bool in_reset() { return _in_reset; }
  47. /**
  48. * register a resource with this reset domain
  49. *
  50. * @param res the resource belonging to this reset domain
  51. */
  52. void register_resource(resource_access_if *res) { resources.push_back(res); }
  53. protected:
  54. std::vector<resource_access_if *> resources;
  55. bool _in_reset = false;
  56. };
  57. } /* namespace scc */
  58. #endif /* _SYSC_RESETTABLE_H_ */