gem5  v20.1.0.0
SimpleLTInitiator2.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 __SIMPLE_LT_INITIATOR2_H__
33 #define __SIMPLE_LT_INITIATOR2_H__
34 
35 #include "tlm.h"
36 #include "tlm_utils/simple_initiator_socket.h"
37 //#include <systemc>
38 #include <cassert>
39 //#include <iostream>
40 
42 {
43 public:
45  typedef tlm::tlm_phase phase_type;
48 
49 public:
51 
52 public:
55  unsigned int nrOfTransactions = 0x5,
56  unsigned int baseAddress = 0x0) :
58  socket("socket"),
59  mNrOfTransactions(nrOfTransactions),
60  mBaseAddress(baseAddress),
62  {
63  // Initiator thread
65  }
66 
68  {
73 
74  } else if (mTransactionCount < 2 * mNrOfTransactions) {
76  mData = 0;
78 
79  } else {
80  return false;
81  }
82 
83  trans.set_data_ptr(reinterpret_cast<unsigned char*>(&mData));
84  trans.set_data_length(4);
85  trans.set_streaming_width(4);
86  trans.set_dmi_allowed(false);
88 
90  return true;
91  }
92 
94  {
95  if (trans.get_command() == tlm::TLM_WRITE_COMMAND) {
96  std::cout << name() << ": Send write request: A = 0x"
97  << std::hex << (unsigned int)trans.get_address()
98  << ", D = 0x" << mData << std::dec
99  << " @ " << sc_core::sc_time_stamp() << std::endl;
100 
101  } else {
102  std::cout << name() << ": Send read request: A = 0x"
103  << std::hex << (unsigned int)trans.get_address() << std::dec
104  << " @ " << sc_core::sc_time_stamp() << std::endl;
105  }
106  }
107 
109  {
110  if (trans.get_response_status() != tlm::TLM_OK_RESPONSE) {
111  std::cout << name() << ": Received error response @ "
112  << sc_core::sc_time_stamp() << std::endl;
113 
114  } else {
115  std::cout << name() << ": Received ok response";
116  if (trans.get_command() == tlm::TLM_READ_COMMAND) {
117  std::cout << ": D = 0x" << std::hex << mData << std::dec;
118  }
119  std::cout << " @ " << sc_core::sc_time_stamp() << std::endl;
120  }
121  }
122 
123  void run()
124  {
127 
128  while (initTransaction(trans)) {
129  // Create transaction and initialise t
131 
132  logStartTransation(trans);
133 
134  socket->b_transport(trans, t);
135  wait(t);
136 
137  logEndTransaction(trans);
138  }
139  wait();
140 
141  }
142 
143 private:
145  unsigned int mNrOfTransactions;
146  unsigned int mBaseAddress;
147  unsigned int mTransactionCount;
148  unsigned int mData;
149 };
150 
151 #endif
tlm::tlm_generic_payload::set_data_length
void set_data_length(const unsigned int length)
Definition: gp.hh:210
tlm::TLM_INCOMPLETE_RESPONSE
@ TLM_INCOMPLETE_RESPONSE
Definition: gp.hh:109
SC_THREAD
#define SC_THREAD(name)
Definition: sc_module.hh:309
sc_core::sc_module
Definition: sc_module.hh:97
tlm::tlm_phase
Definition: phase.hh:47
tlm::TLM_WRITE_COMMAND
@ TLM_WRITE_COMMAND
Definition: gp.hh:102
SimpleLTInitiator2::phase_type
tlm::tlm_phase phase_type
Definition: SimpleLTInitiator2.h:62
tlm::TLM_OK_RESPONSE
@ TLM_OK_RESPONSE
Definition: gp.hh:108
SimpleLTInitiator2::mEndEvent
sc_core::sc_event mEndEvent
Definition: SimpleLTInitiator2.h:161
SimpleLTInitiator2::SC_HAS_PROCESS
SC_HAS_PROCESS(SimpleLTInitiator2)
sc_core::SC_ZERO_TIME
const sc_time SC_ZERO_TIME
Definition: sc_time.cc:290
SimpleLTInitiator2::sync_enum_type
tlm::tlm_sync_enum sync_enum_type
Definition: SimpleLTInitiator2.h:63
tlm::tlm_generic_payload::set_dmi_allowed
void set_dmi_allowed(bool dmi_allowed)
Definition: gp.hh:256
SimpleLTInitiator2::initiator_socket_type
tlm_utils::simple_initiator_socket< SimpleLTInitiator2 > initiator_socket_type
Definition: SimpleLTInitiator2.h:64
tlm::tlm_generic_payload::set_command
void set_command(const tlm_command command)
Definition: gp.hh:198
sc_core::sc_event
Definition: sc_event.hh:169
SimpleLTInitiator2::socket
initiator_socket_type socket
Definition: SimpleLTInitiator2.h:67
SimpleLTInitiator2::initTransaction
bool initTransaction(transaction_type &trans)
Definition: SimpleLTInitiator2.h:84
SimpleLTInitiator2::mBaseAddress
unsigned int mBaseAddress
Definition: SimpleLTInitiator2.h:163
sc_core::sc_time
Definition: sc_time.hh:49
tlm::TLM_READ_COMMAND
@ TLM_READ_COMMAND
Definition: gp.hh:101
tlm_utils::simple_initiator_socket< SimpleLTInitiator2 >
sc_core::sc_module_name
Definition: sc_module_name.hh:41
tlm::tlm_generic_payload::set_streaming_width
void set_streaming_width(const unsigned int streaming_width)
Definition: gp.hh:230
SimpleLTInitiator2::mNrOfTransactions
unsigned int mNrOfTransactions
Definition: SimpleLTInitiator2.h:162
SimpleLTInitiator2
Definition: SimpleLTInitiator2.h:41
SimpleLTInitiator2::mData
unsigned int mData
Definition: SimpleLTInitiator2.h:165
tlm::tlm_generic_payload
Definition: gp.hh:133
ArmISA::t
Bitfield< 5 > t
Definition: miscregs_types.hh:67
SimpleLTInitiator2::SimpleLTInitiator2
SimpleLTInitiator2(sc_core::sc_module_name name, unsigned int nrOfTransactions=0x5, unsigned int baseAddress=0x0)
Definition: SimpleLTInitiator2.h:71
sc_core::sc_object::name
const char * name() const
Definition: sc_object.cc:44
tlm::tlm_generic_payload::set_address
void set_address(const sc_dt::uint64 address)
Definition: gp.hh:202
tlm::tlm_sync_enum
tlm_sync_enum
Definition: fw_bw_ifs.hh:48
sc_core::sc_module::wait
void wait()
Definition: sc_module.cc:428
SimpleLTInitiator2::mTransactionCount
unsigned int mTransactionCount
Definition: SimpleLTInitiator2.h:164
SimpleLTInitiator2::transaction_type
tlm::tlm_generic_payload transaction_type
Definition: SimpleLTInitiator2.h:61
SimpleLTInitiator2::logEndTransaction
void logEndTransaction(transaction_type &trans)
Definition: SimpleLTInitiator2.h:125
SimpleLTInitiator2::run
void run()
Definition: SimpleLTInitiator2.h:140
sc_core::sc_time_stamp
const sc_time & sc_time_stamp()
Definition: sc_main.cc:128
SimpleLTInitiator2::logStartTransation
void logStartTransation(transaction_type &trans)
Definition: SimpleLTInitiator2.h:110
tlm::tlm_generic_payload::set_data_ptr
void set_data_ptr(unsigned char *data)
Definition: gp.hh:206
tlm::tlm_generic_payload::set_response_status
void set_response_status(const tlm_response_status response_status)
Definition: gp.hh:221

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