📄 at_initiator_explicit.cpp
字号:
/***************************************************************************** The following code is derived, directly or indirectly, from the SystemC source code Copyright (c) 1996-2008 by all Contributors. All Rights reserved. The contents of this file are subject to the restrictions and limitations set forth in the SystemC Open Source License Version 3.0 (the "License"); You may not use this file except in compliance with such restrictions and limitations. You may obtain instructions on how to receive a copy of the License at http://www.systemc.org/. Software distributed by Contributors under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. *****************************************************************************/ //=============================================================================/// @file at_initiator_explicit.cpp/// @Details Implements a AT non-blocking initiator ////=============================================================================// Original Authors:// Bill Bunton, ESLX// Charles Wilson, ESLX// Anna Keist, ESLX//=============================================================================#include "reporting.h" // Reporting convenience macros#include "at_initiator_explicit.h" // Our header#include "tlm.h" // TLM headersusing namespace sc_core;static const char *filename = "at_initiator_explicit.cpp"; /// filename for reporting//=============================================================================///Constructorat_initiator_explicit::at_initiator_explicit // constructor( sc_module_name name // module name, const unsigned int ID // initiator ID, sc_core::sc_time end_rsp_delay // delay): sc_module (name) /// init module name, initiator_socket ("initiator_socket") /// init socket name, m_send_end_rsp_PEQ ("send_end_rsp_PEQ") /// init PEQ name , m_ID (ID) /// init initiator ID, m_end_rsp_delay (end_rsp_delay) /// init end response delay{ // bind initiator to the export initiator_socket (*this); // register thread process SC_THREAD(initiator_thread); // register method process SC_METHOD(send_end_rsp_method); sensitive << m_send_end_rsp_PEQ.get_event(); dont_initialize();}//=============================================================================//// Initiator thread////=============================================================================void at_initiator_explicit::initiator_thread(void) // initiator thread{ tlm::tlm_generic_payload *transaction_ptr; // transaction pointer std::ostringstream msg; // log message while (true) {//=============================================================================// Read FIFO to Get new transaction GP from the traffic generator //============================================================================= transaction_ptr = request_in_port->read(); // get request from input fifo tlm::tlm_phase phase = tlm::BEGIN_REQ; // Create phase objects sc_time delay = SC_ZERO_TIME; // Create delay objects msg.str(""); msg << "Initiator: " << m_ID << " starting new transaction" << endl << " " << "Initiator: " << m_ID << " nb_transport_fw (GP, " << report::print(phase) << ", " << delay << ")"; REPORT_INFO(filename, __FUNCTION__, msg.str());//-----------------------------------------------------------------------------// Make the non-blocking call and decode returned status (tlm_sync_enum) //----------------------------------------------------------------------------- tlm::tlm_sync_enum return_value = initiator_socket->nb_transport_fw(*transaction_ptr, phase, delay); msg.str(""); msg << "Initiator: " << m_ID << " " << report::print(return_value) << " (GP, " << report::print(phase) << ", " << delay << ")" << endl; switch (return_value) {//-----------------------------------------------------------------------------// The target returned COMPLETED this is a 1 phase transaction // Wait the annotated delay// Return the transaction to the traffic generator // Make the next request //----------------------------------------------------------------------------- case tlm::TLM_COMPLETED: { wait(delay + m_end_rsp_delay); // wait the annotated delay msg << " " << "Initiator: " << m_ID << " target returned COMPLETED with annotated time "; REPORT_INFO (filename, __FUNCTION__, msg.str() ); response_out_port->write(transaction_ptr); // return txn to traffic gen break; }// end case TLM_COMPLETED//-----------------------------------------------------------------------------// Target returned UPDATED //----------------------------------------------------------------------------- case tlm::TLM_UPDATED: {//-----------------------------------------------------------------------------// Put poiter in waiting backware path map// Wait the annotated delay// Make the next request //----------------------------------------------------------------------------- if( phase == tlm::END_REQ) { m_waiting_bw_path_map.insert(make_pair(transaction_ptr ,Rcved_END_REQ_enum )); wait(delay); // wait the annotated delay msg << " " << "Initiator: " << m_ID << " transaction waiting begin-response on backward path"; REPORT_INFO (filename, __FUNCTION__, msg.str() ); } //-----------------------------------------------------------------------------// Wait the annotated delay// Use payload event queue to schedule sending end response // Make the next request //----------------------------------------------------------------------------- else if( phase == tlm::BEGIN_RESP) { msg << " " << "Initiator: " << m_ID << " transaction moved to send-end-response PEQ " << endl; wait(delay); // wait the annotated delay m_send_end_rsp_PEQ.notify (*transaction_ptr, m_end_rsp_delay); msg << " " << "Initiator: " << m_ID << " " << " (GP, " << report::print(phase) << ", " << delay << ")" ; REPORT_INFO (filename, __FUNCTION__, msg.str() ) }//-----------------------------------------------------------------------------//----------------------------------------------------------------------------- else { msg << " " << "Initiator: " << m_ID << " Unexpected phase for UPDATED return from target "; REPORT_FATAL (filename, __FUNCTION__, msg.str() ); } break; } // end case TLM_UPDATED//-----------------------------------------------------------------------------// Target returned ACCEPTED this an explicit response // Add the transaction pointer to the waiting backward path map // END REQUEST RULE wait for the target to response//----------------------------------------------------------------------------- case tlm::TLM_ACCEPTED: { msg << " " << "Initiator: " << m_ID << " transaction waiting end-request on backward-path "; REPORT_INFO (filename, __FUNCTION__, msg.str() ); // use map to track transaction including current state information m_waiting_bw_path_map.insert (make_pair (transaction_ptr ,Rcved_ACCEPTED_enum )); wait (m_enable_next_request_event); // wait for the target to response break; } // end case TLM_ACCEPTED//-----------------------------------------------------------------------------// All case covered default //----------------------------------------------------------------------------- default: { msg << " " << "Initiator: " << m_ID << " Unexpected response to BEGIN_REQ "; REPORT_FATAL (filename, __FUNCTION__, msg.str() ); break; } } // end case } // end while true} // end initiator_thread //=============================================================================/// @fn at_initiator_explicit::nb_transport_bw///// @brief non-blocking transport from targets
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -