qualcomm/qbox
Loading...
Searching...
No Matches
aoss_pmic_arb_pmic_arb_core.h
1/*
2 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef aoss_pmic_arb_pmic_arb_core_H
8#define aoss_pmic_arb_pmic_arb_core_H
9
10#include <systemc>
11#include <cci_configuration>
12#include <cciutils.h>
13#include <scp/report.h>
14#include <tlm>
15#include <cciutils.h>
16#include <module_factory_registery.h>
17#include "aoss_pmic_arb_pmic_arb_core_gen.h"
18#include <ports/multiinitiator-signal-socket.h>
26
27namespace quic {
28class aoss_pmic_arb_pmic_arb_core : public sc_core::sc_module, public aoss_pmic_arb_pmic_arb_core_gen
29{
30 SCP_LOGGER();
31 cci::cci_broker_handle m_broker; // Should be a private broker for efficiency, but requires fixes to cci utils to
32 // prevent use of cci_get_broker()
34 bool loaded_ok;
36
37 sc_core::sc_event reset_ev;
38
39 sc_core::sc_time last_reset = sc_core::SC_ZERO_TIME;
40 void do_reset()
41 {
42 // Insist that SystemC time moves forward at least by more than a zero timed delta between resets
43 // (Call it a debounce protection!)
44 if (last_reset == sc_core::sc_time_stamp()) return;
45
46 SCP_INFO(())("Initiate Reset sequence");
47
48 // Actually send the reset pulse. In this case we are driving the whole reset activity
49 // we'll send a positive then negative edge - from an sc_thread. see the MultiInitiatorSignalSocket
50 // convenience socket.
51 reset.async_write_vector({ 1, 0 });
52 last_reset = sc_core::sc_time_stamp();
53 }
54
55public:
56 tlm_utils::multi_passthrough_target_socket<aoss_pmic_arb_pmic_arb_core> target_socket;
58
60
61 aoss_pmic_arb_pmic_arb_core(sc_core::sc_module_name name, sc_core::sc_object* _router,
62 sc_core::sc_object* _reg_memory);
63
64 void start_of_simulation()
65 {
66 /* NB writes should not happen before simulation starts,
67 * Write any special register initial values here (e.g. over-right what is in the
68 * configuration files)
69 */
70 }
71 void before_end_of_elaboration()
72 {
73 SCP_TRACE(())("Before End of Elaboration, registering callbacks");
74 /* Add callbacks tt the registers*/
75 /* e.g. MYREG.post_write([&](TXN(txn)) {... my function...}); */
76 PMIC_ARB_CHNL_CMD.post_write([&](TXN()) {
77 SCP_DEBUG(())
78 ("PMIC_ARB_CHNL_CMD was written to with value: {:x} (the OPCODE is {}) ", PMIC_ARB_CHNL_CMD[0],
79 (int)OPCODE);
80 if (OPCODE == 0x3) reset_ev.notify();
81 });
82 }
83};
84} // namespace quic
85
86extern "C" void module_register();
87
88#endif // aoss_pmic_arb_pmic_arb_core_H
Definition multiinitiator-signal-socket.h:22
Definition target-signal-socket.h:163
Definition reg_model_maker.h:457
Definition reg_model_maker.h:35
Definition aoss_pmic_arb_pmic_arb_core.h:27