Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
scClusterBusMemoryFast.h
Go to the documentation of this file.
1 
10  /* @author János Végh (jvegh)
11  * @bug No known bugs.
12  */
13 /*
14  The origin of this development file is available as SystemC example
15  simple_bus_fast_mem.h : The memory (slave) without wait states.
16 
17  Original Author: Ric Hilderink, Synopsys, Inc., 2001-10-11
18 
19  *****************************************************************************/
20 
21 #ifndef __simple_bus_fast_mem_h
22 #define __simple_bus_fast_mem_h
23 
24 //#include <systemc.h>
25 
26 
27 #include "scClusterBusSlave_if.h" //#include "ClusterBusTypes.h"
35  : public scClusterBusSlave_if
36  , public sc_module
37 {
38 public:
39  // constructor
40  scClusterBusMemoryFast(sc_module_name name_
41  , unsigned int start_address
42  , unsigned int end_address)
43  : sc_module(name_)
44  , m_start_address(start_address)
45  , m_end_address(end_address)
46  {
47  sc_assert(m_start_address <= m_end_address);
48  sc_assert((m_end_address-m_start_address+1)%4 == 0);
49  unsigned int size = (m_end_address-m_start_address+1)/4;
50  MEM = new int [size];
51  for (unsigned int i = 0; i < size; ++i)
52  MEM[i] = 0;
53  }
54 
55  // destructor
57 
58  // direct Slave Interface
59  bool direct_read(int *data, unsigned int address);
60  bool direct_write(int *data, unsigned int address);
61  bool direct_read(scIGPMessage*){return true;};
62  bool direct_write(scIGPMessage*){return true;};
63  ClusterBusStatus read(scIGPMessage*){ return CLUSTER_BUS_OK;};
64  ClusterBusStatus write(scIGPMessage*){return CLUSTER_BUS_OK;};
65 
66  // Slave Interface
67  ClusterBusStatus read(int *data, unsigned int address);
68  ClusterBusStatus write(int *data, unsigned int address);
69 
70  unsigned int start_address() const;
71  unsigned int end_address() const;
72 
73 private:
74  int * MEM;
75  unsigned int m_start_address;
76  unsigned int m_end_address;
77 
78 }; // end class scClusterBusMemoryFast
79 
80 inline bool scClusterBusMemoryFast::direct_read(int *data, unsigned int address)
81 {
82  return (read(data, address) == CLUSTER_BUS_OK);
83 }
84 
85 inline bool scClusterBusMemoryFast::direct_write(int *data, unsigned int address)
86 {
87  return (write(data, address) == CLUSTER_BUS_OK);
88 }
89 
90 inline ClusterBusStatus scClusterBusMemoryFast::read(int *data
91  , unsigned int address)
92 {
93  *data = MEM[(address - m_start_address)/4];
94  return CLUSTER_BUS_OK;
95 }
96 
97 inline ClusterBusStatus scClusterBusMemoryFast::write(int *data
98  , unsigned int address)
99 {
100  MEM[(address - m_start_address)/4] = *data;
101  return CLUSTER_BUS_OK;
102 }
103 
104 inline scClusterBusMemoryFast::~scClusterBusMemoryFast()
105 {
106  if (MEM) delete [] MEM;
107  MEM = (int *)0;
108 }
109 
110 inline unsigned int scClusterBusMemoryFast::start_address() const
111 {
112  return m_start_address;
113 }
114 
115 inline unsigned int scClusterBusMemoryFast::end_address() const
116 {
117  return m_end_address;
118 }
119 
120 #endif
scIGPMessage
The scIGPMessage class.
Definition: scIGPMessage.h:97
scClusterBusMemoryFast
A register-type memory area per .
Definition: scClusterBusMemoryFast.h:34
scClusterBusSlave_if.h
The inter-cluster bus states.