1 | /* -*- c++ -*- |
---|
2 | * File : vci_synthetic_initiator.h |
---|
3 | * Date : 26/08/2010 |
---|
4 | * Copyright : UPMC / LIP6 |
---|
5 | * Authors : Christophe Choichillon |
---|
6 | * Version : 2.0 |
---|
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 | * Maintainers: christophe.choichillon@lip6.fr |
---|
29 | */ |
---|
30 | |
---|
31 | #ifndef SOCLIB_CABA_SYNTHETIC_INITIATOR_H |
---|
32 | #define SOCLIB_CABA_SYNTHETIC_INITIATOR_H |
---|
33 | |
---|
34 | #include <systemc> |
---|
35 | #include <inttypes.h> |
---|
36 | #include "generic_fifo.h" |
---|
37 | #include "vci_initiator.h" |
---|
38 | #include "soclib_endian.h" |
---|
39 | #include "caba_base_module.h" |
---|
40 | #include "int_tab.h" |
---|
41 | #include "mapping_table.h" |
---|
42 | #include "arithmetics.h" |
---|
43 | |
---|
44 | namespace soclib { namespace caba { |
---|
45 | using namespace sc_core; |
---|
46 | |
---|
47 | template<typename vci_param> |
---|
48 | class VciSyntheticInitiator |
---|
49 | : public soclib::caba::BaseModule |
---|
50 | { |
---|
51 | typedef uint32_t addr_t; |
---|
52 | typedef uint32_t data_t; |
---|
53 | typedef uint32_t tag_t; |
---|
54 | typedef uint32_t size_t; |
---|
55 | typedef uint32_t be_t; |
---|
56 | typedef uint32_t copy_t; |
---|
57 | |
---|
58 | |
---|
59 | /* States of the GENERATOR fsm */ |
---|
60 | enum vci_fsm_state_e{ |
---|
61 | VCI_IDLE, |
---|
62 | VCI_SINGLE_SEND, |
---|
63 | VCI_BC_SEND, |
---|
64 | }; |
---|
65 | |
---|
66 | enum bc_rsp_fsm_state_e{ |
---|
67 | BC_RSP_IDLE, |
---|
68 | BC_RSP_WAIT_RSP |
---|
69 | }; |
---|
70 | |
---|
71 | |
---|
72 | uint64_t m_cpt_cycles; // Counter of cycles |
---|
73 | |
---|
74 | |
---|
75 | protected: |
---|
76 | |
---|
77 | SC_HAS_PROCESS(VciSyntheticInitiator); |
---|
78 | |
---|
79 | public: |
---|
80 | sc_in<bool> p_clk; |
---|
81 | sc_in<bool> p_resetn; |
---|
82 | soclib::caba::VciInitiator<vci_param> p_vci; |
---|
83 | |
---|
84 | VciSyntheticInitiator( |
---|
85 | sc_module_name name, |
---|
86 | const soclib::common::MappingTable &mt, |
---|
87 | const soclib::common::IntTab &vci_index, |
---|
88 | const uint32_t length, // Packet length (flit numbers) |
---|
89 | const uint32_t rho, // Packets ratio on the network |
---|
90 | const uint32_t depth, // Fifo depth |
---|
91 | const uint32_t xmesh, |
---|
92 | const uint32_t ymesh, |
---|
93 | const uint32_t bc_period = 0, // Broadcast period, if no broadcast => 0 |
---|
94 | const uint32_t xmin = 0, |
---|
95 | const uint32_t xmax = 0, |
---|
96 | const uint32_t ymin = 0, |
---|
97 | const uint32_t ymax = 0 |
---|
98 | ); |
---|
99 | |
---|
100 | ~VciSyntheticInitiator(); |
---|
101 | |
---|
102 | void transition(); |
---|
103 | |
---|
104 | void genMoore(); |
---|
105 | |
---|
106 | uint32_t destAdress(); |
---|
107 | |
---|
108 | uint32_t destAdress(uint32_t *rand_seed); |
---|
109 | |
---|
110 | void printStats(); |
---|
111 | |
---|
112 | void print_trace(); |
---|
113 | |
---|
114 | private: |
---|
115 | |
---|
116 | // Component attributes |
---|
117 | const size_t m_length; // Number of words to write |
---|
118 | const size_t m_rho; // Rate of packets in the network wanted |
---|
119 | //const float m_rho; // Rate of packets in the network wanted |
---|
120 | const size_t m_depth; // Fifo depth |
---|
121 | const size_t m_xmesh; |
---|
122 | const size_t m_ymesh; |
---|
123 | const size_t m_bc_period; // Broadcast period, if no broadcast => 0 |
---|
124 | const size_t m_xmin; |
---|
125 | const size_t m_xmax; |
---|
126 | const size_t m_ymin; |
---|
127 | const size_t m_ymax; |
---|
128 | const size_t m_srcid; |
---|
129 | |
---|
130 | size_t m_count; // Numbers of words sent |
---|
131 | size_t m_npackets; // Total number of packets already sent |
---|
132 | uint64_t m_start_latency1; // Start time of sending packet wanted |
---|
133 | uint64_t m_start_latency2; // Start time of sending packet |
---|
134 | uint64_t m_latency1; // Average latency wanted |
---|
135 | uint64_t m_latency2; // Average latency |
---|
136 | addr_t m_address_to_send; // Address to send the write command |
---|
137 | uint32_t m_local_seed; |
---|
138 | int m_id_to_send; |
---|
139 | |
---|
140 | uint64_t m_start_latency_bc; |
---|
141 | uint64_t m_latency_bc; |
---|
142 | uint64_t m_nb_bc; |
---|
143 | |
---|
144 | static const int tab_size = 1 << vci_param::T; |
---|
145 | // Fifo transmitting date to the VCI FSM |
---|
146 | GenericFifo<uint32_t> m_date_fifo; |
---|
147 | |
---|
148 | sc_signal<int> r_cmd_fsm; |
---|
149 | |
---|
150 | sc_signal<int> r_bc_rsp_fsm; |
---|
151 | |
---|
152 | sc_signal<size_t> r_index; |
---|
153 | |
---|
154 | sc_signal<bool> r_broadcast_req; |
---|
155 | |
---|
156 | sc_signal<bool> r_broadcast_rsp; |
---|
157 | |
---|
158 | sc_signal<uint32_t> r_bc_nrsp; // Expected number of responses for a broadcast command |
---|
159 | |
---|
160 | sc_signal<uint64_t> **r_req_id; |
---|
161 | |
---|
162 | |
---|
163 | }; // end class VciSyntheticInitiator |
---|
164 | |
---|
165 | }} |
---|
166 | |
---|
167 | #endif |
---|