gem5  v20.1.0.0
CoreDecouplingLTInitiator.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements. See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied. See the License for the specific language governing
16  permissions and limitations under the License.
17 
18  *****************************************************************************/
19 
20 //====================================================================
21 // Nov 06, 2008
22 //
23 // Updated by:
24 // Xiaopeng Qiu, JEDA Technologies, Inc
25 // Email: qiuxp@jedatechnologies.net
26 //
27 // To fix violations of TLM2.0 rules, which are detected by JEDA
28 // TLM2.0 checker.
29 //
30 //====================================================================
31 
32 #ifndef __CORE_DECOUPLING_LT_INITIATOR_H__
33 #define __CORE_DECOUPLING_LT_INITIATOR_H__
34 
35 #include "tlm.h"
36 #include "tlm_utils/simple_initiator_socket.h"
37 #include "tlm_utils/tlm_quantumkeeper.h"
38 //#include <systemc>
39 #include <cassert>
40 //#include <iostream>
41 
43 {
44 public:
47 
48 public:
50 
51 public:
54  unsigned int nrOfTransactions = 0x5,
55  unsigned int baseAddress = 0) :
57  socket("socket"),
58  mNrOfTransactions(nrOfTransactions),
59  mBaseAddress(baseAddress),
61  {
64 
65  // Initiator thread
67  }
68 
70  {
72  trans.set_address(mBaseAddress + 4*mTransactionCount);
74  trans.set_command(tlm::TLM_WRITE_COMMAND);
75 
76  } else if (mTransactionCount < 2 * mNrOfTransactions) {
77  trans.set_address(mBaseAddress + 4*(mTransactionCount - mNrOfTransactions));
78  mData = 0;
79  trans.set_command(tlm::TLM_READ_COMMAND);
80 
81  } else {
82  return false;
83  }
84 
85  trans.set_data_ptr(reinterpret_cast<unsigned char*>(&mData));
86  trans.set_data_length(4);
87  trans.set_streaming_width(4);
88  trans.set_response_status(tlm::TLM_INCOMPLETE_RESPONSE);
89 
91  return true;
92  }
93 
95  {
96  if (trans.get_command() == tlm::TLM_WRITE_COMMAND) {
97  std::cout << name() << ": Send write request: A = 0x"
98  << std::hex << (unsigned int)trans.get_address()
99  << ", D = 0x" << mData << std::dec
100  << " @ " << mQuantumKeeper.get_current_time()
101  << " (" << sc_core::sc_time_stamp() << " + "
102  << mQuantumKeeper.get_local_time() << ")"
103  << std::endl;
104 
105  } else {
106  std::cout << name() << ": Send read request: A = 0x"
107  << std::hex << (unsigned int)trans.get_address()
108  << " @ " << mQuantumKeeper.get_current_time()
109  << " (" << sc_core::sc_time_stamp() << " + "
110  << mQuantumKeeper.get_local_time() << ")"
111  << std::endl;
112  }
113  }
114 
116  {
117  if (trans.get_response_status() != tlm::TLM_OK_RESPONSE) {
118  std::cout << name() << ": Received error response @ "
120  << " (" << sc_core::sc_time_stamp() << " + "
121  << mQuantumKeeper.get_local_time() << ")"
122  << std::endl;
123 
124  } else {
125  std::cout << name() << ": Received ok response";
126  if (trans.get_command() == tlm::TLM_READ_COMMAND) {
127  std::cout << ": D = 0x" << std::hex << mData << std::dec;
128  }
129  std::cout << " @ " << mQuantumKeeper.get_current_time()
130  << " (" << sc_core::sc_time_stamp() << " + "
131  << mQuantumKeeper.get_local_time() << ")"
132  << std::endl;
133  }
134  }
135 
136  void run()
137  {
138  transaction_type trans;
139 
140  while (initTransaction(trans)) {
141  logStartTransation(trans);
142 
143  // exec instr
145  socket->b_transport(trans, t);
147  // Target may have added a delay to the quantum -> sync if needed
148  if (mQuantumKeeper.need_sync()) {
149  std::cout << "Sync'ing..." << std::endl;
151  }
152 
154  }
155  wait();
156  }
157 
158 private:
159  unsigned int mNrOfTransactions;
160  unsigned int mBaseAddress;
161  unsigned int mTransactionCount;
162  unsigned int mData;
164 };
165 
166 #endif
tlm::TLM_INCOMPLETE_RESPONSE
@ TLM_INCOMPLETE_RESPONSE
Definition: gp.hh:109
tlm_utils::tlm_quantumkeeper::set
virtual void set(const sc_core::sc_time &t)
Definition: tlm_quantumkeeper.h:104
SC_THREAD
#define SC_THREAD(name)
Definition: sc_module.hh:309
sc_core::sc_module
Definition: sc_module.hh:97
CoreDecouplingLTInitiator::socket
initiator_socket_type socket
Definition: CoreDecouplingLTInitiator.h:66
CoreDecouplingLTInitiator::mNrOfTransactions
unsigned int mNrOfTransactions
Definition: CoreDecouplingLTInitiator.h:176
CoreDecouplingLTInitiator::logStartTransation
void logStartTransation(transaction_type &trans)
Definition: CoreDecouplingLTInitiator.h:111
tlm::TLM_WRITE_COMMAND
@ TLM_WRITE_COMMAND
Definition: gp.hh:102
CoreDecouplingLTInitiator::CoreDecouplingLTInitiator
CoreDecouplingLTInitiator(sc_core::sc_module_name name, unsigned int nrOfTransactions=0x5, unsigned int baseAddress=0)
Definition: CoreDecouplingLTInitiator.h:70
tlm::TLM_OK_RESPONSE
@ TLM_OK_RESPONSE
Definition: gp.hh:108
CoreDecouplingLTInitiator::mBaseAddress
unsigned int mBaseAddress
Definition: CoreDecouplingLTInitiator.h:177
CoreDecouplingLTInitiator::mQuantumKeeper
tlm_utils::tlm_quantumkeeper mQuantumKeeper
Definition: CoreDecouplingLTInitiator.h:180
sc_core::SC_NS
@ SC_NS
Definition: sc_time.hh:43
CoreDecouplingLTInitiator::logEndTransaction
void logEndTransaction(transaction_type &trans)
Definition: CoreDecouplingLTInitiator.h:132
CoreDecouplingLTInitiator::mTransactionCount
unsigned int mTransactionCount
Definition: CoreDecouplingLTInitiator.h:178
CoreDecouplingLTInitiator::mData
unsigned int mData
Definition: CoreDecouplingLTInitiator.h:179
sc_core::sc_time
Definition: sc_time.hh:49
CoreDecouplingLTInitiator::transaction_type
tlm::tlm_generic_payload transaction_type
Definition: CoreDecouplingLTInitiator.h:62
tlm::TLM_READ_COMMAND
@ TLM_READ_COMMAND
Definition: gp.hh:101
tlm_utils::simple_initiator_socket< CoreDecouplingLTInitiator >
tlm_utils::tlm_quantumkeeper::need_sync
virtual bool need_sync() const
Definition: tlm_quantumkeeper.h:110
sc_core::sc_module_name
Definition: sc_module_name.hh:41
tlm_utils::tlm_quantumkeeper::reset
virtual void reset()
Definition: tlm_quantumkeeper.h:140
tlm_utils::tlm_quantumkeeper::get_current_time
virtual sc_core::sc_time get_current_time() const
Definition: tlm_quantumkeeper.h:151
CoreDecouplingLTInitiator::SC_HAS_PROCESS
SC_HAS_PROCESS(CoreDecouplingLTInitiator)
CoreDecouplingLTInitiator::run
void run()
Definition: CoreDecouplingLTInitiator.h:153
CoreDecouplingLTInitiator::initTransaction
bool initTransaction(transaction_type &trans)
Definition: CoreDecouplingLTInitiator.h:86
tlm::tlm_generic_payload
Definition: gp.hh:133
tlm_utils::tlm_quantumkeeper::set_global_quantum
static void set_global_quantum(const sc_core::sc_time &t)
Definition: tlm_quantumkeeper.h:78
CoreDecouplingLTInitiator
Definition: CoreDecouplingLTInitiator.h:42
ArmISA::t
Bitfield< 5 > t
Definition: miscregs_types.hh:67
sc_core::sc_object::name
const char * name() const
Definition: sc_object.cc:44
sc_core::sc_module::wait
void wait()
Definition: sc_module.cc:428
tlm_utils::tlm_quantumkeeper::get_local_time
virtual sc_core::sc_time get_local_time() const
Definition: tlm_quantumkeeper.h:160
tlm_utils::tlm_quantumkeeper::sync
virtual void sync()
Definition: tlm_quantumkeeper.h:119
tlm_utils::tlm_quantumkeeper
Definition: tlm_quantumkeeper.h:50
sc_core::sc_time_stamp
const sc_time & sc_time_stamp()
Definition: sc_main.cc:128
CoreDecouplingLTInitiator::initiator_socket_type
tlm_utils::simple_initiator_socket< CoreDecouplingLTInitiator > initiator_socket_type
Definition: CoreDecouplingLTInitiator.h:63

Generated on Wed Sep 30 2020 14:02:16 for gem5 by doxygen 1.8.17