tlm_req_rsp.svh

Go to the documentation of this file.
00001 // $Id: a00301.html,v 1.1 2009/01/07 19:29:53 alex.marin Exp $
00002 //----------------------------------------------------------------------
00003 //   Copyright 2007-2008 Mentor Graphics Corporation
00004 //   Copyright 2007-2008 Cadence Design Systems, Inc.
00005 //   All Rights Reserved Worldwide
00006 //
00007 //   Licensed under the Apache License, Version 2.0 (the
00008 //   "License"); you may not use this file except in
00009 //   compliance with the License.  You may obtain a copy of
00010 //   the License at
00011 //
00012 //       http://www.apache.org/licenses/LICENSE-2.0
00013 //
00014 //   Unless required by applicable law or agreed to in
00015 //   writing, software distributed under the License is
00016 //   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
00017 //   CONDITIONS OF ANY KIND, either express or implied.  See
00018 //   the License for the specific language governing
00019 //   permissions and limitations under the License.
00020 //----------------------------------------------------------------------
00021 
00022 //------------------------------------------------------------------------------
00023 //
00024 // CLASS: tlm_req_rsp_channel
00025 //
00026 //------------------------------------------------------------------------------
00027 // tlm_req_rsp_channel contains a request fifo and a response fifo.
00028 // These fifos can be of any size. This channel is particularly useful
00029 // for modeling pipelined protocols.
00030 //------------------------------------------------------------------------------
00031 
00032 class tlm_req_rsp_channel #(type REQ=int, type RSP=int) extends ovm_component;
00033 
00034   typedef tlm_req_rsp_channel #(REQ, RSP) this_type;
00035 
00036   const static string type_name = "tlm_req_rsp_channel #(REQ,RSP)";
00037 
00038   ovm_put_export      #(REQ) put_request_export;
00039   ovm_get_peek_export #(REQ) get_peek_request_export;
00040   ovm_analysis_port   #(REQ) request_ap;
00041 
00042   ovm_put_export      #(RSP) put_response_export;
00043   ovm_get_peek_export #(RSP) get_peek_response_export;
00044   ovm_analysis_port   #(RSP) response_ap;
00045 
00046   ovm_master_imp #(REQ, RSP, this_type, tlm_fifo #(REQ), tlm_fifo #(RSP)) master_export;
00047   ovm_slave_imp  #(REQ, RSP, this_type, tlm_fifo #(REQ), tlm_fifo #(RSP)) slave_export;
00048 
00049   // port aliases for backward compatibility
00050   ovm_put_export      #(REQ) blocking_put_request_export,
00051                              nonblocking_put_request_export;
00052   ovm_get_peek_export #(REQ) get_request_export,
00053                              blocking_get_request_export,
00054                              nonblocking_get_request_export,
00055                              peek_request_export,
00056                              blocking_peek_request_export,
00057                              nonblocking_peek_request_export,
00058                              blocking_get_peek_request_export,
00059                              nonblocking_get_peek_request_export;
00060 
00061   ovm_put_export      #(RSP) blocking_put_response_export,
00062                              nonblocking_put_response_export;
00063   ovm_get_peek_export #(RSP) get_response_export,
00064                              blocking_get_response_export,
00065                              nonblocking_get_response_export,
00066                              peek_response_export,
00067                              blocking_peek_response_export,
00068                              nonblocking_peek_response_export,
00069                              blocking_get_peek_response_export,
00070                              nonblocking_get_peek_response_export;
00071 
00072   ovm_master_imp #(REQ, RSP, this_type, tlm_fifo #(REQ), tlm_fifo #(RSP))
00073                              blocking_master_export, 
00074                              nonblocking_master_export;
00075 
00076   ovm_slave_imp  #(REQ, RSP, this_type, tlm_fifo #(REQ), tlm_fifo #(RSP))
00077                              blocking_slave_export, 
00078                              nonblocking_slave_export;
00079   // internal fifos
00080   protected tlm_fifo #(REQ) m_request_fifo;
00081   protected tlm_fifo #(RSP) m_response_fifo;
00082 
00083   function new (string name, ovm_component parent=null, 
00084                 int request_fifo_size=1,
00085                 int response_fifo_size=1);
00086 
00087     super.new (name, parent);
00088 
00089     m_request_fifo  = new ("request_fifo",  this, request_fifo_size);
00090     m_response_fifo = new ("response_fifo", this, response_fifo_size);
00091 
00092     request_ap      = new ("request_ap",  this);
00093     response_ap     = new ("response_ap", this);
00094             
00095     put_request_export       = new ("put_request_export",       this);
00096     get_peek_request_export  = new ("get_peek_request_export",  this);
00097 
00098     put_response_export      = new ("put_response_export",      this); 
00099     get_peek_response_export = new ("get_peek_response_export", this);
00100 
00101     master_export   = new ("master_export", this, m_request_fifo, m_response_fifo);
00102     slave_export    = new ("slave_export",  this, m_request_fifo, m_response_fifo);
00103 
00104     create_aliased_exports();
00105 
00106     set_report_id_action_hier(s_connection_error_id, OVM_NO_ACTION);
00107 
00108   endfunction
00109 
00110   virtual function void connect();
00111     put_request_export.connect       (m_request_fifo.put_export);
00112     get_peek_request_export.connect  (m_request_fifo.get_peek_export);
00113     m_request_fifo.put_ap.connect    (request_ap);
00114     put_response_export.connect      (m_response_fifo.put_export);
00115     get_peek_response_export.connect (m_response_fifo.get_peek_export);
00116     m_response_fifo.put_ap.connect   (response_ap);
00117   endfunction
00118 
00119   function void create_aliased_exports();
00120     // request
00121     blocking_put_request_export         = put_request_export;
00122     nonblocking_put_request_export      = put_request_export;
00123     get_request_export                  = get_peek_request_export;
00124     blocking_get_request_export         = get_peek_request_export;
00125     nonblocking_get_request_export      = get_peek_request_export;
00126     peek_request_export                 = get_peek_request_export;
00127     blocking_peek_request_export        = get_peek_request_export;
00128     nonblocking_peek_request_export     = get_peek_request_export;
00129     blocking_get_peek_request_export    = get_peek_request_export;
00130     nonblocking_get_peek_request_export = get_peek_request_export;
00131   
00132     // response
00133     blocking_put_response_export         = put_response_export;
00134     nonblocking_put_response_export      = put_response_export;
00135     get_response_export                  = get_peek_response_export;
00136     blocking_get_response_export         = get_peek_response_export;
00137     nonblocking_get_response_export      = get_peek_response_export;
00138     peek_response_export                 = get_peek_response_export;
00139     blocking_peek_response_export        = get_peek_response_export;
00140     nonblocking_peek_response_export     = get_peek_response_export;
00141     blocking_get_peek_response_export    = get_peek_response_export;
00142     nonblocking_get_peek_response_export = get_peek_response_export;
00143   
00144     // master/slave
00145     blocking_master_export    = master_export; 
00146     nonblocking_master_export = master_export;
00147     blocking_slave_export     = slave_export;
00148     nonblocking_slave_export  = slave_export;
00149   endfunction
00150   
00151   // get_type_name
00152   // -------------
00153 
00154   function string get_type_name ();
00155     return type_name;
00156   endfunction
00157 
00158 
00159   // create
00160   // ------
00161   
00162   function ovm_object create (string name=""); 
00163     this_type v;
00164     v=new(name);
00165     return v;
00166   endfunction
00167 
00168 
00169 endclass
00170 
00171 
00172 //------------------------------------------------------------------------------
00173 //
00174 // CLASS: tlm_transport_channel
00175 //
00176 //------------------------------------------------------------------------------
00177 // tlm_transport_channel is a tlm_req_rsp_channel that implements the
00178 // transport interface. Because the requests and responses have a
00179 // tightly coupled one to one relationship, the fifo sizes must be one.
00180 //------------------------------------------------------------------------------
00181 
00182 class tlm_transport_channel #(type REQ=int, type RSP=int) 
00183                                      extends tlm_req_rsp_channel #(REQ, RSP);
00184 
00185   typedef tlm_transport_channel #(REQ, RSP) this_type;
00186 
00187   ovm_transport_imp #(REQ, RSP, this_type) transport_export;
00188 
00189   function new (string name, ovm_component parent=null);
00190     super.new(name, parent, 1, 1);
00191     transport_export = new("transport_export", this);
00192   endfunction
00193 
00194 // begin codeblock transport
00195   task transport( input REQ request , output RSP response );
00196     this.m_request_fifo.put( request );
00197     this.m_response_fifo.get( response );
00198   endtask
00199 // end codeblock transport caption path
00200 
00201   function bit nb_transport( input REQ req, output RSP rsp );
00202     if(this.m_request_fifo.try_put(req)) 
00203       return this.m_response_fifo.try_get(rsp);
00204     else
00205       return 0;
00206   endfunction
00207 
00208 endclass

Intelligent Design Verification
Intelligent Design Verification
Project: OVM, Revision: 2.0.1
Copyright (c) 2008 Intelligent Design Verification.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included here:
http://www.intelligentdv.com/licenses/fdl.txt
doxygen
Doxygen Version: 1.5.5
Wed Jan 7 19:27:18 2009
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV