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 __TLM_DMI_H__
2112027Sjungma@eit.uni-kl.de#define __TLM_DMI_H__
2212027Sjungma@eit.uni-kl.de
2312027Sjungma@eit.uni-kl.de#include <systemc>
2412027Sjungma@eit.uni-kl.de
2512027Sjungma@eit.uni-kl.denamespace tlm {
2612027Sjungma@eit.uni-kl.de
2712027Sjungma@eit.uni-kl.declass tlm_dmi
2812027Sjungma@eit.uni-kl.de{
2912027Sjungma@eit.uni-kl.de  public:
3012027Sjungma@eit.uni-kl.de
3112027Sjungma@eit.uni-kl.de  // Enum for indicating the access granted to the initiator.
3212027Sjungma@eit.uni-kl.de  // The initiator uses gp.m_command to indicate it intention (read/write)
3312027Sjungma@eit.uni-kl.de  //  The target is allowed to promote DMI_ACCESS_READ or DMI_ACCESS_WRITE
3412027Sjungma@eit.uni-kl.de  //  requests to dmi_access_read_write.
3512027Sjungma@eit.uni-kl.de
3612027Sjungma@eit.uni-kl.de  enum dmi_access_e
3712027Sjungma@eit.uni-kl.de  { DMI_ACCESS_NONE       = 0x00                               // no access
3812027Sjungma@eit.uni-kl.de  , DMI_ACCESS_READ       = 0x01                               // read access
3912027Sjungma@eit.uni-kl.de  , DMI_ACCESS_WRITE      = 0x02                               // write access
4012027Sjungma@eit.uni-kl.de  , DMI_ACCESS_READ_WRITE = DMI_ACCESS_READ | DMI_ACCESS_WRITE // read/write access
4112027Sjungma@eit.uni-kl.de  };
4212027Sjungma@eit.uni-kl.de
4312027Sjungma@eit.uni-kl.de  tlm_dmi (void)
4412027Sjungma@eit.uni-kl.de  {
4512027Sjungma@eit.uni-kl.de    init();
4612027Sjungma@eit.uni-kl.de  }
4712027Sjungma@eit.uni-kl.de
4812027Sjungma@eit.uni-kl.de  void init (void)
4912027Sjungma@eit.uni-kl.de  {
5012027Sjungma@eit.uni-kl.de    m_dmi_ptr           = 0x0;
5112027Sjungma@eit.uni-kl.de    m_dmi_start_address = 0x0;
5212027Sjungma@eit.uni-kl.de    m_dmi_end_address   = (sc_dt::uint64)(-1);
5312027Sjungma@eit.uni-kl.de    m_dmi_access        = DMI_ACCESS_NONE;
5412027Sjungma@eit.uni-kl.de    m_dmi_read_latency  = sc_core::SC_ZERO_TIME;
5512027Sjungma@eit.uni-kl.de    m_dmi_write_latency = sc_core::SC_ZERO_TIME;
5612027Sjungma@eit.uni-kl.de  }
5712027Sjungma@eit.uni-kl.de
5812027Sjungma@eit.uni-kl.de  unsigned char*    get_dmi_ptr           (void) const {return m_dmi_ptr;}
5912027Sjungma@eit.uni-kl.de  sc_dt::uint64     get_start_address     (void) const {return m_dmi_start_address;}
6012027Sjungma@eit.uni-kl.de  sc_dt::uint64     get_end_address       (void) const {return m_dmi_end_address;}
6112027Sjungma@eit.uni-kl.de  sc_core::sc_time  get_read_latency      (void) const {return m_dmi_read_latency;}
6212027Sjungma@eit.uni-kl.de  sc_core::sc_time  get_write_latency     (void) const {return m_dmi_write_latency;}
6312027Sjungma@eit.uni-kl.de  dmi_access_e      get_granted_access    (void) const {return m_dmi_access;}
6412027Sjungma@eit.uni-kl.de  bool              is_none_allowed       (void) const {return m_dmi_access == DMI_ACCESS_NONE;}
6512027Sjungma@eit.uni-kl.de  bool              is_read_allowed       (void) const {return (m_dmi_access & DMI_ACCESS_READ) == DMI_ACCESS_READ;}
6612027Sjungma@eit.uni-kl.de  bool              is_write_allowed      (void) const {return (m_dmi_access & DMI_ACCESS_WRITE) == DMI_ACCESS_WRITE;}
6712027Sjungma@eit.uni-kl.de  bool              is_read_write_allowed (void) const {return (m_dmi_access & DMI_ACCESS_READ_WRITE) == DMI_ACCESS_READ_WRITE;}
6812027Sjungma@eit.uni-kl.de
6912027Sjungma@eit.uni-kl.de  void              set_dmi_ptr           (unsigned char* p)   {m_dmi_ptr = p;}
7012027Sjungma@eit.uni-kl.de  void              set_start_address     (sc_dt::uint64 addr) {m_dmi_start_address = addr;}
7112027Sjungma@eit.uni-kl.de  void              set_end_address       (sc_dt::uint64 addr) {m_dmi_end_address = addr;}
7212027Sjungma@eit.uni-kl.de  void              set_read_latency      (sc_core::sc_time t) {m_dmi_read_latency = t;}
7312027Sjungma@eit.uni-kl.de  void              set_write_latency     (sc_core::sc_time t) {m_dmi_write_latency = t;}
7412027Sjungma@eit.uni-kl.de  void              set_granted_access    (dmi_access_e a)     {m_dmi_access = a;}
7512027Sjungma@eit.uni-kl.de  void              allow_none            (void)               {m_dmi_access = DMI_ACCESS_NONE;}
7612027Sjungma@eit.uni-kl.de  void              allow_read            (void)               {m_dmi_access = DMI_ACCESS_READ;}
7712027Sjungma@eit.uni-kl.de  void              allow_write           (void)               {m_dmi_access = DMI_ACCESS_WRITE;}
7812027Sjungma@eit.uni-kl.de  void              allow_read_write      (void)               {m_dmi_access = DMI_ACCESS_READ_WRITE;}
7912027Sjungma@eit.uni-kl.de
8012027Sjungma@eit.uni-kl.de  private:
8112027Sjungma@eit.uni-kl.de
8212027Sjungma@eit.uni-kl.de  // If the forward call is successful, the target returns the dmi_ptr,
8312027Sjungma@eit.uni-kl.de  // which must point to the data element corresponding to the
8412027Sjungma@eit.uni-kl.de  // dmi_start_address. The data is organized as a byte array with the
8512027Sjungma@eit.uni-kl.de  // endianness of the target (endianness member of the tlm_dmi struct).
8612027Sjungma@eit.uni-kl.de
8712027Sjungma@eit.uni-kl.de  unsigned char*   m_dmi_ptr;
8812027Sjungma@eit.uni-kl.de
8912027Sjungma@eit.uni-kl.de  // The absolute start and end addresses of the DMI region. If the decoder
9012027Sjungma@eit.uni-kl.de  // logic in the interconnect changes the address field e.g. by masking, the
9112027Sjungma@eit.uni-kl.de  // interconnect is responsible to transform the relative address back to an
9212027Sjungma@eit.uni-kl.de  // absolute address again.
9312027Sjungma@eit.uni-kl.de
9412027Sjungma@eit.uni-kl.de  sc_dt::uint64    m_dmi_start_address;
9512027Sjungma@eit.uni-kl.de  sc_dt::uint64    m_dmi_end_address;
9612027Sjungma@eit.uni-kl.de
9712027Sjungma@eit.uni-kl.de  // Granted access
9812027Sjungma@eit.uni-kl.de
9912027Sjungma@eit.uni-kl.de  dmi_access_e     m_dmi_access;
10012027Sjungma@eit.uni-kl.de
10112027Sjungma@eit.uni-kl.de  // These members define the latency of read/write transactions. The
10212027Sjungma@eit.uni-kl.de  // initiator must initialize these members to zero before requesting a
10312027Sjungma@eit.uni-kl.de  // dmi pointer, because both the interconnect as well as the target can
10412027Sjungma@eit.uni-kl.de  // add to the total transaction latency.
10512027Sjungma@eit.uni-kl.de  // Depending on the 'type' attribute only one, or both of these attributes
10612027Sjungma@eit.uni-kl.de  // will be valid.
10712027Sjungma@eit.uni-kl.de
10812027Sjungma@eit.uni-kl.de  sc_core::sc_time m_dmi_read_latency;
10912027Sjungma@eit.uni-kl.de  sc_core::sc_time m_dmi_write_latency;
11012027Sjungma@eit.uni-kl.de};
11112027Sjungma@eit.uni-kl.de
11212027Sjungma@eit.uni-kl.de} // namespace tlm
11312027Sjungma@eit.uni-kl.de
11412027Sjungma@eit.uni-kl.de#endif /* TLM_DMI_HEADER */
115