1 | /* -*- c++ -*- |
---|
2 | * File : vci_traffic_generator.cpp |
---|
3 | * Date : 26/08/2010 |
---|
4 | * Copyright : UPMC / LIP6 |
---|
5 | * Authors : Christophe Choichillon |
---|
6 | * |
---|
7 | * SOCLIB_LGPL_HEADER_BEGIN |
---|
8 | * |
---|
9 | * This file is part of SoCLib, GNU LGPLv2.1. |
---|
10 | * |
---|
11 | * SoCLib is free software; you can redistribute it and/or modify it |
---|
12 | * under the terms of the GNU Lesser General Public License as published |
---|
13 | * by the Free Software Foundation; version 2.1 of the License. |
---|
14 | * |
---|
15 | * SoCLib is distributed in the hope that it will be useful, but |
---|
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | * Lesser General Public License for more details. |
---|
19 | * |
---|
20 | * You should have received a copy of the GNU Lesser General Public |
---|
21 | * License along with SoCLib; if not, write to the Free Software |
---|
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
23 | * 02110-1301 USA |
---|
24 | * |
---|
25 | * SOCLIB_LGPL_HEADER_END |
---|
26 | * |
---|
27 | * Maintainers: christophe.choichillon@lip6.fr |
---|
28 | */ |
---|
29 | |
---|
30 | #include "../include/vci_synthetic_initiator.h" |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | namespace soclib { namespace caba { |
---|
35 | |
---|
36 | |
---|
37 | #define tmpl(x) template<typename vci_param> x VciSyntheticInitiator<vci_param> |
---|
38 | |
---|
39 | //using soclib::common::uint32_log2; |
---|
40 | |
---|
41 | //////////////////////////////// |
---|
42 | // Constructor |
---|
43 | //////////////////////////////// |
---|
44 | |
---|
45 | tmpl(/**/)::VciSyntheticInitiator( |
---|
46 | sc_module_name name, |
---|
47 | size_t length, // Packet length (flit numbers) |
---|
48 | float rho, // Packets ratio on the network |
---|
49 | size_t depth, // Fifo depth |
---|
50 | size_t x, // |
---|
51 | size_t y, // |
---|
52 | size_t xmesh, |
---|
53 | size_t ymesh, |
---|
54 | size_t bc_period, // Broadcast period, if no broadcast => 0 |
---|
55 | size_t xmin, |
---|
56 | size_t xmax, |
---|
57 | size_t ymin, |
---|
58 | size_t ymax |
---|
59 | ) |
---|
60 | |
---|
61 | : soclib::caba::BaseModule(name), |
---|
62 | |
---|
63 | p_clk("clk"), |
---|
64 | p_resetn("resetn"), |
---|
65 | p_vci("vci_ini"), |
---|
66 | |
---|
67 | m_srcid_ini( mtc.indexForId(vci_ini_index) ), |
---|
68 | // FIFOs |
---|
69 | m_date_fifo("m_date_fifo", depth), |
---|
70 | |
---|
71 | r_tgt_cmd_fsm("r_tgt_cmd_fsm"), |
---|
72 | { |
---|
73 | |
---|
74 | // Memory cache allocation & initialisation |
---|
75 | m_cache_data = new data_t**[nways]; |
---|
76 | for ( size_t i=0 ; i<nways ; ++i ) { |
---|
77 | m_cache_data[i] = new data_t*[nsets]; |
---|
78 | } |
---|
79 | for ( size_t i=0; i<nways; ++i ) { |
---|
80 | for ( size_t j=0; j<nsets; ++j ) { |
---|
81 | m_cache_data[i][j] = new data_t[nwords]; |
---|
82 | for ( size_t k=0; k<nwords; k++){ |
---|
83 | m_cache_data[i][j][k]=0; |
---|
84 | } |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | SC_METHOD(transition); |
---|
89 | dont_initialize(); |
---|
90 | sensitive << p_clk.pos(); |
---|
91 | |
---|
92 | SC_METHOD(genMoore); |
---|
93 | dont_initialize(); |
---|
94 | sensitive << p_clk.neg(); |
---|
95 | |
---|
96 | } // end constructor |
---|
97 | |
---|
98 | |
---|
99 | ///////////////////////////////// |
---|
100 | tmpl(/**/)::~VciSyntheticInitiator() |
---|
101 | ///////////////////////////////// |
---|
102 | { |
---|
103 | delete [] r_write_to_init_cmd_data; |
---|
104 | } |
---|
105 | |
---|
106 | ////////////////////////////////// |
---|
107 | tmpl(void)::transition() |
---|
108 | ////////////////////////////////// |
---|
109 | { |
---|
110 | //using soclib::common::uint32_log2; |
---|
111 | // RESET |
---|
112 | if ( ! p_resetn.read() ) { |
---|
113 | |
---|
114 | // Initializing FSMs |
---|
115 | r_tgt_cmd_fsm = TGT_CMD_IDLE; |
---|
116 | |
---|
117 | // initializing FIFOs and communication Buffers |
---|
118 | |
---|
119 | m_date_fifo.init(); |
---|
120 | |
---|
121 | r_read_to_tgt_rsp_req = false; |
---|
122 | r_read_to_xram_cmd_req = false; |
---|
123 | |
---|
124 | r_write_to_tgt_rsp_req = false; |
---|
125 | r_write_to_xram_cmd_req = false; |
---|
126 | r_write_to_init_cmd_req = false; |
---|
127 | |
---|
128 | |
---|
129 | // Activity counters |
---|
130 | m_cpt_cycles = 0; |
---|
131 | |
---|
132 | return; |
---|
133 | } |
---|
134 | |
---|
135 | bool cmd_read_fifo_put = false; |
---|
136 | bool cmd_read_fifo_get = false; |
---|
137 | |
---|
138 | switch ( r_vci_fsm.read() ) { |
---|
139 | |
---|
140 | ////////////////// |
---|
141 | case VCI_IDLE: |
---|
142 | { |
---|
143 | break; |
---|
144 | } |
---|
145 | ////////////////// |
---|
146 | case VCI_SINGLE_SEND: |
---|
147 | { |
---|
148 | break; |
---|
149 | } |
---|
150 | ////////////////////// |
---|
151 | case VCI_SINGLE_RECEIVE: |
---|
152 | { |
---|
153 | break; |
---|
154 | } |
---|
155 | /////////////////// |
---|
156 | case VCI_BC_SEND: |
---|
157 | { |
---|
158 | break; |
---|
159 | } |
---|
160 | //////////////////// |
---|
161 | case VCI_BC_RECEIVE: |
---|
162 | { |
---|
163 | break; |
---|
164 | } |
---|
165 | } // end switch vci_fsm |
---|
166 | |
---|
167 | |
---|
168 | if ( cmd_cleanup_fifo_put ) { |
---|
169 | if ( cmd_cleanup_fifo_get ) { |
---|
170 | m_cmd_cleanup_srcid_fifo.put_and_get(p_vci_tgt.srcid.read()); |
---|
171 | m_cmd_cleanup_trdid_fifo.put_and_get(p_vci_tgt.trdid.read()); |
---|
172 | m_cmd_cleanup_pktid_fifo.put_and_get(p_vci_tgt.pktid.read()); |
---|
173 | m_cmd_cleanup_nline_fifo.put_and_get(p_vci_tgt.wdata.read()); |
---|
174 | } else { |
---|
175 | m_cmd_cleanup_srcid_fifo.simple_put(p_vci_tgt.srcid.read()); |
---|
176 | m_cmd_cleanup_trdid_fifo.simple_put(p_vci_tgt.trdid.read()); |
---|
177 | m_cmd_cleanup_pktid_fifo.simple_put(p_vci_tgt.pktid.read()); |
---|
178 | m_cmd_cleanup_nline_fifo.simple_put(p_vci_tgt.wdata.read()); |
---|
179 | } |
---|
180 | } else { |
---|
181 | if ( cmd_cleanup_fifo_get ) { |
---|
182 | m_cmd_cleanup_srcid_fifo.simple_get(); |
---|
183 | m_cmd_cleanup_trdid_fifo.simple_get(); |
---|
184 | m_cmd_cleanup_pktid_fifo.simple_get(); |
---|
185 | m_cmd_cleanup_nline_fifo.simple_get(); |
---|
186 | } |
---|
187 | } |
---|
188 | |
---|
189 | m_cpt_cycles++; |
---|
190 | |
---|
191 | } // end transition() |
---|
192 | |
---|
193 | ///////////////////////////// |
---|
194 | tmpl(void)::genMoore() |
---|
195 | ///////////////////////////// |
---|
196 | { |
---|
197 | //////////////////////////////////////////////////////////// |
---|
198 | // Command signals on the p_vci_ixr port |
---|
199 | //////////////////////////////////////////////////////////// |
---|
200 | |
---|
201 | |
---|
202 | switch ( r_vci_fsm.read() ) { |
---|
203 | |
---|
204 | ////////////////// |
---|
205 | case VCI_IDLE: |
---|
206 | { |
---|
207 | break; |
---|
208 | } |
---|
209 | ////////////////// |
---|
210 | case VCI_SINGLE_SEND: |
---|
211 | { |
---|
212 | break; |
---|
213 | } |
---|
214 | ////////////////////// |
---|
215 | case VCI_SINGLE_RECEIVE: |
---|
216 | { |
---|
217 | break; |
---|
218 | } |
---|
219 | /////////////////// |
---|
220 | case VCI_BC_SEND: |
---|
221 | { |
---|
222 | break; |
---|
223 | } |
---|
224 | //////////////////// |
---|
225 | case VCI_BC_RECEIVE: |
---|
226 | { |
---|
227 | break; |
---|
228 | } |
---|
229 | } // end switch vci_fsm |
---|
230 | |
---|
231 | } // end genMoore() |
---|
232 | |
---|
233 | }} // end name space |
---|