fw_bw_ifs.hh revision 13521:74fa3ac44057
112027Sjungma@eit.uni-kl.de/*****************************************************************************
212027Sjungma@eit.uni-kl.de
312027Sjungma@eit.uni-kl.de  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
412027Sjungma@eit.uni-kl.de  more contributor license agreements.  See the NOTICE file distributed
512027Sjungma@eit.uni-kl.de  with this work for additional information regarding copyright ownership.
612027Sjungma@eit.uni-kl.de  Accellera licenses this file to you under the Apache License, Version 2.0
712027Sjungma@eit.uni-kl.de  (the "License"); you may not use this file except in compliance with the
812027Sjungma@eit.uni-kl.de  License.  You may obtain a copy of the License at
912027Sjungma@eit.uni-kl.de
1012027Sjungma@eit.uni-kl.de    http://www.apache.org/licenses/LICENSE-2.0
1112027Sjungma@eit.uni-kl.de
1212027Sjungma@eit.uni-kl.de  Unless required by applicable law or agreed to in writing, software
1312027Sjungma@eit.uni-kl.de  distributed under the License is distributed on an "AS IS" BASIS,
1412027Sjungma@eit.uni-kl.de  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1512027Sjungma@eit.uni-kl.de  implied.  See the License for the specific language governing
1612027Sjungma@eit.uni-kl.de  permissions and limitations under the License.
1712027Sjungma@eit.uni-kl.de
1812027Sjungma@eit.uni-kl.de *****************************************************************************/
1912027Sjungma@eit.uni-kl.de
2012027Sjungma@eit.uni-kl.de#ifndef __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_FW_BW_IFS_HH__
2112027Sjungma@eit.uni-kl.de#define __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_FW_BW_IFS_HH__
2212027Sjungma@eit.uni-kl.de
2312027Sjungma@eit.uni-kl.de#include <systemc>
2412027Sjungma@eit.uni-kl.de
2512027Sjungma@eit.uni-kl.de#include "tlm_core/2/generic_payload/generic_payload.hh"
2612027Sjungma@eit.uni-kl.de#include "tlm_core/2/interfaces/dmi.hh"
2712027Sjungma@eit.uni-kl.de
2812027Sjungma@eit.uni-kl.denamespace tlm
2912027Sjungma@eit.uni-kl.de{
3012027Sjungma@eit.uni-kl.de
3112027Sjungma@eit.uni-kl.deenum tlm_sync_enum { TLM_ACCEPTED, TLM_UPDATED, TLM_COMPLETED };
3212027Sjungma@eit.uni-kl.de
3312027Sjungma@eit.uni-kl.de////////////////////////////////////////////////////////////////////////////
3412027Sjungma@eit.uni-kl.de// Basic interfaces
3512027Sjungma@eit.uni-kl.de////////////////////////////////////////////////////////////////////////////
3612027Sjungma@eit.uni-kl.detemplate <typename TRANS=tlm_generic_payload, typename PHASE=tlm_phase>
3712027Sjungma@eit.uni-kl.declass tlm_fw_nonblocking_transport_if : public virtual sc_core::sc_interface
3812027Sjungma@eit.uni-kl.de{
3912027Sjungma@eit.uni-kl.de  public:
4012027Sjungma@eit.uni-kl.de    virtual tlm_sync_enum nb_transport_fw(TRANS &trans, PHASE &phase,
4112027Sjungma@eit.uni-kl.de                                          sc_core::sc_time& t) = 0;
4212027Sjungma@eit.uni-kl.de};
4312027Sjungma@eit.uni-kl.de
4412027Sjungma@eit.uni-kl.detemplate <typename TRANS=tlm_generic_payload, typename PHASE=tlm_phase>
4512027Sjungma@eit.uni-kl.declass tlm_bw_nonblocking_transport_if : public virtual sc_core::sc_interface
4612027Sjungma@eit.uni-kl.de{
4712027Sjungma@eit.uni-kl.de  public:
4812027Sjungma@eit.uni-kl.de    virtual tlm_sync_enum nb_transport_bw(TRANS &trans, PHASE &phase,
4912027Sjungma@eit.uni-kl.de                                          sc_core::sc_time &t) = 0;
5012027Sjungma@eit.uni-kl.de};
5112027Sjungma@eit.uni-kl.de
5212027Sjungma@eit.uni-kl.detemplate <typename TRANS=tlm_generic_payload>
5312027Sjungma@eit.uni-kl.declass tlm_blocking_transport_if : public virtual sc_core::sc_interface
5412027Sjungma@eit.uni-kl.de{
5512027Sjungma@eit.uni-kl.de  public:
5612027Sjungma@eit.uni-kl.de    virtual void b_transport(TRANS &trans, sc_core::sc_time &t) = 0;
5712027Sjungma@eit.uni-kl.de};
5812027Sjungma@eit.uni-kl.de
5912027Sjungma@eit.uni-kl.de//////////////////////////////////////////////////////////////////////////
6012027Sjungma@eit.uni-kl.de// DMI interfaces for getting and invalidating DMI pointers:
6112027Sjungma@eit.uni-kl.de//////////////////////////////////////////////////////////////////////////
6212027Sjungma@eit.uni-kl.de
6312027Sjungma@eit.uni-kl.de// The semantics of the forward interface are as follows:
6412027Sjungma@eit.uni-kl.de//
6512027Sjungma@eit.uni-kl.de// - An initiator that wants to get direct access to a target's memory region
6612027Sjungma@eit.uni-kl.de//   can call the get_direct_mem_ptr method with the 'trans' parameter set to
6712027Sjungma@eit.uni-kl.de//   the address that it wants to gain access to. It sets the trans.m_command
6812027Sjungma@eit.uni-kl.de//   to specify if the initiator intended use (read or write)
6912027Sjungma@eit.uni-kl.de//   to the target's DMI region. The initiator is responsible for calling the
7012027Sjungma@eit.uni-kl.de//   method with a freshly initialized tlm_dmi object either by using a newly
7112027Sjungma@eit.uni-kl.de//   constructed object, or by calling an existing object's init() method.
7212027Sjungma@eit.uni-kl.de// - Although a reference to a complete 'TRANS' type is passed to the get_
7312027Sjungma@eit.uni-kl.de//   direct_mem_ptr call, only the address command, and extension fields are of
7412027Sjungma@eit.uni-kl.de//   interest in most cases.
7512027Sjungma@eit.uni-kl.de// - Read and write ranges are not necessarily identical. If they are, a target
7612027Sjungma@eit.uni-kl.de//   can specify that the range is valid for all accesses with the tlm_data
7712027Sjungma@eit.uni-kl.de//   m_type attribute in the.
7812027Sjungma@eit.uni-kl.de// - The interconnect, if any, needs to decode the address and forward the
7912027Sjungma@eit.uni-kl.de//   call to the corresponding target. It needs to handle the address exactly
8012027Sjungma@eit.uni-kl.de//   as the target would expect on a transaction call, e.g. mask the address
8112027Sjungma@eit.uni-kl.de//   according to the target's address width.
8212027Sjungma@eit.uni-kl.de// - If the target supports DMI access for the given address, it sets the
8312027Sjungma@eit.uni-kl.de//   data fields in the DMI struct and returns true.
8412027Sjungma@eit.uni-kl.de// - If a target does not support DMI access it needs to return false.
8512027Sjungma@eit.uni-kl.de//   The target can either set the correct address range in the DMI struct
8612027Sjungma@eit.uni-kl.de//   to indicate the memory region where DMI is disallowed, or it can specify
8712027Sjungma@eit.uni-kl.de//   the complete address range if it doesn't know it's memory range. In this
8812027Sjungma@eit.uni-kl.de//   case the interconnect is responsible for clipping the address range to
8912027Sjungma@eit.uni-kl.de//   the correct range that the target serves.
9012027Sjungma@eit.uni-kl.de// - The interconnect must always translate the addresses to the initiator's
9112027Sjungma@eit.uni-kl.de//   address space. This must be the inverse operation of what the
9212027Sjungma@eit.uni-kl.de//   interconnect needed to do when forwarding the call. In case the
9312027Sjungma@eit.uni-kl.de//   component wants to change any member of the tlm_dmi object, e.g. for
9412027Sjungma@eit.uni-kl.de//   its own latency to the target's latency, it must only do so *after* the
9512027Sjungma@eit.uni-kl.de//   target has been called. The target is always allowed to overwrite all
9612027Sjungma@eit.uni-kl.de//   values in the tlm_dmi object.
9712027Sjungma@eit.uni-kl.de// - In case the slave returned with an invalid region the bus/interconnect
9812027Sjungma@eit.uni-kl.de//   must fill in the complete address region for the particular slave in the
9912027Sjungma@eit.uni-kl.de//   DMI data structure.
10012027Sjungma@eit.uni-kl.de//
10112027Sjungma@eit.uni-kl.de// DMI hint optimization:
10212027Sjungma@eit.uni-kl.de//
10312027Sjungma@eit.uni-kl.de// Initiators may use the DMI hint in the tlm_generic_payload to avoid
10412027Sjungma@eit.uni-kl.de// unnecessary DMI attempts. The recommended sequence of interface
10512027Sjungma@eit.uni-kl.de// method calls would be:
10612027Sjungma@eit.uni-kl.de//
10712027Sjungma@eit.uni-kl.de// - The initiator first tries to check if it has a valid DMI region for the
10812027Sjungma@eit.uni-kl.de//   address that it wants to access next.
10912027Sjungma@eit.uni-kl.de// - If not, it performs a normal transaction.
11012027Sjungma@eit.uni-kl.de// - If the DMI hint in this transaction is true, the initiator can try and
11112027Sjungma@eit.uni-kl.de//   get the DMI region.
11212027Sjungma@eit.uni-kl.de//
11312027Sjungma@eit.uni-kl.de// Note that the DMI hint optimization is completely optional and every
11412027Sjungma@eit.uni-kl.de// initiator model is free to ignore the DMI hint. However, a target is
11512027Sjungma@eit.uni-kl.de// required to set the DMI hint to true if a DMI request on the given address
11612027Sjungma@eit.uni-kl.de// with the given transaction type (read or write) would have succeeded.
11712027Sjungma@eit.uni-kl.de
11812027Sjungma@eit.uni-kl.detemplate <typename TRANS=tlm_generic_payload>
11912027Sjungma@eit.uni-kl.declass tlm_fw_direct_mem_if : public virtual sc_core::sc_interface
12012027Sjungma@eit.uni-kl.de{
12112027Sjungma@eit.uni-kl.de  public:
12212027Sjungma@eit.uni-kl.de    virtual bool get_direct_mem_ptr(TRANS &trans, tlm_dmi &dmi_data) = 0;
12312027Sjungma@eit.uni-kl.de};
12412027Sjungma@eit.uni-kl.de
12512027Sjungma@eit.uni-kl.de// The semantics of the backwards call is as follows:
12612027Sjungma@eit.uni-kl.de//
12712027Sjungma@eit.uni-kl.de// - An interconnect component or a target is required to invalidate all
12812027Sjungma@eit.uni-kl.de//   affected DMI regions whenever any change in the regions take place.
12912027Sjungma@eit.uni-kl.de//   The exact rule is that a component must invalidate all those DMI regions
13012027Sjungma@eit.uni-kl.de//   that it already reported, if it would answer the same DMI request
13112027Sjungma@eit.uni-kl.de//   with any member of the tlm_dmi data structure set differently.
13212027Sjungma@eit.uni-kl.de// - An interconnect component must forward the invalidate_direct_mem_ptr call
13312027Sjungma@eit.uni-kl.de//   to all initiators that could potentially have a DMI pointer to the region
13412027Sjungma@eit.uni-kl.de//   specified in the method arguments. A safe implementation is to call
13512027Sjungma@eit.uni-kl.de//   every attached initiator.
13612027Sjungma@eit.uni-kl.de// - An interconnect component must transform the address region of an
13712027Sjungma@eit.uni-kl.de//   incoming invalidate_direct_mem_ptr to the corresponding address space
13812027Sjungma@eit.uni-kl.de//   for the initiators. Basically, this is the same address transformation
13912027Sjungma@eit.uni-kl.de//   that the interconnect does on the DMI ranges on the forward direction.
14012027Sjungma@eit.uni-kl.de// - Each initiator must check if it has a pointer to the given region and
14112027Sjungma@eit.uni-kl.de//   throw this away. It is recommended that the initiator throws away all DMI
14212027Sjungma@eit.uni-kl.de//   regions that have any overlap with the given regions, but this is not a
14312027Sjungma@eit.uni-kl.de//   hard requirement.
14412027Sjungma@eit.uni-kl.de//
14512027Sjungma@eit.uni-kl.de// - A full DMI pointer invalidation, e.g. for a bus remap can be signaled
14612027Sjungma@eit.uni-kl.de//   by setting the range: 0x0 - 0xffffffffffffffffull = (sc_dt::uint64)-1
14712027Sjungma@eit.uni-kl.de// - An initiator must throw away all DMI pointers in this case.
14812027Sjungma@eit.uni-kl.de//
14912027Sjungma@eit.uni-kl.de// - Under no circumstances a model is allowed to call the get_direct_mem_ptr
15012027Sjungma@eit.uni-kl.de//   from within the invalidate_direct_mem_ptr method, directly or indirectly.
15112027Sjungma@eit.uni-kl.de//
15212027Sjungma@eit.uni-kl.declass tlm_bw_direct_mem_if : public virtual sc_core::sc_interface
15312027Sjungma@eit.uni-kl.de{
15412027Sjungma@eit.uni-kl.de  public:
15512027Sjungma@eit.uni-kl.de    virtual void invalidate_direct_mem_ptr(sc_dt::uint64 start_range,
15612027Sjungma@eit.uni-kl.de                                           sc_dt::uint64 end_range) = 0;
15712027Sjungma@eit.uni-kl.de};
15812027Sjungma@eit.uni-kl.de
15912027Sjungma@eit.uni-kl.de/////////////////////////////////////////////////////////////////////
16012027Sjungma@eit.uni-kl.de// debug interface for memory access
16112027Sjungma@eit.uni-kl.de/////////////////////////////////////////////////////////////////////
16212027Sjungma@eit.uni-kl.de//
16312027Sjungma@eit.uni-kl.de// This interface can be used to gain access to a targets memory or registers
16412027Sjungma@eit.uni-kl.de// in a non-intrusive manner. No side effects, waits or event notifications
16512027Sjungma@eit.uni-kl.de// must happen in the course of the method.
16612027Sjungma@eit.uni-kl.de//
16712027Sjungma@eit.uni-kl.de// Semantics:
16812027Sjungma@eit.uni-kl.de// - The initiator calls the transport_dbg method with transaction 'trans' as
16912027Sjungma@eit.uni-kl.de//   argument. The commonly used parts of trans for debug are:
17012027Sjungma@eit.uni-kl.de//   . address: The start address that it wants to peek or poke.
17112027Sjungma@eit.uni-kl.de//   . length:  The number of bytes that it requests to read or write.
17212027Sjungma@eit.uni-kl.de//   . command: Indicates a read or write access.
17312027Sjungma@eit.uni-kl.de//   . data:    A pointer to the initiator-allocated data buffer, which must
17412027Sjungma@eit.uni-kl.de//              be at least num_bytes large. The data is always organized in
17512027Sjungma@eit.uni-kl.de//              the endianness of the machine.
17612027Sjungma@eit.uni-kl.de//   . extensions: Any extension that could affect the transaction.
17712027Sjungma@eit.uni-kl.de// - The interconnect, if any, will decode the address and forward the call to
17812027Sjungma@eit.uni-kl.de//   the appropriate target.
17912027Sjungma@eit.uni-kl.de// - The target must return the number of successfully transmitted bytes, where
18012027Sjungma@eit.uni-kl.de//   this number must be <= num_bytes. Thus, a target can safely return 0 if it
18112027Sjungma@eit.uni-kl.de//   does not support debug transactions.
18212027Sjungma@eit.uni-kl.de//
18312027Sjungma@eit.uni-kl.detemplate <typename TRANS=tlm_generic_payload>
18412027Sjungma@eit.uni-kl.declass tlm_transport_dbg_if : public virtual sc_core::sc_interface
18512027Sjungma@eit.uni-kl.de{
18612027Sjungma@eit.uni-kl.de  public:
18712027Sjungma@eit.uni-kl.de    // The return value of defines the number of bytes successfully
18812027Sjungma@eit.uni-kl.de    // transferred.
18912027Sjungma@eit.uni-kl.de    virtual unsigned int transport_dbg(TRANS &trans) = 0;
19012027Sjungma@eit.uni-kl.de};
19112027Sjungma@eit.uni-kl.de
19212027Sjungma@eit.uni-kl.de////////////////////////////////////////////////////////////////////////////
19312027Sjungma@eit.uni-kl.de// Combined interfaces
19412027Sjungma@eit.uni-kl.de////////////////////////////////////////////////////////////////////////////
19512027Sjungma@eit.uni-kl.de
19612027Sjungma@eit.uni-kl.destruct tlm_base_protocol_types
19712027Sjungma@eit.uni-kl.de{
19812027Sjungma@eit.uni-kl.de    typedef tlm_generic_payload tlm_payload_type;
19912027Sjungma@eit.uni-kl.de    typedef tlm_phase tlm_phase_type;
20012027Sjungma@eit.uni-kl.de};
20112027Sjungma@eit.uni-kl.de
20212027Sjungma@eit.uni-kl.de// The forward interface:
20312027Sjungma@eit.uni-kl.detemplate <typename TYPES=tlm_base_protocol_types>
20412027Sjungma@eit.uni-kl.declass tlm_fw_transport_if :
20512027Sjungma@eit.uni-kl.de    public virtual tlm_fw_nonblocking_transport_if<
20612027Sjungma@eit.uni-kl.de        typename TYPES::tlm_payload_type, typename TYPES::tlm_phase_type>,
20712027Sjungma@eit.uni-kl.de    public virtual tlm_blocking_transport_if<typename TYPES::tlm_payload_type>,
20812027Sjungma@eit.uni-kl.de    public virtual tlm_fw_direct_mem_if<typename TYPES::tlm_payload_type>,
20912027Sjungma@eit.uni-kl.de    public virtual tlm_transport_dbg_if<typename TYPES::tlm_payload_type>
21012027Sjungma@eit.uni-kl.de{};
21112027Sjungma@eit.uni-kl.de
21212027Sjungma@eit.uni-kl.de// The backward interface:
21312027Sjungma@eit.uni-kl.detemplate <typename TYPES=tlm_base_protocol_types>
21412027Sjungma@eit.uni-kl.declass tlm_bw_transport_if :
21512027Sjungma@eit.uni-kl.de    public virtual tlm_bw_nonblocking_transport_if<
21612027Sjungma@eit.uni-kl.de        typename TYPES::tlm_payload_type, typename TYPES::tlm_phase_type>,
21712027Sjungma@eit.uni-kl.de    public virtual tlm_bw_direct_mem_if
21812027Sjungma@eit.uni-kl.de{};
21912027Sjungma@eit.uni-kl.de
22012027Sjungma@eit.uni-kl.de} // namespace tlm
22112027Sjungma@eit.uni-kl.de
22212027Sjungma@eit.uni-kl.de#endif /* __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_FW_BW_IFS_HH__ */
22312027Sjungma@eit.uni-kl.de