TLM-2.0  2.0.3
Accellera TLM-2.0 proof-of-concept library
tlm_dmi.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 #ifndef __TLM_DMI_H__
19 #define __TLM_DMI_H__
20 
21 #include <systemc>
22 
23 namespace tlm {
24 
25 class tlm_dmi
26 {
27  public:
28 
29  // Enum for indicating the access granted to the initiator.
30  // The initiator uses gp.m_command to indicate it intention (read/write)
31  // The target is allowed to promote DMI_ACCESS_READ or DMI_ACCESS_WRITE
32  // requests to dmi_access_read_write.
33 
35  { DMI_ACCESS_NONE = 0x00 // no access
36  , DMI_ACCESS_READ = 0x01 // read access
37  , DMI_ACCESS_WRITE = 0x02 // write access
39  };
40 
41  tlm_dmi (void)
42  {
43  init();
44  }
45 
46  void init (void)
47  {
48  m_dmi_ptr = 0x0;
49  m_dmi_start_address = 0x0;
50  m_dmi_end_address = (sc_dt::uint64)(-1);
51  m_dmi_access = DMI_ACCESS_NONE;
52  m_dmi_read_latency = sc_core::SC_ZERO_TIME;
53  m_dmi_write_latency = sc_core::SC_ZERO_TIME;
54  }
55 
56  unsigned char* get_dmi_ptr (void) const {return m_dmi_ptr;}
57  sc_dt::uint64 get_start_address (void) const {return m_dmi_start_address;}
58  sc_dt::uint64 get_end_address (void) const {return m_dmi_end_address;}
59  sc_core::sc_time get_read_latency (void) const {return m_dmi_read_latency;}
60  sc_core::sc_time get_write_latency (void) const {return m_dmi_write_latency;}
61  dmi_access_e get_granted_access (void) const {return m_dmi_access;}
62  bool is_none_allowed (void) const {return m_dmi_access == DMI_ACCESS_NONE;}
63  bool is_read_allowed (void) const {return (m_dmi_access & DMI_ACCESS_READ) == DMI_ACCESS_READ;}
64  bool is_write_allowed (void) const {return (m_dmi_access & DMI_ACCESS_WRITE) == DMI_ACCESS_WRITE;}
65  bool is_read_write_allowed (void) const {return (m_dmi_access & DMI_ACCESS_READ_WRITE) == DMI_ACCESS_READ_WRITE;}
66 
67  void set_dmi_ptr (unsigned char* p) {m_dmi_ptr = p;}
68  void set_start_address (sc_dt::uint64 addr) {m_dmi_start_address = addr;}
69  void set_end_address (sc_dt::uint64 addr) {m_dmi_end_address = addr;}
70  void set_read_latency (sc_core::sc_time t) {m_dmi_read_latency = t;}
71  void set_write_latency (sc_core::sc_time t) {m_dmi_write_latency = t;}
72  void set_granted_access (dmi_access_e a) {m_dmi_access = a;}
73  void allow_none (void) {m_dmi_access = DMI_ACCESS_NONE;}
74  void allow_read (void) {m_dmi_access = DMI_ACCESS_READ;}
75  void allow_write (void) {m_dmi_access = DMI_ACCESS_WRITE;}
76  void allow_read_write (void) {m_dmi_access = DMI_ACCESS_READ_WRITE;}
77 
78  private:
79 
80  // If the forward call is successful, the target returns the dmi_ptr,
81  // which must point to the data element corresponding to the
82  // dmi_start_address. The data is organized as a byte array with the
83  // endianness of the target (endianness member of the tlm_dmi struct).
84 
85  unsigned char* m_dmi_ptr;
86 
87  // The absolute start and end addresses of the DMI region. If the decoder
88  // logic in the interconnect changes the address field e.g. by masking, the
89  // interconnect is responsible to transform the relative address back to an
90  // absolute address again.
91 
92  sc_dt::uint64 m_dmi_start_address;
93  sc_dt::uint64 m_dmi_end_address;
94 
95  // Granted access
96 
97  dmi_access_e m_dmi_access;
98 
99  // These members define the latency of read/write transactions. The
100  // initiator must initialize these members to zero before requesting a
101  // dmi pointer, because both the interconnect as well as the target can
102  // add to the total transaction latency.
103  // Depending on the 'type' attribute only one, or both of these attributes
104  // will be valid.
105 
106  sc_core::sc_time m_dmi_read_latency;
107  sc_core::sc_time m_dmi_write_latency;
108 };
109 
110 } // namespace tlm
111 
112 #endif /* TLM_DMI_HEADER */
void allow_none(void)
Definition: tlm_dmi.h:73
sc_core::sc_time get_read_latency(void) const
Definition: tlm_dmi.h:59
void set_write_latency(sc_core::sc_time t)
Definition: tlm_dmi.h:71
uint64_t uint64
void set_end_address(sc_dt::uint64 addr)
Definition: tlm_dmi.h:69
sc_dt::uint64 get_start_address(void) const
Definition: tlm_dmi.h:57
void set_dmi_ptr(unsigned char *p)
Definition: tlm_dmi.h:67
bool is_read_allowed(void) const
Definition: tlm_dmi.h:63
dmi_access_e get_granted_access(void) const
Definition: tlm_dmi.h:61
void set_start_address(sc_dt::uint64 addr)
Definition: tlm_dmi.h:68
void allow_write(void)
Definition: tlm_dmi.h:75
bool is_none_allowed(void) const
Definition: tlm_dmi.h:62
tlm_dmi(void)
Definition: tlm_dmi.h:41
void set_granted_access(dmi_access_e a)
Definition: tlm_dmi.h:72
void init(void)
Definition: tlm_dmi.h:46
unsigned char * get_dmi_ptr(void) const
Definition: tlm_dmi.h:56
bool is_write_allowed(void) const
Definition: tlm_dmi.h:64
void set_read_latency(sc_core::sc_time t)
Definition: tlm_dmi.h:70
void allow_read_write(void)
Definition: tlm_dmi.h:76
sc_core::sc_time get_write_latency(void) const
Definition: tlm_dmi.h:60
sc_dt::uint64 get_end_address(void) const
Definition: tlm_dmi.h:58
const sc_time SC_ZERO_TIME
void allow_read(void)
Definition: tlm_dmi.h:74
bool is_read_write_allowed(void) const
Definition: tlm_dmi.h:65