⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 select_initiator.cpp

📁 SystemC Transaction Level Modelling. 是基于SystemC之上的总线互联协议
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************  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 select_initiator.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 "select_initiator.h"                         // Our header#include "tlm.h"                                      // TLM headersusing namespace sc_core;static const char *filename = "select_initiator.cpp";  ///  filename for reporting//=============================================================================///Constructorselect_initiator::select_initiator                  // 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{  m_enable_target_tracking = true;   /// init style tracking mode????  // 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 select_initiator::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     std::ostringstream  msg;                    // log message        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 single phase transaction //    Wait the annotated delay//    Return the transaction to the traffic generator //-----------------------------------------------------------------------------      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 this will be 2 phase transaction //    Add the transaction pointer to the waiting backward path map  //    Set tracking enum to Rcved_UPDATED //    Wait the annotated delay//-----------------------------------------------------------------------------      case tlm::TLM_UPDATED:       {        if( phase == tlm::END_REQ) {          if (m_enable_target_tracking) {            m_waiting_bw_path_map.insert(make_pair(transaction_ptr                                                  ,Rcved_UPDATED_enum                                                  ));                    }          else {            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() );        }        else if( phase == tlm::BEGIN_RESP) {        // ?????        }        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 will be 4 phase transaction //    Add the transaction pointer to the waiting backward path map  //    Set tracking enum to Rcved_END_REQ //    When the END REQUEST RULE is active 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);                                                   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 select_initiator::nb_transport_bw/////  @brief non-blocking transport from targets////=============================================================================tlm::tlm_sync_enum    select_initiator::nb_transport_bw                       // inbound nb_transport_bw( tlm::tlm_generic_payload&  transaction_ref            // generic payload , tlm::tlm_phase&            phase                     // tlm phase , sc_time&                   delay                     // delay ){  tlm::tlm_sync_enum        status = tlm::TLM_COMPLETED;  // return status reject by default  std::ostringstream        msg;                          // log message  //=============================================================================// Check waiting backward path map of valid transaction  //=============================================================================  waiting_bw_path_map::iterator transaction_pair ;        // create interator for map  transaction_pair  = m_waiting_bw_path_map.find(&transaction_ref);     if (transaction_pair == m_waiting_bw_path_map.end() ) {               //=============================================================================//  The transaction pointer used by the backward path call does not belong //  to this initiator, this is a major error //=============================================================================    msg << "      "    << "Initiator: " << m_ID     << " Received invalid transaction pointer";    REPORT_FATAL (filename, __FUNCTION__, msg.str() );  }//=============================================================================//  Normal operation  //    Decode backward path phase 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -