1 | /* -*- c++ -*- |
---|
2 | * File : vci_synthetic_initiator.h |
---|
3 | * Date : 26/08/2010 |
---|
4 | * Copyright : UPMC / LIP6 |
---|
5 | * Authors : Christophe Choichillon |
---|
6 | * Version : 2.1 |
---|
7 | * |
---|
8 | * SOCLIB_LGPL_HEADER_BEGIN |
---|
9 | * |
---|
10 | * This file is part of SoCLib, GNU LGPLv2.1. |
---|
11 | * |
---|
12 | * SoCLib is free software; you can redistribute it and/or modify it |
---|
13 | * under the terms of the GNU Lesser General Public License as published |
---|
14 | * by the Free Software Foundation; version 2.1 of the License. |
---|
15 | * |
---|
16 | * SoCLib is distributed in the hope that it will be useful, but |
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
19 | * Lesser General Public License for more details. |
---|
20 | * |
---|
21 | * You should have received a copy of the GNU Lesser General Public |
---|
22 | * License along with SoCLib; if not, write to the Free Software |
---|
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
24 | * 02110-1301 USA |
---|
25 | * |
---|
26 | * SOCLIB_LGPL_HEADER_END |
---|
27 | * |
---|
28 | * Versions : |
---|
29 | * - 1.0 Sending only one request at a time |
---|
30 | * - 2.0 Sending multiple transactions and broadcast responses |
---|
31 | * identified with pktid (deprecated) |
---|
32 | * - 2.1 Broadcast responses identified with the value 0 of trdid |
---|
33 | * |
---|
34 | * Maintainers: christophe.choichillon@lip6.fr |
---|
35 | */ |
---|
36 | |
---|
37 | #ifndef SOCLIB_CABA_SYNTHETIC_INITIATOR_H |
---|
38 | #define SOCLIB_CABA_SYNTHETIC_INITIATOR_H |
---|
39 | |
---|
40 | #include <cassert> |
---|
41 | #include <systemc> |
---|
42 | #include <inttypes.h> |
---|
43 | #include "generic_fifo.h" |
---|
44 | #include "vci_initiator.h" |
---|
45 | #include "soclib_endian.h" |
---|
46 | #include "caba_base_module.h" |
---|
47 | #include "int_tab.h" |
---|
48 | #include "mapping_table.h" |
---|
49 | #include "arithmetics.h" |
---|
50 | |
---|
51 | namespace soclib { namespace caba { |
---|
52 | using namespace sc_core; |
---|
53 | |
---|
54 | template<typename vci_param> |
---|
55 | class VciSyntheticInitiator |
---|
56 | : public soclib::caba::BaseModule |
---|
57 | { |
---|
58 | typedef uint32_t addr_t; |
---|
59 | typedef uint32_t data_t; |
---|
60 | typedef uint32_t tag_t; |
---|
61 | typedef uint32_t size_t; |
---|
62 | typedef uint32_t be_t; |
---|
63 | typedef uint32_t copy_t; |
---|
64 | |
---|
65 | |
---|
66 | /* States of the VCI CMD fsm */ |
---|
67 | enum vci_fsm_state_e{ |
---|
68 | VCI_IDLE, |
---|
69 | VCI_SINGLE_SEND, |
---|
70 | VCI_BC_SEND, |
---|
71 | VCI_SINGLE_REGISTER |
---|
72 | }; |
---|
73 | |
---|
74 | enum bc_fsm_state_e{ |
---|
75 | BC_RSP_IDLE, |
---|
76 | BC_RSP_WAIT_RSP |
---|
77 | }; |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | protected: |
---|
83 | |
---|
84 | SC_HAS_PROCESS(VciSyntheticInitiator); |
---|
85 | |
---|
86 | public: |
---|
87 | sc_in<bool> p_clk; |
---|
88 | sc_in<bool> p_resetn; |
---|
89 | soclib::caba::VciInitiator<vci_param> p_vci; |
---|
90 | |
---|
91 | VciSyntheticInitiator( |
---|
92 | sc_module_name name, |
---|
93 | const soclib::common::MappingTable &mt, |
---|
94 | const soclib::common::IntTab &vci_index, |
---|
95 | const uint32_t length, // Packet length (flit numbers) |
---|
96 | const uint32_t rho, // Packets ratio on the network |
---|
97 | const uint32_t depth, // Fifo depth |
---|
98 | const uint32_t xmesh, |
---|
99 | const uint32_t ymesh, |
---|
100 | const uint32_t bc_period = 0, // Broadcast period, if no broadcast => 0 |
---|
101 | const uint32_t xmin = 0, |
---|
102 | const uint32_t xmax = 0, |
---|
103 | const uint32_t ymin = 0, |
---|
104 | const uint32_t ymax = 0 |
---|
105 | ); |
---|
106 | |
---|
107 | ~VciSyntheticInitiator(); |
---|
108 | |
---|
109 | void transition(); |
---|
110 | |
---|
111 | void genMoore(); |
---|
112 | |
---|
113 | uint32_t destAdress(); |
---|
114 | |
---|
115 | uint32_t destAdress(uint32_t *rand_seed); |
---|
116 | |
---|
117 | void printStats(); |
---|
118 | |
---|
119 | double getLatencySingle(); |
---|
120 | |
---|
121 | double getLatencyBC(); |
---|
122 | |
---|
123 | void print_trace(); |
---|
124 | |
---|
125 | private: |
---|
126 | |
---|
127 | // Component attributes |
---|
128 | const size_t m_length; // Number of words to write |
---|
129 | const size_t m_rho; // offered load * 1000 |
---|
130 | const size_t m_depth; // Fifo depth |
---|
131 | const size_t m_xmesh; |
---|
132 | const size_t m_ymesh; |
---|
133 | const size_t m_bc_period; // Broadcast period, if no broadcast => 0 |
---|
134 | const size_t m_xmin; |
---|
135 | const size_t m_xmax; |
---|
136 | const size_t m_ymin; |
---|
137 | const size_t m_ymax; |
---|
138 | const size_t m_srcid; |
---|
139 | static const size_t m_tab_size = 1 << vci_param::T; |
---|
140 | |
---|
141 | |
---|
142 | // Fifo transmitting requests from the generator FSM to the VCI FSM |
---|
143 | GenericFifo<uint64_t> r_date_fifo; |
---|
144 | GenericFifo<bool> r_bc_fifo; |
---|
145 | |
---|
146 | // VCI CMD FSM |
---|
147 | sc_signal<int> r_cmd_fsm; |
---|
148 | sc_signal<addr_t> r_cmd_address; // Address for the single transaction |
---|
149 | sc_signal<int> r_cmd_trdid; // TRDID for the single transaction |
---|
150 | sc_signal<size_t> r_cmd_count; // Numbers of words sent |
---|
151 | sc_signal<uint32_t> r_cmd_seed; // seed for reproducible address generation |
---|
152 | |
---|
153 | // Broadcast FSM |
---|
154 | sc_signal<uint32_t> r_bc_nrsp; // Expected number of responses for a broadcast command |
---|
155 | |
---|
156 | // Pending transaction FSMs |
---|
157 | sc_signal<bool>* r_pending_fsm; // FSM states |
---|
158 | sc_signal<uint64_t>* r_pending_date; // single transaction requested date |
---|
159 | |
---|
160 | // Instrumentation registers |
---|
161 | sc_signal<uint64_t> r_cpt_cycles; // Local time |
---|
162 | sc_signal<uint64_t> r_cpt_period; // Number of cycles between 2 broadcast transactions |
---|
163 | sc_signal<size_t> r_nb_single; // Total number of single transactions |
---|
164 | sc_signal<uint64_t> r_latency_single; // Total cumulated latency for single transactions |
---|
165 | sc_signal<size_t> r_nb_bc; // Total number of bc transactions |
---|
166 | sc_signal<uint64_t> r_latency_bc; // Total cumulated latency for broadcast transactions |
---|
167 | |
---|
168 | }; // end class VciSyntheticInitiator |
---|
169 | |
---|
170 | }} |
---|
171 | |
---|
172 | #endif |
---|